OpenViSTAI · Agents · Blockchain · Crypto
Menu
Developer Tools

Anchor Coverage

Anchor Coverage is a Rust command-line wrapper around `anchor test` that collects test coverage for Anchor-based Solana programs. It runs tests with a patched `solana-test-validator`, uses DWARF debug information to map SBF instructions to source locations, and writes LCOV files that can be rendered as an HTML report.

Independent OpenViST project profile, based on linked sources.

Anchor Coverage — OpenViST project profile in Developer Tools.
OpenViST project illustration. See the linked sources for product details.
Understand the project

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.
Before you choose

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 = true for 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.

Source-based practical guide

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

  1. Add debug = true under [profile.release] in the Anchor project's root Cargo.toml.

  2. Run anchor-coverage [ANCHOR_TEST_ARGS]... with the desired Anchor test arguments.

  3. Use genhtml --output-directory coverage sbf_trace_dir/*.lcov && open coverage/index.html to 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.
Evidence and transparency

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