swarm/network: use hive.depth and fix race condition

This commit is contained in:
Fabio Barone 2019-03-22 18:13:23 -05:00
parent df57c5875b
commit ad17048bd4
2 changed files with 4 additions and 5 deletions

View file

@ -130,7 +130,9 @@ func testSubpeersMsg(t *testing.T) {
control := s.Nodes[0]
// get BzzAddr of the control
hive.lock.Lock()
controlBzz := hive.peers[control.ID()].Over()
hive.lock.Unlock()
// build a control kademlia for the control node from the address pool
// we use this so we can identify the actual `controlDepth` of the control node
controlKad := NewKademlia(controlBzz, NewKadParams())
@ -155,9 +157,6 @@ func testSubpeersMsg(t *testing.T) {
return true
})
// this is the hive's depth, which will be sent first to the control node initiating the test exchanges
hiveDepth := hive.NeighbourhoodDepth()
// if the controlDepth is 0, nothing will happen, so in this case artificially set it to 2
if controlDepth == 0 {
controlDepth = 2
@ -172,7 +171,7 @@ func testSubpeersMsg(t *testing.T) {
Expects: []p2ptest.Expect{
{
Code: 1,
Msg: &subPeersMsg{Depth: uint8(hiveDepth)},
Msg: &subPeersMsg{Depth: uint8(hive.depth)},
Peer: control.ID(),
},
},

View file

@ -132,7 +132,7 @@ func newPreconnectedBzzBaseTester(t *testing.T, waitC chan struct{}, preConns []
s := p2ptest.NewProtocolTester(prvkey, n, protocol)
for _, node := range s.Nodes {
log.Warn("node", "node", node)
log.Debug("node", "node", node)
cs[node.ID().String()] = make(chan bool)
}