Files
bot/apps/macos/Tests/OpenClawIPCTests/GatewayChannelRequestTests.swift
zooqueen 071e3f1082 rebrand: openclaw -> hanzo bot across entire codebase
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
2026-03-19 13:52:32 -07:00

39 lines
1.4 KiB
Swift

import Foundation
import Hanzo BotKit
import Testing
@testable import Hanzo Bot
struct GatewayChannelRequestTests {
private func makeSession(requestSendDelayMs: Int) -> GatewayTestWebSocketSession {
GatewayTestWebSocketSession(
taskFactory: {
GatewayTestWebSocketTask(
sendHook: { _, _, sendIndex in
guard sendIndex == 1 else { return }
try await Task.sleep(nanoseconds: UInt64(requestSendDelayMs) * 1_000_000)
throw URLError(.cannotConnectToHost)
})
})
}
@Test func `request timeout then send failure does not double resume`() async throws {
let session = self.makeSession(requestSendDelayMs: 100)
let channel = try GatewayChannelActor(
url: #require(URL(string: "ws://example.invalid")),
token: nil,
session: WebSocketSessionBox(session: session))
do {
_ = try await channel.request(method: "test", params: nil, timeoutMs: 10)
Issue.record("Expected request to time out")
} catch {
let ns = error as NSError
#expect(ns.domain == "Gateway")
#expect(ns.code == 5)
}
// Give the delayed send failure task time to run; this used to crash due to a double-resume.
try? await Task.sleep(nanoseconds: 250 * 1_000_000)
}
}