mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm: calc kad depth outside loop in EachBin test
This commit is contained in:
parent
c305a3eb83
commit
8de234a335
1 changed files with 4 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue