swarm/network: DRY out repeated giga comment
I not necessarily agree with the way we wait for event propagation. But I truly disagree with having duplicated giga comments.
This commit is contained in:
parent
8cfe1a6832
commit
4b2f34c824
|
@ -339,16 +339,7 @@ func TestStartStopNode(t *testing.T) {
|
||||||
t.Error("node not stopped")
|
t.Error("node not stopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep here to ensure that Network.watchPeerEvents defer function
|
waitForPeerEventPropagation()
|
||||||
// has set the `node.Up = false` before we start the node again.
|
|
||||||
// p2p/simulations/network.go:215
|
|
||||||
//
|
|
||||||
// The same node is stopped and started again, and upon start
|
|
||||||
// watchPeerEvents is started in a goroutine. If the node is stopped
|
|
||||||
// and then very quickly started, that goroutine may be scheduled later
|
|
||||||
// then start and force `node.Up = false` in its defer function.
|
|
||||||
// This will make this test unreliable.
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
|
|
||||||
err = sim.StartNode(id)
|
err = sim.StartNode(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -386,16 +377,7 @@ func TestStartStopRandomNode(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep here to ensure that Network.watchPeerEvents defer function
|
waitForPeerEventPropagation()
|
||||||
// has set the `node.Up = false` before we start the node again.
|
|
||||||
// p2p/simulations/network.go:215
|
|
||||||
//
|
|
||||||
// The same node is stopped and started again, and upon start
|
|
||||||
// watchPeerEvents is started in a goroutine. If the node is stopped
|
|
||||||
// and then very quickly started, that goroutine may be scheduled later
|
|
||||||
// then start and force `node.Up = false` in its defer function.
|
|
||||||
// This will make this test unreliable.
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
|
|
||||||
idStarted, err := sim.StartRandomNode()
|
idStarted, err := sim.StartRandomNode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -431,16 +413,7 @@ func TestStartStopRandomNodes(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep here to ensure that Network.watchPeerEvents defer function
|
waitForPeerEventPropagation()
|
||||||
// has set the `node.Up = false` before we start the node again.
|
|
||||||
// p2p/simulations/network.go:215
|
|
||||||
//
|
|
||||||
// The same node is stopped and started again, and upon start
|
|
||||||
// watchPeerEvents is started in a goroutine. If the node is stopped
|
|
||||||
// and then very quickly started, that goroutine may be scheduled later
|
|
||||||
// then start and force `node.Up = false` in its defer function.
|
|
||||||
// This will make this test unreliable.
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
|
|
||||||
ids, err = sim.StartRandomNodes(2)
|
ids, err = sim.StartRandomNodes(2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -457,3 +430,15 @@ func TestStartStopRandomNodes(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func waitForPeerEventPropagation() {
|
||||||
|
// Sleep here to ensure that Network.watchPeerEvents defer function
|
||||||
|
// has set the `node.Up() = false` before we start the node again.
|
||||||
|
//
|
||||||
|
// The same node is stopped and started again, and upon start
|
||||||
|
// watchPeerEvents is started in a goroutine. If the node is stopped
|
||||||
|
// and then very quickly started, that goroutine may be scheduled later
|
||||||
|
// then start and force `node.Up() = false` in its defer function.
|
||||||
|
// This will make this test unreliable.
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue