-
-
Notifications
You must be signed in to change notification settings - Fork 0
Tests Normalize
mchristegh edited this page Jul 14, 2026
·
1 revision
test-scripts/normalize-harness.js — the encoding pipeline (lib/normalize.js): clone → redact → encode → measure → degrade. This is the highest edge-case-density code in the project — everything else sits on it — which is why it was built and tested first. No stubs needed; the module's built-in clone and encoder are themselves the units under test.
| Group | Why it exists |
|---|---|
| T1 — plain round-trip | The baseline contract: an ordinary message survives the pipeline deep-equal, unflagged, with _msgid kept (needed for correlating records against debug output). |
| T2 — redaction | Configured paths are masked and listed; absent paths and paths through missing parents neither appear nor throw. The listing matters — records declare what was hidden. |
| T3 — original unmutated | Proves redaction happens on the clone, never the live message. This is one half of "passthrough is sacred" — the recorder may never alter traffic. |
| T4 — circular messages | Circular structures (direct and through the root) encode to [Circular] markers instead of crashing — hostile input must never take the recorder down. |
| T5 — oversized payload | A 1MB payload against a 16KB cap degrades to summary form with truncated: true — and, critically, a redacted secret must not appear anywhere in the output, including the truncated preview. This pins the pipeline order: redact before any preview exists. |
| T6 — Buffers | Binary payloads become small placeholders carrying the true length and a hex preview — a camera frame must not bloat the tape. |
| T7 — summary capture mode | Summary-by-config produces the summary shape without the truncated flag — being configured light is not the same as being cut. |
| T8 — HTTP req/res | The classic trap: msg.req/msg.res are circular, multi-megabyte objects. They become shallow placeholders and are never deep-encoded; the original message keeps its live objects. |
| T9 — Error objects | Errors encode structurally (name, message, capped stack) — incidents carry errors as context, so they must encode well. |
| T10 — determinism | Same input twice → byte-identical output. Required for the report tests' character-exact assertions, and a property analysts can rely on. |
| E1–E8 — edge assertions | The contract's fine print: undefined payloads and dropped undefined keys, function markers, Date→ISO, non-object input tolerated, topic capping in summaries, and config validation rejecting invalid modes and caps at construction. |
Flight Recorder
Node Reference
Reference
Guides
Testing