Practical overview
When it fits
Use it when an Anchor testing workflow needs coverage output, provided you can use the required patched validator and enable release debug information in the project.
Who it is for
- Developers testing Solana programs with Anchor.
- Teams that want LCOV files or an HTML view of coverage from Anchor test runs.
Documented uses
- Run Anchor tests while collecting coverage for executable runs.
- Create LCOV files and render them into an HTML coverage report.
- Inspect which source locations are associated with executed SBF instructions.
Requirements & limits
The project is documented as an open-source command-line tool under the AGPL-3.0 license.
- A patched solana-test-validator is required; the documentation says the patch is known to work with Agave v3.0.8.
- The Anchor project's release profile must set
debug = truefor source mapping; the README points to this setting when reports show zero line hits. - Coverage is mapped using DWARF debug information rather than LLVM instrumentation, which can produce non-intuitive per-line hit counts.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Generate LCOV and an HTML coverage report
Run Anchor tests through Anchor Coverage and render the resulting coverage files as an HTML report.
Before you start
- An Anchor project with its root Cargo.toml accessible.
- A patched solana-test-validator downloaded and unpacked from the sbpf-coverage releases; the documentation identifies the patch as known to work with Agave v3.0.8.
- genhtml available for rendering LCOV files.
Steps
Add
debug = trueunder[profile.release]in the Anchor project's root Cargo.toml.Run
anchor-coverage [ANCHOR_TEST_ARGS]...with the desired Anchor test arguments.Use
genhtml --output-directory coverage sbf_trace_dir/*.lcov && open coverage/index.htmlto create and open the report.
Expected outcome
Anchor Coverage creates an `sbf_trace_dir` directory containing one LCOV file per executable run; genhtml renders those files into an HTML report in `coverage`.
Guide limitations
- The tool requires a patched solana-test-validator.
- DWARF-based instruction mapping can produce line-hit counts that do not correspond intuitively to apparent source-line order.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 13 October 2026
- Original website title
- trailofbits/anchor-coverage · Official homepage title · retained in its source language

