mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
feat: 在初始化失败时停止 Peer 实例并更新测试用例以验证关闭状态
This commit is contained in:
@@ -102,6 +102,7 @@ class Peer:
|
||||
raise AstrBotError.protocol_error("initialize 必须收到 initialize_result")
|
||||
if not result.success:
|
||||
self._unusable = True
|
||||
await self.stop()
|
||||
raise AstrBotError.from_payload(result.error.model_dump() if result.error else {})
|
||||
output = InitializeOutput.model_validate(result.output)
|
||||
self.remote_peer = output.peer
|
||||
|
||||
@@ -220,9 +220,9 @@ class PeerRuntimeTest(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertEqual(raised.exception.code, "protocol_version_mismatch")
|
||||
|
||||
await asyncio.wait_for(core.wait_closed(), timeout=1.0)
|
||||
await asyncio.wait_for(plugin.wait_closed(), timeout=1.0)
|
||||
self.assertTrue(core._closed)
|
||||
|
||||
await plugin.stop()
|
||||
self.assertTrue(plugin._closed)
|
||||
|
||||
|
||||
class CapabilityRouterContractTest(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user