Skip to content
Snippets Groups Projects
Commit dca131bc authored by ksparakis's avatar ksparakis
Browse files

added poll ndf from comms

parent c743ca8e
No related branches found
No related tags found
No related merge requests found
...@@ -112,8 +112,9 @@ func setupConnection(impl *notifications.Impl, permissioningCertPath, permission ...@@ -112,8 +112,9 @@ func setupConnection(impl *notifications.Impl, permissioningCertPath, permission
// Loop until an NDF is received // Loop until an NDF is received
var def *ndf.NetworkDefinition var def *ndf.NetworkDefinition
emptyNdf := &ndf.NetworkDefinition{}
for def == nil { for def == nil {
def, err = notifications.PollNdf(nil, impl.Comms) def, err = impl.Comms.PollNdf(emptyNdf)
// Don't stop if error is expected // Don't stop if error is expected
if err != nil && !strings.Contains(err.Error(), ndf.NO_NDF) { if err != nil && !strings.Contains(err.Error(), ndf.NO_NDF) {
return errors.Wrap(err, "Failed to get NDF") return errors.Wrap(err, "Failed to get NDF")
......
...@@ -22,7 +22,7 @@ require ( ...@@ -22,7 +22,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.6.2 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/crypto v0.0.0-20200206203107-b8926242da23
gitlab.com/elixxir/primitives v0.0.0-20200210205543-5c55c1f6949f gitlab.com/elixxir/primitives v0.0.0-20200210205543-5c55c1f6949f
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd // indirect golang.org/x/exp v0.0.0-20200207192155-f17229e696bd // indirect
......
...@@ -230,6 +230,8 @@ gitlab.com/elixxir/crypto v0.0.0-20200206203107-b8926242da23 h1:J9MKdOxLGzDZoLy2 ...@@ -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/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 h1:F0YwFZz4umoXOJ+xX34WIRrucuLgHCSyKxWOKGaEt5g=
gitlab.com/elixxir/primitives v0.0.0-20200131183153-e93c6b75019f/go.mod h1:REJMcwIcyxh74VSHqy4S9yYiaEsQYObOPglRExDpk14= 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 h1:1bYEOz3/a3Q09dxE0ND64+9l21MsyeailzoFYEGC93s=
gitlab.com/elixxir/primitives v0.0.0-20200210205543-5c55c1f6949f/go.mod h1:REJMcwIcyxh74VSHqy4S9yYiaEsQYObOPglRExDpk14= 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= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
......
...@@ -59,6 +59,7 @@ type NotificationComms interface { ...@@ -59,6 +59,7 @@ type NotificationComms interface {
AddHost(id, address string, cert []byte, disableTimeout, enableAuth bool) (host *connect.Host, err error) AddHost(id, address string, cert []byte, disableTimeout, enableAuth bool) (host *connect.Host, err error)
RequestNotifications(host *connect.Host) (*pb.IDList, error) RequestNotifications(host *connect.Host) (*pb.IDList, error)
RequestNdf(host *connect.Host, message *pb.NDFHash) (*pb.NDF, 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 // Main function for this repo accepts credentials and an impl
......
...@@ -144,6 +144,9 @@ func (m mockPollComm) AddHost(id, address string, cert []byte, disableTimeout, e ...@@ -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) { func (m mockPollComm) RequestNdf(host *connect.Host, message *pb.NDFHash) (*pb.NDF, error) {
return nil, nil return nil, nil
} }
func (m mockPollComm) PollNdf(currentDef *ndf.NetworkDefinition) (*ndf.NetworkDefinition, error){
return nil, nil
}
type mockPollErrComm struct{} type mockPollErrComm struct{}
...@@ -159,6 +162,9 @@ func (m mockPollErrComm) AddHost(id, address string, cert []byte, disableTimeout ...@@ -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) { func (m mockPollErrComm) RequestNdf(host *connect.Host, message *pb.NDFHash) (*pb.NDF, error) {
return nil, nil return nil, nil
} }
func (m mockPollErrComm) PollNdf(currentDef *ndf.NetworkDefinition) (*ndf.NetworkDefinition, error){
return nil, nil
}
// Unit test for PollForNotifications // Unit test for PollForNotifications
func TestPollForNotifications(t *testing.T) { func TestPollForNotifications(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment