p2p/simulations: fix staticcheck warnings (#20322)

This commit is contained in:
Felix Lange
2019-11-19 17:16:42 +01:00
committed by GitHub
parent 9e8cc00b73
commit df206d2513
5 changed files with 128 additions and 190 deletions

View File

@ -80,14 +80,17 @@ func TestMocker(t *testing.T) {
var opts SubscribeOpts
sub, err := client.SubscribeNetwork(events, opts)
defer sub.Unsubscribe()
//wait until all nodes are started and connected
//store every node up event in a map (value is irrelevant, mimic Set datatype)
// wait until all nodes are started and connected
// store every node up event in a map (value is irrelevant, mimic Set datatype)
nodemap := make(map[enode.ID]bool)
wg.Add(1)
nodesComplete := false
connCount := 0
wg.Add(1)
go func() {
for {
defer wg.Done()
for connCount < (nodeCount-1)*2 {
select {
case event := <-events:
if isNodeUp(event) {
@ -99,14 +102,10 @@ func TestMocker(t *testing.T) {
}
} else if event.Conn != nil && nodesComplete {
connCount += 1
if connCount == (nodeCount-1)*2 {
wg.Done()
return
}
}
case <-time.After(30 * time.Second):
wg.Done()
t.Fatalf("Timeout waiting for nodes being started up!")
t.Errorf("Timeout waiting for nodes being started up!")
return
}
}
}()