Establish watch relay contracts and platform package wiring
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
import RemoteCore
|
||||
import WatchBridgeCommon
|
||||
|
||||
@Test func payloadUsesUnixMillisecondsInBothDirections() throws {
|
||||
let issued = Date(timeIntervalSince1970: 1_700_000_000.125)
|
||||
let envelope = CommandEnvelope(
|
||||
sessionID: UUID(), televisionID: UUID(), sequence: 1,
|
||||
issuedAt: issued, expiresAt: issued.addingTimeInterval(0.5), command: .right
|
||||
)
|
||||
let container = try RelayContainer(kind: .command, value: envelope)
|
||||
let data = container.payload
|
||||
#expect(container.schemaVersion == RelayWire.schemaVersion)
|
||||
#expect(container.kind == .command)
|
||||
let object = try #require(JSONSerialization.jsonObject(with: data) as? [String: Any])
|
||||
#expect((object["issuedAt"] as? Double) == 1_700_000_000_125)
|
||||
#expect((object["expiresAt"] as? Double) == 1_700_000_000_625)
|
||||
#expect(try RelayJSON.decode(CommandEnvelope.self, from: data) == envelope)
|
||||
}
|
||||
|
||||
@Test func outgoingContainerRejectsOversizedPayload() {
|
||||
#expect(throws: RelayContractError.payloadTooLarge) {
|
||||
try RelayContainer(kind: .error, value: String(repeating: "x", count: RelayWire.maximumPayloadBytes))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user