asset slice + testing initiative: fixed assets, property/mutation/fuzz testing, docs

This commit is contained in:
swaits committed 2026-10-11 02:25:59 +00:00
1 parent 2a72f37a9d
commit d703874f87
1 file changed
+24
+24
View File
@@ -0,0 +1,24 @@
// Fuzz target: journal line parsing must never panic, and the canonical
// form must be a fixed point: parse(canonical(x)) re-serializes to the
// same canonical bytes. Staged here; `cargo fuzz init` wires it up.
#![no_main]
use libfuzzer_sys::fuzz_target;
use ledger_store::JournalLine;
fuzz_target!(|data: &[u8]| {
// Garbage must return Err, never panic.
if let Ok(line) = serde_json::from_slice::<JournalLine>(data) {
let canon = line.to_canonical();
let line2: JournalLine =
serde_json::from_str(&canon).expect("canonical form must re-parse");
assert_eq!(
line2.to_canonical(),
canon,
"canonical form is not a fixed point"
);
// Sequence numbers survive the round trip.
assert_eq!(line.seq, line2.seq);
assert_eq!(line.line_type, line2.line_type);
}
});