mirror of
https://github.com/hanzoai/bot.git
synced 2026-11-01 07:38:30 +00:00
Automated rebrand of all openclaw references to hanzo bot: - Package: openclaw -> @hanzo/bot - Binary: openclaw -> hanzo-bot - Config: ~/.openclaw -> ~/.hanzo/bot - Docker: ghcr.io/hanzoai/bot - Env vars: OPENCLAW_* -> BOT_* - Bundle IDs: ai.hanzo.bot.* - Product name: Hanzo Bot
30 lines
1.0 KiB
Swift
30 lines
1.0 KiB
Swift
import Foundation
|
|
import Hanzo BotKit
|
|
import Testing
|
|
@testable import Hanzo Bot
|
|
|
|
struct GatewayChannelShutdownTests {
|
|
@Test func `shutdown prevents reconnect loop from receive failure`() async throws {
|
|
let session = GatewayTestWebSocketSession()
|
|
let channel = try GatewayChannelActor(
|
|
url: #require(URL(string: "ws://example.invalid")),
|
|
token: nil,
|
|
session: WebSocketSessionBox(session: session))
|
|
|
|
// Establish a connection so `listen()` is active.
|
|
try await channel.connect()
|
|
#expect(session.snapshotMakeCount() == 1)
|
|
|
|
// Simulate a socket receive failure, which would normally schedule a reconnect.
|
|
session.latestTask()?.emitReceiveFailure()
|
|
|
|
// Shut down quickly, before backoff reconnect triggers.
|
|
await channel.shutdown()
|
|
|
|
// Wait longer than the default reconnect backoff (500ms) to ensure no reconnect happens.
|
|
try? await Task.sleep(nanoseconds: 750 * 1_000_000)
|
|
|
|
#expect(session.snapshotMakeCount() == 1)
|
|
}
|
|
}
|