diff --git a/mirai-core/src/commonMain/kotlin/network/components/BotOfflineEventMonitor.kt b/mirai-core/src/commonMain/kotlin/network/components/BotOfflineEventMonitor.kt index 44f4aac42..61ad38f63 100644 --- a/mirai-core/src/commonMain/kotlin/network/components/BotOfflineEventMonitor.kt +++ b/mirai-core/src/commonMain/kotlin/network/components/BotOfflineEventMonitor.kt @@ -42,7 +42,7 @@ private data class BotClosedByEvent(val event: BotOfflineEvent) : RuntimeExcepti internal class BotOfflineEventMonitorImpl : BotOfflineEventMonitor { override fun attachJob(bot: AbstractBot, scope: CoroutineScope) { - return + return // leave it until 2.7-RC bot.eventChannel.parentScope(scope).subscribeAlways( ::onEvent, priority = EventPriority.MONITOR, diff --git a/mirai-core/src/commonTest/kotlin/network/impl/netty/NettyBotLifecycleTest.kt b/mirai-core/src/commonTest/kotlin/network/impl/netty/NettyBotLifecycleTest.kt index cd0a07c07..669cf4b65 100644 --- a/mirai-core/src/commonTest/kotlin/network/impl/netty/NettyBotLifecycleTest.kt +++ b/mirai-core/src/commonTest/kotlin/network/impl/netty/NettyBotLifecycleTest.kt @@ -12,11 +12,7 @@ package net.mamoe.mirai.internal.network.impl.netty import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.isActive -import net.mamoe.mirai.event.broadcast -import net.mamoe.mirai.event.events.BotOfflineEvent import net.mamoe.mirai.internal.MockBot -import net.mamoe.mirai.internal.network.components.BotOfflineEventMonitor -import net.mamoe.mirai.internal.network.components.BotOfflineEventMonitorImpl import net.mamoe.mirai.internal.network.handler.NetworkHandler.State.* import net.mamoe.mirai.internal.test.runBlockingUnit import net.mamoe.mirai.supervisorJob @@ -27,27 +23,30 @@ import kotlin.test.assertTrue internal class NettyBotLifecycleTest : AbstractNettyNHTest() { - @Test - fun `closed on Force offline with BotOfflineEventMonitor`() = runBlockingUnit { - defaultComponents[BotOfflineEventMonitor] = BotOfflineEventMonitorImpl() - bot.login() - assertState(OK) - BotOfflineEvent.Force(bot, "test", "test").broadcast() - assertState(CLOSED) - assertFalse { network.isActive } - assertTrue { bot.isActive } - } - @Test - fun `closed on Active offline with BotOfflineEventMonitor`() = runBlockingUnit { - defaultComponents[BotOfflineEventMonitor] = BotOfflineEventMonitorImpl() - bot.login() - assertState(OK) - BotOfflineEvent.Active(bot, null).broadcast() - assertState(CLOSED) - assertFalse { network.isActive } - assertTrue { bot.isActive } - } + // not allowed anymore + +// @Test +// fun `closed on Force offline with BotOfflineEventMonitor`() = runBlockingUnit { +// defaultComponents[BotOfflineEventMonitor] = BotOfflineEventMonitorImpl() +// bot.login() +// assertState(OK) +// BotOfflineEvent.Force(bot, "test", "test").broadcast() +// assertState(CLOSED) +// assertFalse { network.isActive } +// assertTrue { bot.isActive } +// } + +// @Test +// fun `closed on Active offline with BotOfflineEventMonitor`() = runBlockingUnit { +// defaultComponents[BotOfflineEventMonitor] = BotOfflineEventMonitorImpl() +// bot.login() +// assertState(OK) +// BotOfflineEvent.Active(bot, null).broadcast() +// assertState(CLOSED) +// assertFalse { network.isActive } +// assertTrue { bot.isActive } +// } @Test