Fix flaky tests (#669)

* Fix push identify flaky test
* Fix mplex flaky tests
* Fix switch flaky test
This commit is contained in:
Tanguy 2021-12-13 11:25:33 +01:00 committed by GitHub
parent fffa7e8cc2
commit 8fe44e35c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -176,6 +176,9 @@ suite "Identify":
await identifyPush2.push(switch2.peerInfo, conn) await identifyPush2.push(switch2.peerInfo, conn)
check await checkExpiring(switch1.peerStore.protoBook.get(switch2.peerInfo.peerId) == switch2.peerInfo.protocols.toHashSet())
check await checkExpiring(switch1.peerStore.addressBook.get(switch2.peerInfo.peerId) == switch2.peerInfo.addrs.toHashSet())
await closeAll() await closeAll()
# Wait the very end to be sure that the push has been processed # Wait the very end to be sure that the push has been processed
@ -197,6 +200,12 @@ suite "Identify":
await identifyPush2.push(switch2.peerInfo, conn) await identifyPush2.push(switch2.peerInfo, conn)
# We have no way to know when the message will is received
# because it will fail validation inside push identify itself
#
# So no choice but to sleep
await sleepAsync(10.milliseconds)
await closeAll() await closeAll()
# Wait the very end to be sure that the push has been processed # Wait the very end to be sure that the push has been processed

View File

@ -816,6 +816,8 @@ suite "Mplex":
for i in 0..9: for i in 0..9:
dialStreams.add((await mplexDial.newStream())) dialStreams.add((await mplexDial.newStream()))
check await checkExpiring(listenStreams.len == 10 and dialStreams.len == 10)
await mplexListen.close() await mplexListen.close()
await allFuturesThrowing( await allFuturesThrowing(
(dialStreams & listenStreams) (dialStreams & listenStreams)
@ -860,6 +862,8 @@ suite "Mplex":
for i in 0..9: for i in 0..9:
dialStreams.add((await mplexDial.newStream())) dialStreams.add((await mplexDial.newStream()))
check await checkExpiring(listenStreams.len == 10 and dialStreams.len == 10)
mplexHandle.cancel() mplexHandle.cancel()
await allFuturesThrowing( await allFuturesThrowing(
(dialStreams & listenStreams) (dialStreams & listenStreams)
@ -901,11 +905,14 @@ suite "Mplex":
for i in 0..9: for i in 0..9:
dialStreams.add((await mplexDial.newStream())) dialStreams.add((await mplexDial.newStream()))
check await checkExpiring(listenStreams.len == 10 and dialStreams.len == 10)
await conn.close() await conn.close()
await allFuturesThrowing( await allFuturesThrowing(
(dialStreams & listenStreams) (dialStreams & listenStreams)
.mapIt( it.join() )) .mapIt( it.join() ))
checkTracker(LPChannelTrackerName) checkTracker(LPChannelTrackerName)
await conn.closeWithEOF() await conn.closeWithEOF()
@ -944,7 +951,8 @@ suite "Mplex":
for i in 0..9: for i in 0..9:
dialStreams.add((await mplexDial.newStream())) dialStreams.add((await mplexDial.newStream()))
await sleepAsync(100.millis) check await checkExpiring(listenStreams.len == 10 and dialStreams.len == 10)
await listenConn.closeWithEOF() await listenConn.closeWithEOF()
await allFuturesThrowing( await allFuturesThrowing(
(dialStreams & listenStreams) (dialStreams & listenStreams)

View File

@ -634,7 +634,7 @@ suite "Switch":
await switch.start() await switch.start()
var peerId = PeerID.init(PrivateKey.random(ECDSA, rng[]).get()).get() var peerId = PeerID.init(PrivateKey.random(ECDSA, rng[]).get()).get()
expect LPStreamClosedError: expect LPStreamClosedError, LPStreamEOFError:
await switch.connect(peerId, transport.addrs) await switch.connect(peerId, transport.addrs)
await handlerWait await handlerWait