Spaces:
Paused
Paused
| import OpenClawKit | |
| import Network | |
| import Testing | |
| @testable import OpenClaw | |
| struct GatewayEndpointIDTests { | |
| func stableIDForServiceDecodesAndNormalizesName() { | |
| let endpoint = NWEndpoint.service( | |
| name: "OpenClaw\\032Gateway \\032 Node\n", | |
| type: "_openclaw-gw._tcp", | |
| domain: "local.", | |
| interface: nil) | |
| #expect(GatewayEndpointID.stableID(endpoint) == "_openclaw-gw._tcp|local.|OpenClaw Gateway Node") | |
| } | |
| func stableIDForNonServiceUsesEndpointDescription() { | |
| let endpoint = NWEndpoint.hostPort(host: NWEndpoint.Host("127.0.0.1"), port: 4242) | |
| #expect(GatewayEndpointID.stableID(endpoint) == String(describing: endpoint)) | |
| } | |
| func prettyDescriptionDecodesBonjourEscapes() { | |
| let endpoint = NWEndpoint.service( | |
| name: "OpenClaw\\032Gateway", | |
| type: "_openclaw-gw._tcp", | |
| domain: "local.", | |
| interface: nil) | |
| let pretty = GatewayEndpointID.prettyDescription(endpoint) | |
| #expect(pretty == BonjourEscapes.decode(String(describing: endpoint))) | |
| #expect(!pretty.localizedCaseInsensitiveContains("\\032")) | |
| } | |
| } | |