test: pin sourceCount(hex"00") == 0 explicitly#118
Conversation
The NatSpec on LibBytecode.sourceCount documents 0x and 0x00 as equivalent, both having 0 sources. testSourceCount0 pins the empty case; this adds the named single-zero-byte pin so the documented equivalence has a dedicated, deterministic assertion rather than only incidental fuzz coverage. Closes #115 Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #115
Summary
LibBytecode.sourceCount's NatSpec documents that0xand0x00are equivalent, both having 0 sources. The empty case is pinned bytestSourceCount0, but the single-bytehex"00"case was only covered incidentally by fuzzing (testSourceCount1/testSourceCountReferenceinclude it in their input domain without naming it). This adds the dedicated, deterministic pin the issue asks for:Test-only change; no source or bytecode is touched.
QA
forge test --mc LibBytecodeSourceCountTestgreen on unmutated main-based branch — 4 passed / 0 failed (2048 fuzz runs each for the two fuzz tests).count := byte(0, mload(add(bytecode, 0x20)))→add(1, byte(...))fails the new test withassertion failed: 1 != 0; restoring the source returns the suite to 4/4 green.return 0→return 1killed by existingtestSourceCount0+testSourceCountReference(existing coverage validated).add(1, byte(0, …))killed by the newtestSourceCountSingleZeroByteandtestSourceCount1.byte(0, …)→byte(1, …)killed by existingtestSourceCount1+testSourceCountReference.0x≡0x00; integrity of sources explicitly NOT checked). Implementation matches on all points; thebyte(0, …)read extracts only the first data byte, which exists for any length ≥ 1, and the differential fuzz againstLibBytecodeSlow.sourceCountSlowguards the read shape. No candidate bugs; no scope beyond the named gap.Closes.forge fmt --checkclean on the changed file.Co-Authored-By: Claude noreply@anthropic.com