diff --git a/swarm/network/kademlia_test.go b/swarm/network/kademlia_test.go index 9804dd2eb9..ac459c436b 100644 --- a/swarm/network/kademlia_test.go +++ b/swarm/network/kademlia_test.go @@ -843,9 +843,10 @@ func TestEachBin(t *testing.T) { } //run the k.EachBin function k.EachBin(addr[:], pot.DefaultPof(k.MaxProxDisplay), 0, eachBinFunc) + //calculate the kademlia depth + kdepth := k.NeighbourhoodDepth() //now, check that all peers have the expected (fake) subscriptions - //iterate the bin map for bin, peers := range binMap { //for every peer... @@ -853,7 +854,7 @@ func TestEachBin(t *testing.T) { //...get its (fake) subscriptions fakeSubs := fakeSubscriptions[peer] //if the peer's bin is below the kademlia depth... - if bin < k.NeighbourhoodDepth() { + if bin < kdepth { //(iterate all (fake) subscriptions) for _, subbin := range fakeSubs { //...only the peer's bin should be "subscribed" @@ -867,7 +868,7 @@ func TestEachBin(t *testing.T) { for i, subbin := range fakeSubs { //...each bin from the peer's bin number up to k.MaxProxDisplay should be "subscribed" // as we start from depth we can use the iteration index to check - if subbin != i+k.NeighbourhoodDepth() { + if subbin != i+kdepth { t.Fatalf("Did not get expected subscription for bin > depth; bin of peer %s: %d, subscription: %d", peer, bin, subbin) } //the last "subscription" should be k.MaxProxDisplay