MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / fuzz_truncated_valid_payloads

Function fuzz_truncated_valid_payloads

nodedb-query/src/msgpack_scan/reader.rs:811–836  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

809 /// All reader functions must return `None` — never panic.
810 #[test]
811 fn fuzz_truncated_valid_payloads() {
812 let docs = [
813 json!({"key": "value", "num": 42, "flag": true}),
814 json!({"nested": {"a": 1, "b": [1, 2, 3]}}),
815 json!([1, "two", 3.0, null, false]),
816 json!({"large": 9999999999_i64}),
817 json!({"float": 1.23456789}),
818 ];
819
820 for doc in &docs {
821 let full = encode(doc);
822 // Truncate at every position from 0 to full.len()-1
823 for truncate_at in 0..full.len() {
824 let slice = &full[..truncate_at];
825 // None of these may panic; result doesn't matter
826 let _ = skip_value(slice, 0);
827 let _ = read_f64(slice, 0);
828 let _ = read_i64(slice, 0);
829 let _ = read_str(slice, 0);
830 let _ = read_bool(slice, 0);
831 let _ = map_header(slice, 0);
832 let _ = array_header(slice, 0);
833 let _ = read_value(slice, 0);
834 }
835 }
836 }
837
838 /// The never-used 0xc1 tag must return `None` for all functions.
839 #[test]

Callers

nothing calls this directly

Calls 10

skip_valueFunction · 0.85
read_i64Function · 0.85
read_boolFunction · 0.85
map_headerFunction · 0.85
array_headerFunction · 0.85
encodeFunction · 0.70
read_f64Function · 0.70
read_strFunction · 0.70
read_valueFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected