From dca131bc44c9ff9ec1509b6de78eff541b627cd8 Mon Sep 17 00:00:00 2001 From: ksparakis <ksparakis@gmail.com> Date: Wed, 12 Feb 2020 16:15:55 -0500 Subject: [PATCH] added poll ndf from comms --- cmd/root.go | 3 ++- go.mod | 2 +- go.sum | 2 ++ notifications/notifications.go | 1 + notifications/notifications_test.go | 6 ++++++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 2c4c776..43e349f 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 43ccde5..d5bc052 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 91d0553..bb4193d 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 44abda7..e355564 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 bdc9539..5dbab4c 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) { -- GitLab