@@ -53,14 +53,41 @@ Every codec (varint, frame) needs three test classes:
5353| Malformed rejection | Known-bad byte sequences must return an error, not panic |
5454| Boundary conditions | Max varint value, empty payload, max frame length |
5555
56- ## Fuzzing (future)
56+ ## Fuzzing
57+
58+ Fuzz targets live in ` crates/istok-core/fuzz/fuzz_targets/ ` and are built with
59+ ` cargo fuzz ` (nightly required). Currently covering:
60+ - ` fuzz_varint_decode ` — ` varint::decode `
61+ - ` fuzz_frame_decode ` — ` h3_frame::decode_frame_header `
62+
63+ To run locally (` +nightly ` is required — cargo-fuzz uses ` -Z ` flags):
64+ ``` sh
65+ cd crates/istok-core
66+ cargo +nightly fuzz run fuzz_varint_decode
67+ cargo +nightly fuzz run fuzz_frame_decode
68+ ```
69+
70+ Runs indefinitely until ` Ctrl+C ` . Corpus is saved in ` fuzz/corpus/ ` and seeds future runs.
71+
72+ For a time-bounded run (CI-style):
73+ ``` sh
74+ ASAN_OPTIONS=" detect_odr_violation=0:quarantine_size_mb=1:malloc_context_size=0" \
75+ cargo +nightly fuzz run fuzz_varint_decode -- -max_total_time=30 -max_len=8 -rss_limit_mb=256
76+ ```
5777
58- Fuzz targets will live in ` fuzz/ ` and cover:
59- - Frame decoding (` Frame::parse ` )
60- - QPACK decoding (once M2 is active)
78+ Use ` max_len=8 ` for varint (QUIC varint max is 8 bytes) and ` max_len=16 ` for frame
79+ decode (type varint + length varint = up to 16 bytes).
6180
6281Rule: crashes are bugs. The engine must never panic on arbitrary input.
6382
83+ ### Adding a new fuzz target
84+
85+ 1 . Add a ` fuzz_targets/<name>.rs ` file (see existing targets for the one-liner pattern).
86+ 2 . Add a ` [[bin]] ` entry to ` crates/istok-core/fuzz/Cargo.toml ` .
87+ 3 . ** The fuzz ` Cargo.toml ` must have ` [workspace] ` at the top** — without it, Cargo
88+ treats the fuzz crate as part of the parent workspace and ` cargo fuzz ` fails.
89+ This is already present; do not remove it when editing the file.
90+
6491## Anti-patterns
6592
6693- Real ` tokio::time::sleep ` or ` tokio::net ` in unit tests — use the mock harness.
0 commit comments