test(relay): annotate the hostile handshake frame instead of suppressing a cast

JSON.parse answers `any`, so a typed const expresses the same deliberate lie the
assertion did and the casting gate has nothing to flag. One fewer suppression.
This commit is contained in:
Neil
2026-09-17 00:17:50 -07:00
parent 87360c5a45
commit 66a2e9db63
+5 -5
View File
@@ -258,12 +258,12 @@ describe('handshake round-trip over a real Socket pair', () => {
const hostile = connect(sockPath)
await new Promise<void>((r) => hostile.once('connect', () => r()))
const hostileClosed = new Promise<void>((r) => hostile.once('close', () => r()))
hostile.write(
encodeHandshakeFrame(
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: deliberately a lie. This is the frame a hostile peer sends and the type system cannot describe; the cast is what lets the encoder put it on the wire.
JSON.parse('{"type":"orca-relay-handshake","version":{"toString":1}}') as HandshakeMessage
)
// The annotation is deliberately a lie: this is the frame a hostile peer sends, and
// HandshakeMessage cannot describe it. JSON.parse answers `any`, so it needs no assertion.
const hostileFrame: HandshakeMessage = JSON.parse(
'{"type":"orca-relay-handshake","version":{"toString":1}}'
)
hostile.write(encodeHandshakeFrame(hostileFrame))
await hostileClosed
const good = connect(sockPath)