diff --git a/cmd/root.go b/cmd/root.go index 2c4c776a2acf325058ee9725bad3491ff26ab209..43e349ff5d24603f4a3448971d92174ef9c7245b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -112,8 +112,9 @@ func setupConnection(impl *notifications.Impl, permissioningCertPath, permission // Loop until an NDF is received var def *ndf.NetworkDefinition + emptyNdf := &ndf.NetworkDefinition{} for def == nil { - def, err = notifications.PollNdf(nil, impl.Comms) + def, err = impl.Comms.PollNdf(emptyNdf) // Don't stop if error is expected if err != nil && !strings.Contains(err.Error(), ndf.NO_NDF) { return errors.Wrap(err, "Failed to get NDF") diff --git a/go.mod b/go.mod index 43ccde5bde1b0cfd48061746a18738f70714c5ba..d5bc0521690ecca1a329d542883125a4ebe21f9b 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.6.2 - gitlab.com/elixxir/comms v0.0.0-20200212195437-f1bedc602073 + gitlab.com/elixxir/comms v0.0.0-20200212195437-f1bedc602073 // indirect gitlab.com/elixxir/crypto v0.0.0-20200206203107-b8926242da23 gitlab.com/elixxir/primitives v0.0.0-20200210205543-5c55c1f6949f golang.org/x/exp v0.0.0-20200207192155-f17229e696bd // indirect diff --git a/go.sum b/go.sum index 91d05530b4b0264f3c72556a0871615b7dce2c6f..bb4193d04d8123e8084a748290912495cf2b5f6c 100644 --- a/go.sum +++ b/go.sum @@ -230,6 +230,8 @@ gitlab.com/elixxir/crypto v0.0.0-20200206203107-b8926242da23 h1:J9MKdOxLGzDZoLy2 gitlab.com/elixxir/crypto v0.0.0-20200206203107-b8926242da23/go.mod h1:wWulHuSqxiGhvasduZrtyTTqy+7y5ebe440GdORhzig= gitlab.com/elixxir/primitives v0.0.0-20200131183153-e93c6b75019f h1:F0YwFZz4umoXOJ+xX34WIRrucuLgHCSyKxWOKGaEt5g= gitlab.com/elixxir/primitives v0.0.0-20200131183153-e93c6b75019f/go.mod h1:REJMcwIcyxh74VSHqy4S9yYiaEsQYObOPglRExDpk14= +gitlab.com/elixxir/primitives v0.0.0-20200207225613-9a4445ddec16 h1:ifJ/7gl7odnp8iz09ranziiSmH+ZI4CalQW2PQn0W6M= +gitlab.com/elixxir/primitives v0.0.0-20200207225613-9a4445ddec16/go.mod h1:REJMcwIcyxh74VSHqy4S9yYiaEsQYObOPglRExDpk14= gitlab.com/elixxir/primitives v0.0.0-20200210205543-5c55c1f6949f h1:1bYEOz3/a3Q09dxE0ND64+9l21MsyeailzoFYEGC93s= gitlab.com/elixxir/primitives v0.0.0-20200210205543-5c55c1f6949f/go.mod h1:REJMcwIcyxh74VSHqy4S9yYiaEsQYObOPglRExDpk14= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= diff --git a/notifications/notifications.go b/notifications/notifications.go index 44abda7737b839b69ae8923e3e7aa638d74da4b2..e3555645bfe88a380d82b515f5dcc45e93d9857c 100644 --- a/notifications/notifications.go +++ b/notifications/notifications.go @@ -59,6 +59,7 @@ type NotificationComms interface { AddHost(id, address string, cert []byte, disableTimeout, enableAuth bool) (host *connect.Host, err error) RequestNotifications(host *connect.Host) (*pb.IDList, error) RequestNdf(host *connect.Host, message *pb.NDFHash) (*pb.NDF, error) + PollNdf(currentDef *ndf.NetworkDefinition) (*ndf.NetworkDefinition, error) } // Main function for this repo accepts credentials and an impl diff --git a/notifications/notifications_test.go b/notifications/notifications_test.go index bdc95392a5d847c96a4bdc45fc61189446569798..5dbab4cf34d981762b5fe321c57e18d9fc975a84 100644 --- a/notifications/notifications_test.go +++ b/notifications/notifications_test.go @@ -144,6 +144,9 @@ func (m mockPollComm) AddHost(id, address string, cert []byte, disableTimeout, e func (m mockPollComm) RequestNdf(host *connect.Host, message *pb.NDFHash) (*pb.NDF, error) { return nil, nil } +func (m mockPollComm) PollNdf(currentDef *ndf.NetworkDefinition) (*ndf.NetworkDefinition, error){ + return nil, nil +} type mockPollErrComm struct{} @@ -159,6 +162,9 @@ func (m mockPollErrComm) AddHost(id, address string, cert []byte, disableTimeout func (m mockPollErrComm) RequestNdf(host *connect.Host, message *pb.NDFHash) (*pb.NDF, error) { return nil, nil } +func (m mockPollErrComm) PollNdf(currentDef *ndf.NetworkDefinition) (*ndf.NetworkDefinition, error){ + return nil, nil +} // Unit test for PollForNotifications func TestPollForNotifications(t *testing.T) {