diff --git a/connect/auth.go b/connect/auth.go index 289f46ed30fb586ff6196fe0a23bff5860658ecb..ff5fd2e769dd552186ba9920eb72e80d56122851 100644 --- a/connect/auth.go +++ b/connect/auth.go @@ -19,11 +19,9 @@ import ( "github.com/golang/protobuf/ptypes" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" - "gitlab.com/elixxir/crypto/signature/rsa" "gitlab.com/elixxir/crypto/xx" "gitlab.com/xx_network/comms/connect/token" pb "gitlab.com/xx_network/comms/messages" - "gitlab.com/xx_network/crypto/nonce" "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/primitives/id" "google.golang.org/grpc/metadata" diff --git a/connect/auth_test.go b/connect/auth_test.go index 024f28024d32b9286670efafe0b41f984c52995d..9717e2049d36310b92a0dedb170de56945d98869 100644 --- a/connect/auth_test.go +++ b/connect/auth_test.go @@ -12,12 +12,11 @@ import ( "github.com/golang/protobuf/ptypes" "gitlab.com/elixxir/crypto/csprng" "gitlab.com/elixxir/crypto/xx" - token "gitlab.com/xx_network/comms/connect/token" + "gitlab.com/xx_network/comms/connect/token" pb "gitlab.com/xx_network/comms/messages" "gitlab.com/xx_network/comms/testkeys" "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/primitives/id" - "sync" "testing" ) diff --git a/connect/token/map.go b/connect/token/map.go index b106a8819468d41a67971524114a770f6b6379c6..5bd80390ff945a3f54389534f4330c5bfa9b8c69 100644 --- a/connect/token/map.go +++ b/connect/token/map.go @@ -2,7 +2,7 @@ package token import ( jww "github.com/spf13/jwalterweatherman" - "gitlab.com/elixxir/crypto/nonce" + "gitlab.com/xx_network/crypto/nonce" "sync" ) diff --git a/connect/token/map_test.go b/connect/token/map_test.go index d841170b9e7a761a82793f6b50e7b9d6e1a7e400..45bdacdf91e36bcc4f4425eb4b55b9756c0901c6 100644 --- a/connect/token/map_test.go +++ b/connect/token/map_test.go @@ -1,7 +1,7 @@ package token import ( - nonce2 "gitlab.com/elixxir/crypto/nonce" + nonce2 "gitlab.com/xx_network/crypto/nonce" "testing" ) diff --git a/connect/token/token.go b/connect/token/token.go index 54613584356ab9478ddc6bc763445e661c921c0e..6063c95a694668bda2263eb8b626bb4329275c8e 100644 --- a/connect/token/token.go +++ b/connect/token/token.go @@ -9,7 +9,7 @@ package token import ( "bytes" "github.com/pkg/errors" - "gitlab.com/elixxir/crypto/nonce" + "gitlab.com/xx_network/crypto/nonce" "sync" ) diff --git a/connect/token/token_test.go b/connect/token/token_test.go index 7d4bb9d0b528f592957d44a887e77d819ace4eac..b70645a9801c5ad59647cb61f9bd804e90635a2d 100644 --- a/connect/token/token_test.go +++ b/connect/token/token_test.go @@ -8,7 +8,7 @@ package token import ( "bytes" - nonce2 "gitlab.com/elixxir/crypto/nonce" + nonce2 "gitlab.com/xx_network/crypto/nonce" "reflect" "testing" ) diff --git a/gossip/endpoint_test.go b/gossip/endpoint_test.go index eb8c0af9be0183a67956f45f54de72fdd95286d2..efcd0ead67215cc881f4990c6664820968d83913 100644 --- a/gossip/endpoint_test.go +++ b/gossip/endpoint_test.go @@ -17,7 +17,11 @@ import ( // Test endpoint when manager has a protocol func TestManager_Endpoint_toProtocol(t *testing.T) { - m := NewManager(&connect.ProtoComms{}, DefaultManagerFlags()) + pc := &connect.ProtoComms{ + Manager: connect.NewManagerTesting(t), + } + + m := NewManager(pc, DefaultManagerFlags()) var received bool r := func(msg *GossipMsg) error { @@ -47,7 +51,11 @@ func TestManager_Endpoint_toProtocol(t *testing.T) { // Test endpoint function when there is no protocol and no buffer record func TestManager_Endpoint_toNewBuffer(t *testing.T) { - m := NewManager(&connect.ProtoComms{}, DefaultManagerFlags()) + pc := &connect.ProtoComms{ + Manager: connect.NewManagerTesting(t), + } + + m := NewManager(pc, DefaultManagerFlags()) _, err := m.Endpoint(context.Background(), &GossipMsg{ Tag: "test", Origin: []byte("origin"), @@ -68,7 +76,11 @@ func TestManager_Endpoint_toNewBuffer(t *testing.T) { // Test endpoint function when there is no protocol, but an existing buffer func TestComms_Endpoint_toExistingBuffer(t *testing.T) { - m := NewManager(&connect.ProtoComms{}, DefaultManagerFlags()) + pc := &connect.ProtoComms{ + Manager: connect.NewManagerTesting(t), + } + + m := NewManager(pc, DefaultManagerFlags()) now := time.Now() m.buffer["test"] = &MessageRecord{ Timestamp: now, @@ -93,7 +105,11 @@ func TestComms_Endpoint_toExistingBuffer(t *testing.T) { } func TestManager_Endpoint_AddProtocol(t *testing.T) { - m := NewManager(&connect.ProtoComms{}, DefaultManagerFlags()) + pc := &connect.ProtoComms{ + Manager: connect.NewManagerTesting(t), + } + + m := NewManager(pc, DefaultManagerFlags()) _, err := m.Endpoint(context.Background(), &GossipMsg{ Tag: "test", Origin: []byte("origin"), diff --git a/gossip/manager_test.go b/gossip/manager_test.go index b79910ba531c090a968d174df99d91e27a1159df..359544a2d9bb1f14d4283f1626c4590343fa2ec0 100644 --- a/gossip/manager_test.go +++ b/gossip/manager_test.go @@ -16,7 +16,11 @@ import ( // Basic test on manager creation func TestNewManager(t *testing.T) { - m := NewManager(&connect.ProtoComms{}, DefaultManagerFlags()) + pc := &connect.ProtoComms{ + Manager: connect.NewManagerTesting(t), + } + + m := NewManager(pc, DefaultManagerFlags()) if m.buffer == nil || m.protocols == nil { t.Error("Failed to initialize all fields properly") } @@ -24,7 +28,11 @@ func TestNewManager(t *testing.T) { // Happy path test for adding new gossip protocol func TestManager_NewGossip(t *testing.T) { - m := NewManager(&connect.ProtoComms{}, DefaultManagerFlags()) + pc := &connect.ProtoComms{ + Manager: connect.NewManagerTesting(t), + } + + m := NewManager(pc, DefaultManagerFlags()) r := func(msg *GossipMsg) error { return nil @@ -41,7 +49,11 @@ func TestManager_NewGossip(t *testing.T) { // Happy path test for new gossip protocol with messages in buffer for that tag func TestManager_NewGossip_WithBuffer(t *testing.T) { - m := NewManager(&connect.ProtoComms{}, DefaultManagerFlags()) + pc := &connect.ProtoComms{ + Manager: connect.NewManagerTesting(t), + } + + m := NewManager(pc, DefaultManagerFlags()) m.buffer["test"] = &MessageRecord{ Timestamp: time.Time{}, Messages: []*GossipMsg{{Tag: "testmsg"}}, @@ -74,7 +86,11 @@ func TestManager_NewGossip_WithBuffer(t *testing.T) { // Basic unit test for getting a protocol func TestManager_Get(t *testing.T) { - m := NewManager(&connect.ProtoComms{}, DefaultManagerFlags()) + pc := &connect.ProtoComms{ + Manager: connect.NewManagerTesting(t), + } + + m := NewManager(pc, DefaultManagerFlags()) m.protocols = map[string]*Protocol{"test": {}} _, ok := m.Get("test") @@ -85,7 +101,11 @@ func TestManager_Get(t *testing.T) { // Basic unit test for deleting a protocol func TestManager_Delete(t *testing.T) { - m := NewManager(&connect.ProtoComms{}, DefaultManagerFlags()) + pc := &connect.ProtoComms{ + Manager: connect.NewManagerTesting(t), + } + + m := NewManager(pc, DefaultManagerFlags()) m.protocols = map[string]*Protocol{"test": {}} m.Delete("test") diff --git a/gossip/protocol_test.go b/gossip/protocol_test.go index ee7f732c4101bc60c031373c25080364176247c5..c0f781456901f6ac1467e1b877468e77e9124f98 100644 --- a/gossip/protocol_test.go +++ b/gossip/protocol_test.go @@ -32,7 +32,8 @@ import ( func TestProtocol_AddGossipPeer(t *testing.T) { p := setup(t) testHostID := id.NewIdFromString("testhost", id.Node, t) - _, err := p.comms.AddHost(testHostID, "0.0.0.0:420", nil, true, false) + + _, err := p.comms.AddHost(testHostID, "0.0.0.0:420", nil, connect.GetDefaultHostParams()) if err != nil { t.Errorf("Failed to add test host: %+v", err) } @@ -179,7 +180,7 @@ func setup(t *testing.T) *Protocol { return nil } c := &connect.ProtoComms{ - Manager: connect.Manager{}, + Manager: connect.NewManagerTesting(t), } return &Protocol{ comms: c, @@ -445,7 +446,9 @@ func TestGossipNodes(t *testing.T) { for j := 0; j < numNodes; j++ { if i != j { peers = append(peers, nodes[j]) - _, err := managers[i].comms.AddHost(nodes[j], "127.0.0.1:"+ports[j], certPEM, false, false) + params := connect.GetDefaultHostParams() + params.AuthEnabled = false + _, err := managers[i].comms.AddHost(nodes[j], "127.0.0.1:"+ports[j], certPEM, params) if err != nil { t.Fatal(err) }