Pin the discovery frame against a real capture
The gateway and backend halves of `discovered_printers` are hand-synced, so every hand-written example in this file agrees with whichever side wrote it - which is exactly how the two ends of /ws/edge/v1 drifted into different protocols before. A capture is the only thing that catches that. This one came off a live LAN with a Bambu P1P and H2C on it, through the gateway's own serde enum, with its fleet file pointed at an empty file so nothing was filtered out. The addresses and the shape are as captured. The two serials are placeholders of the captured shape. They identify someone's physical hardware, no test depends on their value, and no other fixture here carries one - so the real ones are not something to commit on the owner's behalf.
This commit is contained in:
@@ -10,6 +10,7 @@ import "../src/validation/formats";
|
||||
|
||||
import currentCapture from "./fixtures/gateway_frames.json";
|
||||
import legacyCapture from "./fixtures/gateway_frames_legacy_nulls.json";
|
||||
import discoveryCapture from "./fixtures/gateway_discovery_frame.json";
|
||||
|
||||
/**
|
||||
* A contract test, not a unit test: it checks that what continuum-proxy
|
||||
@@ -152,6 +153,23 @@ describe("gateway -> backend frames", () => {
|
||||
driver_ready: true,
|
||||
};
|
||||
|
||||
it("accepts the real scan captured from a live LAN", () => {
|
||||
// The one case a hand-written example cannot cover. Everything below
|
||||
// agrees with how this test file imagines the gateway behaves; this
|
||||
// agrees with what the gateway actually emitted, through its own serde
|
||||
// enum, about two real printers. The two halves of this message are
|
||||
// hand-synced, so a capture is the only thing that catches a drift.
|
||||
for (const frame of discoveryCapture.frames) {
|
||||
check(EdgeClientMessageSchema, frame);
|
||||
}
|
||||
// Guards against a fixture that validates because it is empty.
|
||||
const printers = discoveryCapture.frames[0].printers;
|
||||
expect(printers.length).toBeGreaterThan(0);
|
||||
// And against one that validates because every field is absent: the
|
||||
// address is the entire reason this message exists.
|
||||
expect(printers.every((p) => p.address.length > 0 && p.vendor.length > 0)).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts a scan result", () => {
|
||||
check(EdgeClientMessageSchema, {
|
||||
type: "discovered_printers",
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"_note": "A real `discovered_printers` frame, captured on 2026-10-19 by running `cargo run --example discover_printers -- wire 192.168.0.0/24` against a live LAN with a Bambu P1P and H2C on it, with the gateway's fleet file pointed at an empty file so nothing was filtered out. The addresses and the message shape are exactly as captured. The two `serial` values are PLACEHOLDERS of the captured shape (15 alphanumeric characters) rather than the real ones: the serials identify someone's physical hardware, nothing in this test depends on their value, and no other fixture here carries one. Note what the frame does not contain, which is the point of the format: no access code, no API key. Re-capture with the `wire` subcommand above when the message changes.",
|
||||
"frames": [
|
||||
{
|
||||
"type": "discovered_printers",
|
||||
"printers": [
|
||||
{
|
||||
"vendor": "bambu",
|
||||
"address": "192.168.0.20",
|
||||
"serial": "01S00A000000000",
|
||||
"source": "certificate",
|
||||
"driver_ready": true
|
||||
},
|
||||
{
|
||||
"vendor": "bambu",
|
||||
"address": "192.168.0.21",
|
||||
"serial": "31B0BP0A0000000",
|
||||
"source": "certificate",
|
||||
"driver_ready": true
|
||||
}
|
||||
],
|
||||
"scanned_at": "2026-10-19T08:20:03Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user