This document explains how to measure and analyze code coverage for the Sentium Bridge adapters.
- Rust toolchain (stable)
- cargo-tarpaulin (installed automatically by scripts)
Run the coverage measurement script:
./scripts/measure_coverage.shThis will:
- Install cargo-tarpaulin if needed
- Run all tests with coverage tracking
- Generate HTML and XML reports
- Check if coverage meets the 80% threshold
For detailed per-adapter analysis:
./scripts/analyze_coverage.shThis provides:
- Coverage percentage for each adapter
- Component-level coverage breakdown
- Overall coverage status
- Recommendations for improvement
After running the measurement script, reports are available at:
- HTML Report:
target/coverage/index.html(open in browser) - XML Report:
target/coverage/cobertura.xml(for CI/CD) - LCOV Report:
target/coverage/lcov.info(for IDE integration)
- Minimum: 80% line coverage
- Goal: 90%+ line coverage
Each adapter should maintain:
- Critical adapters (Ethereum, Bitcoin, Polkadot, Cosmos): ≥85%
- Standard adapters: ≥80%
- Experimental adapters: ≥70%
- Line Coverage: Percentage of code lines executed during tests
- Branch Coverage: Percentage of conditional branches tested
- Function Coverage: Percentage of functions called
- Test files (
tests/*) - Benchmark files (
benches/*) - Example files (
examples/*) - Generated code
Open the HTML report and look for:
- Red lines (not executed)
- Yellow lines (partially executed)
- Uncovered branches
Focus on:
- Error handling paths
- Edge cases
- Conditional logic
- Integration points
Test a specific adapter:
cargo test --test adapter_unit_tests cosmos_testsTest with coverage:
cargo tarpaulin --test adapter_unit_tests- name: Run Coverage
run: ./scripts/measure_coverage.sh
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
files: target/coverage/cobertura.xmlcoverage:
script:
- ./scripts/measure_coverage.sh
coverage: '/Overall Coverage: (\d+\.\d+)%/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: target/coverage/cobertura.xmlInstall manually:
cargo install cargo-tarpaulinIncrease timeout in tarpaulin.toml:
[run]
timeout = 600 # 10 minutes-
Check which files are uncovered:
./scripts/analyze_coverage.sh
-
Add unit tests for uncovered adapters
-
Add integration tests for end-to-end flows
-
Test error cases and edge conditions
- Write tests first: Follow TDD for new features
- Test error paths: Don't just test happy paths
- Use property-based testing: For complex logic
- Mock external dependencies: For unit tests
- Use real networks: For integration tests (with
#[ignore])
- Overall: ≥80%
- Critical adapters: ≥85%
- Overall: ≥85%
- All adapters: ≥80%
- Overall: ≥90%
- All adapters: ≥85%
- Branch coverage: ≥80%