test(surfpool): native cargo runner via build.rs + per-IDL macro#285
Draft
shahan-khatchadourian-anchorage wants to merge 2 commits intoshahankhatch/surfpool_testingfrom
Draft
Conversation
Replaces the bash runner (`scripts/surfpool_fuzz_all_idls.sh`) with a fully native Rust setup: - `build.rs` runs `cargo metadata` once, locates `solana_parser`'s IDL directory (matching the rev in `Cargo.lock`), and emits it as `cargo:rustc-env=SOLANA_IDL_DIR`. Tests pick it up via `env!()` with no runtime cargo invocation. - A `macro_rules!` macro generates one `#[tokio::test]` per IDL (`surfpool_idl_<name>`). Cargo's harness handles enumeration, parallelism, pass/fail counts, and per-test failure output -- the things the bash script was reimplementing by hand. - `collision.json` and `cyclic.json` are excluded: they're solana_parser's own negative test fixtures (duplicate type names / cyclic type refs) and are intentionally rejected by `decode_idl_data`. - The surfpool test now distinguishes the three failure modes (decode rejected, no instructions, missing discriminator) with messages that name the IDL file -- previously a malformed IDL produced a misleading "no discriminator" panic. CI now invokes `cargo test ... --test surfpool_fuzz -- --ignored --test-threads=1` directly. The 14 tests run serially in ~9s end-to-end on the local Helius pin. Documents the pattern in `CLAUDE.md`'s Testing Patterns section. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…e IDL lookup
`solana_parser` already exposes each IDL as a `pub const &str` via
`solana::embedded_idls::*` (compiled in via `include_str!`). Use those
consts directly in the per-IDL macro instead of resolving a filesystem
path at build time.
Net deletions:
- `build.rs::emit_solana_idl_dir()` (the `cargo metadata` invocation)
- `[build-dependencies] serde_json` from `visualsign-solana/Cargo.toml`
- `env!("SOLANA_IDL_DIR")` and the `std::fs::read_to_string` per test
Resolves the duplicated locate-IDL-dir logic the code review flagged
between `tools/idl-meta::locate_idl_dir` and `build.rs::emit_solana_idl_dir`.
14 tests pass locally in ~9s (`HELIUS_API_KEY=<key> cargo test ... --
--ignored --test-threads=1`).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a646dce to
c89ad3e
Compare
This was referenced May 8, 2026
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
Stacked on #202. Replaces the bash runner (
scripts/surfpool_fuzz_all_idls.sh) with a native Rust setup socargo testitself enumerates the per-IDL roundtrip tests.chain_parsers/visualsign-solana/build.rsrunscargo metadataat build time, locatessolana_parser's IDL directory (the one matching the rev inCargo.lock), and emits it ascargo:rustc-env=SOLANA_IDL_DIR. Tests pick it up viaenv!()— no runtime cargo invocation.macro_rules!macro intests/surfpool_fuzz.rsgenerates one#[tokio::test]per IDL (surfpool_idl_<name>). Cargo's harness handles enumeration, parallelism, pass/fail counts, and per-test failure diagnostics — the things the bash script was reimplementing.collision.jsonandcyclic.jsonare excluded: they're solana_parser's negative test fixtures (duplicate type names / cyclic type refs) intentionally rejected bydecode_idl_data.CI change
The workflow drops the bash invocation and runs:
--test-threads=1serialises surfpool spawns so each test owns its mainnet fork.Documentation
Adds a Testing Patterns bullet in
CLAUDE.mdcovering the macro-based pattern and how to add a new IDL.Test plan
HELIUS_API_KEY=<key> cargo test -p visualsign-solana --test surfpool_fuzz -- --ignored --test-threads=1— 14 passed in ~9s.surfpoollabel on this PR (after test: surfpool mainnet-fork integration for built-in IDL fuzz path #202 merges) to exercise CI.Why this PR
Addresses the third-party reviewer comment from #202 ("you might be able to do all this in Rust itself"). The narrow interpretation was already done there via the
idl-metaRust tool; this PR closes the loop by removing the bash orchestrator entirely.🤖 Generated with Claude Code