Skip to content

Code coverage example for a simple Anchor app#6

Open
procdump wants to merge 8 commits intotxtx:mainfrom
procdump:code_coverage_example
Open

Code coverage example for a simple Anchor app#6
procdump wants to merge 8 commits intotxtx:mainfrom
procdump:code_coverage_example

Conversation

@procdump
Copy link

@procdump procdump commented Feb 2, 2026

Summary

  • Adds a code coverage example demonstrating how to generate coverage reports for Anchor programs using Surfpool's register-tracing feature and sbpf-coverage
  • Based on LimeChain/simple_anchor_app
  • Updates main README and anchor README with the new example

Related

  • Requires txtx/surfpool#496 (Allow building surfpool with LiteSVM's register-tracing feature)

@procdump
Copy link
Author

procdump commented Mar 18, 2026

If everything looks good for solana-foundation/surfpool#573, solana-foundation/surfpool#574, solana-foundation/txtx#399 and they get merged the steps in this example can be narrowed down to:

# build as usual, actually the IDL is only needed
anchor build
# produce a program that has debug info
RUSTFLAGS="-Copt-level=0 -C strip=none -C debuginfo=2" cargo build-sbf --tools-version v1.53 --arch v1 --debug
# start surfpool
SBF_TRACE_DIR=$PWD/target/sbf_trace_dir surfpool start --artifacts-path ./target/deploy/debug --watch
# run the test
anchor test --skip-local-validator --skip-build --skip-deploy
# get code coverage
sbpf-coverage --src-path=$PWD/programs/simple_anchor_app/src \
		--sbf-path=$PWD/target/deploy/debug \
		--sbf-trace-dir=$PWD/target/sbf_trace_dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant