From baf6c35e46ac71391c09b241f1c7503fa1998933 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 13 May 2022 22:20:30 +0100 Subject: [PATCH] Wait async connector in SelectorRecoveryTest --- .../kotlin/network/handler/SelectorRecoveryTest.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/commonTest/kotlin/network/handler/SelectorRecoveryTest.kt b/mirai-core/src/commonTest/kotlin/network/handler/SelectorRecoveryTest.kt index 490488b99..4358b9c1c 100644 --- a/mirai-core/src/commonTest/kotlin/network/handler/SelectorRecoveryTest.kt +++ b/mirai-core/src/commonTest/kotlin/network/handler/SelectorRecoveryTest.kt @@ -51,9 +51,11 @@ internal class SelectorRecoveryTest : AbstractNettyNHTestWithSelector() { */ @Test fun `can recover on heartbeat failure with NettyChannelException`() = runBlockingUnit { - // We allow IOException to cause a reconnect. + // We allow NetworkException to cause a reconnect. testRecoverWhenHeartbeatFailWith { NettyChannelException("test IO ex") } + bot.components[EventDispatcher].joinBroadcast() // Wait our async connector to complete. + // BotOfflineMonitor immediately launches a recovery which is UNDISPATCHED, so connection is immediately recovered. assertState(NetworkHandler.State.CONNECTING, NetworkHandler.State.LOADING, NetworkHandler.State.OK) } @@ -85,6 +87,8 @@ internal class SelectorRecoveryTest : AbstractNettyNHTestWithSelector() { bot.network.context[EventDispatcher].joinBroadcast() assertState(NetworkHandler.State.OK) + println("1") heartbeatScheduler.onHeartFailure("Test", exception()) + println("2") } } \ No newline at end of file