-
-
Notifications
You must be signed in to change notification settings - Fork 0
Tests Persistence
mchristegh edited this page Jul 14, 2026
·
1 revision
test-scripts/persistence-harness.js — the file adapter (lib/persistence.js), tested against real temp directories on disk rather than fakes, because filesystem behavior (atomic renames, ENOENT, directory creation) is exactly what this module abstracts.
| Group | Why it exists |
|---|---|
| P1 — round-trip | State written is state read back, through real files, with the storage directory created on demand and overwrites landing cleanly. |
| P2 — missing vs corrupt | A missing file returns null (normal: no recording yet); a corrupt file throws — and the same test then feeds that corrupt file through a real RecorderStore to prove the seam: the core catches, warns, and starts fresh. Contracts are tested where modules meet, not just inside each. |
| P3 — sanitization | Hostile store ids (../../etc/passwd, hidden-file prefixes, oversized strings) cannot escape the storage directory or produce unsafe filenames — including an actual hostile write proven to stay inside the directory. |
| P4 — remove | Deletion works and is idempotent — removing an already-removed recording is not an error (redeploy races shouldn't throw). |
| P5 — atomicity hygiene | Twenty rapid writes leave zero temp files behind and the final content correct — the temp-file-and-rename strategy cleans up after itself. |
| P6 — end-to-end restart | The flagship story as one test: a real store persisting through the real adapter, closed, "restarted", records back with restored: true, marks intact, seq continuing, the downtime visible as a delta gap — and node deletion removing the file. |
Flight Recorder
Node Reference
Reference
Guides
Testing