forked from TrueCloudLab/neoneo-go
network: optimize waiting in test
require.Eventually polls more often reducing average waiting time.
This commit is contained in:
parent
9cc4f42a71
commit
b8192d0958
1 changed files with 2 additions and 10 deletions
|
@ -87,13 +87,9 @@ func TestDefaultDiscoverer(t *testing.T) {
|
||||||
t.Fatalf("timeout expecting for transport dial")
|
t.Fatalf("timeout expecting for transport dial")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Updated asynchronously.
|
require.Eventually(t, func() bool { return len(d.UnconnectedPeers()) == 0 }, 2*time.Second, 50*time.Millisecond)
|
||||||
if len(d.UnconnectedPeers()) != 0 {
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
}
|
|
||||||
sort.Strings(dialled)
|
sort.Strings(dialled)
|
||||||
assert.Equal(t, 0, d.PoolCount())
|
assert.Equal(t, 0, d.PoolCount())
|
||||||
assert.Equal(t, 0, len(d.UnconnectedPeers()))
|
|
||||||
assert.Equal(t, 0, len(d.BadPeers()))
|
assert.Equal(t, 0, len(d.BadPeers()))
|
||||||
assert.Equal(t, 0, len(d.GoodPeers()))
|
assert.Equal(t, 0, len(d.GoodPeers()))
|
||||||
require.Equal(t, set1, dialled)
|
require.Equal(t, set1, dialled)
|
||||||
|
@ -168,11 +164,7 @@ func TestDefaultDiscoverer(t *testing.T) {
|
||||||
assert.Equal(t, set1[i], dialledBad[i*connRetries+j])
|
assert.Equal(t, set1[i], dialledBad[i*connRetries+j])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Updated asynchronously.
|
require.Eventually(t, func() bool { return len(d.BadPeers()) == len(set1) }, 2*time.Second, 50*time.Millisecond)
|
||||||
if len(d.BadPeers()) != len(set1) {
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
}
|
|
||||||
assert.Equal(t, len(set1), len(d.BadPeers()))
|
|
||||||
assert.Equal(t, 0, len(d.GoodPeers()))
|
assert.Equal(t, 0, len(d.GoodPeers()))
|
||||||
assert.Equal(t, 0, len(d.UnconnectedPeers()))
|
assert.Equal(t, 0, len(d.UnconnectedPeers()))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue