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

Function fuzz_truncated_buffers

nodedb-query/src/msgpack_scan/index.rs:210–225  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

208 /// never panic; it should return None on truncated input.
209 #[test]
210 fn fuzz_truncated_buffers() {
211 let docs = [
212 json!({"name": "alice", "age": 30, "score": 9.5}),
213 json!({"a": 1, "b": 2, "c": 3, "d": 4, "e": 5}),
214 json!({"nested": {"inner": 42}}),
215 ];
216
217 for doc in &docs {
218 let full = encode(doc);
219 for truncate_at in 0..full.len() {
220 let slice = &full[..truncate_at];
221 // Must not panic — None is the valid outcome for truncated data.
222 let _ = FieldIndex::build(slice, 0);
223 }
224 }
225 }
226
227 /// Deterministic random byte sequences — FieldIndex::build must never panic.
228 #[test]

Callers

nothing calls this directly

Calls 2

encodeFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected