Skip to content

Code Coverage#

Trident's code coverage feature analyzes which parts of your Solana program are tested during fuzzing sessions, helping you identify untested code paths and improve test effectiveness.

Key features:

  • Real-time Analysis: Monitor coverage as fuzzing progresses
  • Multiple Formats: Generate reports in JSON and HTML formats
  • VS Code Integration: Visualize coverage directly in your IDE using Solana VS Code extension
  • Detailed Reporting: Get insights into line coverage, branch coverage, and execution paths

Gathering Coverage Data#

  1. Enable coverage in the Trident manifest
  2. Deploy your program through the entrypoint
  3. Run the fuzz test

Viewing Coverage Reports#

You have two options for displaying coverage data: generate an HTML report for browser viewing, or generate a JSON report for VS Code integration.

HTML Report#

  1. Set format = "html" in the Trident manifest before running the fuzz test
  2. Run the fuzz test
  3. After the fuzz test finishes, the HTML report will be stored in the <fuzz-test-name>-coverage-report folder
  4. Open the HTML report in your browser

VS Code Extension#

  1. Set format = "json" in the Trident manifest before running the fuzz test
  2. Run the fuzz test
  3. Install the Solana VS Code extension
  4. Run the VS Code command Solana: Show Code Coverage and select the "Load generated JSON report" option

Live Coverage Updates#

For real-time coverage monitoring during fuzzing:

  1. Set format = "json" in the Trident manifest
  2. Set loopcount to a value other than 0 e.g., 5 for frequent updates, for more info check out Trident manifest
  3. Install the Solana VS Code extension
  4. Choose one of these options:
    • Automatic: Set attach_extension = true in the Trident manifest to automatically show live updates while the fuzz test is running
    • Manual: Use the command Solana: Show Code Coverage and select the "Attach to active fuzzing session" option