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
37 lines
1.2 KiB
Swift
37 lines
1.2 KiB
Swift
import Hanzo BotProtocol
|
|
import Testing
|
|
@testable import Hanzo Bot
|
|
|
|
struct InstancesStoreTests {
|
|
@Test
|
|
@MainActor
|
|
func `presence event payload decodes via JSON encoder`() {
|
|
// Build a payload that mirrors the gateway's presence event shape:
|
|
// { "presence": [ PresenceEntry ] }
|
|
let entry: [String: Hanzo BotProtocol.AnyCodable] = [
|
|
"host": .init("gw"),
|
|
"ip": .init("10.0.0.1"),
|
|
"version": .init("2.0.0"),
|
|
"mode": .init("gateway"),
|
|
"lastInputSeconds": .init(5),
|
|
"reason": .init("test"),
|
|
"text": .init("Gateway node"),
|
|
"ts": .init(1_730_000_000),
|
|
]
|
|
let payloadMap: [String: Hanzo BotProtocol.AnyCodable] = [
|
|
"presence": .init([Hanzo BotProtocol.AnyCodable(entry)]),
|
|
]
|
|
let payload = Hanzo BotProtocol.AnyCodable(payloadMap)
|
|
|
|
let store = InstancesStore(isPreview: true)
|
|
store.handlePresenceEventPayload(payload)
|
|
|
|
#expect(store.instances.count == 1)
|
|
let instance = store.instances.first
|
|
#expect(instance?.host == "gw")
|
|
#expect(instance?.ip == "10.0.0.1")
|
|
#expect(instance?.mode == "gateway")
|
|
#expect(instance?.reason == "test")
|
|
}
|
|
}
|