Flaky Test In dot/peerset/peerset_test.go
Describe the bug
Sometimes succeeds, sometimes doesn't. Looks like when it fails its due to the times being equal, so milliseconds matter here.
triedToConnectAt := ps.peerState.nodes[peer1].lastConnected[testSetID]
require.True(t, lastDisconectedAt.Before(triedToConnectAt))
go test -timeout 30s -run $Test$ github.com/ChainSafe/gossamer/dot/peerset -count=1
=== TestBanRejectAcceptPeer
peerset_test.go:56:
Error Trace: C:/Users/User/Path/To/gossamer/dot/peerset/peerset_test.go:56
Error: Should be true
Test: TestBanRejectAcceptPeer
lastDisconnectedAt: 2023-07-05 02:24:22.0133831 -0400 EDT m=+0.112701101
triedToConnectAt: 2023-07-05 02:24:22.0133831 -0400 EDT m=+0.112701101
Equal Times: true
Machine: Windows 10 x64 based Version: 10.0.19045 Build 19045
I think our best option is to check for equal-ness as well. I tried extending the time to nanoseconds, but the test still failed every now and then.
triedToConnectAt := ps.peerState.nodes[peer1].lastConnected[testSetID]
beforeOrEqualTime := lastDisconectedAt.Before(triedToConnectAt) || lastDisconectedAt.Equal(triedToConnectAt)
require.True(t, beforeOrEqualTime)
Let me know your thoughts. Happy to work on this
@juanri0s, feel free to propose a fix to this problem! If you need help tag me 👍
Is this issue still relevant? I run the test many times and it always pass:
go test -timeout 30000s -run=TestBanRejectAcceptPeer -count=1000
PASS
ok github.com/ChainSafe/gossamer/dot/peerset 1301.643s