Add cargo fuzz targets#6
Merged
shahan-khatchadourian-anchorage merged 4 commits intoMar 18, 2026
Merged
Conversation
…tions Three libFuzzer targets: - fuzz_idl_json: arbitrary bytes as IDL JSON into decode_idl_data - fuzz_instruction_data: arbitrary bytes as instruction data into parse_instruction_with_idl - fuzz_transaction: arbitrary bytes as encoded transaction into parse_transaction Run with: cargo +nightly fuzz run <target> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move proptest strategies from src/arb.rs into fuzz-core/src/proptest.rs and add arbitrary::Arbitrary implementation for IDL types in fuzz-core/src/arbitrary.rs (ArbIdl wrapper). This separates fuzz infrastructure from the core library into a dedicated crate that can be depended on by both libfuzzer targets and proptest consumers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace hardcoded IDL with ArbIdl-based dynamic generation, fixing the
wrong discriminator bug where the hardcoded value didn't match the
Anchor-computed SHA256("global:transfer") discriminator. The fuzz target
now generates random IDL shapes and exercises parse_instruction_with_idl
across varying instruction schemas.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move fuzz_idl_parsing.rs and its proptest regressions here where the IDL parsing code lives. Add embedded_idls_never_panic and embedded_idls_valid_data_always_parses_ok tests that replace the fuzz_all_idls.sh shell script with Rust test code iterating over all 13 embedded IDLs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b6a5e28
into
solana-parser-add-arbitrary
2 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three libFuzzer fuzz targets via
cargo fuzz:fuzz_idl_json— feeds arbitrary bytes as IDL JSON intodecode_idl_data; exercises the JSON deserializer and IDL struct validationfuzz_instruction_data— feeds arbitrary bytes as instruction data intoparse_instruction_with_idlagainst a fixed known-good IDL; exercises discriminator matching and borsh decodingfuzz_transaction— feeds arbitrary bytes as a base64-encoded transaction intoparse_transaction; exercises the full transaction deserialization and dispatch pathSits on top of #1 (proptest arb module).
Usage
Test plan
cargo +nightly fuzz build— all three targets compile clean