Files
goodpuppies--petplay/classes/oscReceiverSocket.test.ts
mommysgoodpuppy e4f3e651c5 Add in-VR camera setup and resilient live calibration
Expose calibration and recording controls in the wrist menu, preserve progress across grip changes, fix OSC discovery alongside other receivers, and improve camera-layer scene delivery and pacing. Document v0.0.12 and cover camera calibration, discovery and menu behavior.

Agent: Codex CLI 0.163.0; model gpt-6.1-sol; thread 01a14f56-a3aa-7bc2-9833-db8463ce54fa
2026-10-18 18:25:58 +03:00

37 lines
1.3 KiB
TypeScript

import { listenOscReceiver } from "./oscReceiverSocket.ts";
Deno.test("OSC receiver coexists with another app owning the preferred port", async () => {
const other = Deno.listenDatagram({ port: 0, transport: "udp" });
const port = (other.addr as Deno.NetAddr).port;
const receiver = listenOscReceiver(port);
const actual = (receiver.addr as Deno.NetAddr).port;
try {
if (actual === port || actual === 0) throw new Error("expected a distinct assigned port");
await other.send(new Uint8Array([42]), {
hostname: "127.0.0.1",
port: actual,
transport: "udp",
});
const [packet] = await receiver.receive();
if (packet[0] !== 42) throw new Error("receiver did not receive on assigned port");
} finally {
receiver.close();
other.close();
}
});
Deno.test("OSC receiver reuses its alternate port after restarting", () => {
const other = Deno.listenDatagram({ port: 0, transport: "udp" });
const port = (other.addr as Deno.NetAddr).port;
let receiver = listenOscReceiver(port);
try {
const actual = (receiver.addr as Deno.NetAddr).port;
receiver.close();
receiver = listenOscReceiver(port);
if ((receiver.addr as Deno.NetAddr).port !== actual) throw new Error("alternate port changed");
} finally {
receiver.close();
other.close();
}
});