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

Function fuzz_truncated_buffers

nodedb-query/src/msgpack_scan/field.rs:183–201  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181 /// extract_path must never panic, returning None on truncated input.
182 #[test]
183 fn fuzz_truncated_buffers() {
184 let docs = [
185 json!({"name": "alice", "age": 30, "active": true}),
186 json!({"address": {"city": "tokyo", "zip": "100-0001"}}),
187 json!({"scores": [10, 20, 30], "ratio": 0.95}),
188 ];
189
190 for doc in &docs {
191 let full = encode(doc);
192 for truncate_at in 0..full.len() {
193 let slice = &full[..truncate_at];
194 let _ = extract_field(slice, 0, "name");
195 let _ = extract_field(slice, 0, "age");
196 let _ = extract_field(slice, 0, "missing");
197 let _ = extract_path(slice, 0, &["address", "city"]);
198 let _ = extract_dot_path(slice, 0, "address.city");
199 }
200 }
201 }
202
203 /// Deterministic random byte sequences — extract_field must never panic.
204 #[test]

Callers

nothing calls this directly

Calls 5

extract_fieldFunction · 0.85
extract_pathFunction · 0.85
extract_dot_pathFunction · 0.85
encodeFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected