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

Function fuzz_random_payloads

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

Source from the content-addressed store, hash-verified

203 /// Deterministic random byte sequences — extract_field must never panic.
204 #[test]
205 fn fuzz_random_payloads() {
206 let mut state: u64 = 0xfeedface_0badf00d;
207 let next = |s: &mut u64| -> u8 {
208 *s = s
209 .wrapping_mul(6364136223846793005)
210 .wrapping_add(1442695040888963407);
211 (*s >> 33) as u8
212 };
213
214 let mut buf = [0u8; 128];
215 for _ in 0..1000 {
216 let len = (next(&mut state) as usize % 128) + 1;
217 for b in buf[..len].iter_mut() {
218 *b = next(&mut state);
219 }
220 let slice = &buf[..len];
221 let _ = extract_field(slice, 0, "key");
222 let _ = extract_path(slice, 0, &["a", "b", "c"]);
223 let _ = extract_dot_path(slice, 0, "x.y.z");
224 }
225 }
226
227 /// Adversarial: map header claims huge element count but buffer is tiny.
228 #[test]

Callers

nothing calls this directly

Calls 4

extract_fieldFunction · 0.85
extract_pathFunction · 0.85
extract_dot_pathFunction · 0.85
iter_mutMethod · 0.80

Tested by

no test coverage detected