getProtoTopology has been replaced by PeersToProto

This helps us remove redundant code across node and handler
This commit is contained in:
Milos Gajdos
2019-09-11 23:56:57 +01:00
parent fa4ff8921e
commit 77c6c9781b
4 changed files with 65 additions and 96 deletions

View File

@@ -256,7 +256,7 @@ func TestUpdatePeerTopology(t *testing.T) {
}
}
func TestGetProtoTopology(t *testing.T) {
func TestPeersToProto(t *testing.T) {
// single node
single := &node{
id: testNodeId,
@@ -266,10 +266,10 @@ func TestGetProtoTopology(t *testing.T) {
}
topCount := 0
protoTop := single.getProtoTopology(10)
protoPeers := PeersToProto(single, single.Peers(), 0)
if len(protoTop.Peers) != topCount {
t.Errorf("Expected to find %d nodes, found: %d", topCount, len(protoTop.Peers))
if len(protoPeers.Peers) != topCount {
t.Errorf("Expected to find %d nodes, found: %d", topCount, len(protoPeers.Peers))
}
// complicated node graph
@@ -282,9 +282,9 @@ func TestGetProtoTopology(t *testing.T) {
peerIds[id] = true
}
// depth 1 should give us immmediate neighbours only
protoTop = node.getProtoTopology(1)
protoPeers = PeersToProto(node, node.Peers(), 1)
if len(protoTop.Peers) != topCount {
t.Errorf("Expected to find %d nodes, found: %d", topCount, len(protoTop.Peers))
if len(protoPeers.Peers) != topCount {
t.Errorf("Expected to find %d nodes, found: %d", topCount, len(protoPeers.Peers))
}
}