Trust Developers
  • Get Started
  • Developing for Trust Wallet platform
    • Browser Extension
      • Ethereum & EVM chains
    • Mobile (WalletConnect)
    • Deep Linking
  • Listing new dApps
    • A Complete Guide to Listing your dApp with Trust Wallet
    • Optimizing your dApp for Trust Wallet
    • Debugging
  • Listing new assets
    • Add Asset
    • Requirements
    • Pull Request Fee
    • FAQ
    • Repository Details
    • Universal Asset ID
  • Wallet Core
    • New Blockchain Support
      • RPC / API Requirements
      • New EVM-compatible chain
    • Developing the Library
      • Contributing
      • Building
      • WalletConsole utility
      • Coverage
      • Releasing
    • Integration Guide
      • Usage Guide
      • iOS Integration Guide
      • Android Integration Guide
      • Server-Side
    • References
      • Swift API Reference
      • Kotlin API Reference
    • FAQ
  • Barz - Smart Wallet
    • Introducing Barz. TrustWallet's Smart Wallet Solution
    • Cutting Diamonds: How to make Accounts Awesome
    • Build with Trust Wallet and Barz, A Comprehensive Guide to Integrating Barz with AA SDK
Powered by GitBook
On this page
  • Coverage Measurement
  • Checking Coverage Summary in CI build
  • Detailed Coverage Report
  • Detailed Rust Coverage Report

Was this helpful?

  1. Wallet Core
  2. Developing the Library

Coverage

Coverage Measurement

Wallet-core is a stable project, we value stability and safety over new features.

Test coverage is one important facet of assuring code quality, and we are strict about high test coverage.

Checking Coverage Summary in CI build

The Linux CI and Linux CI Rust CI builds (executed on PRs and commits) contain coverage measurement, and summary is available in the build output:

Summary coverage rate:
  lines......: 94.5% (14576 of 15426 lines)
  functions..: 95.0% (2688 of 2830 functions)

Detailed Coverage Report

Detailed coverage report can be generated locally. It includes file and line-level info on coverage.

Steps:

  • Run tools/generate-file to make sure new added files are generated

  • Run cmake with -DCODE_COVERAGE=ON to enable coverage measurement

cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCODE_COVERAGE=ON
  • Build tests

make -Cbuild -j12 tests TrezorCryptoTests
  • Cleanup any old coverage files, and run unit tests

find . -name "*.gcda" -exec rm {} \;
./build/trezor-crypto/crypto/tests/TrezorCryptoTests
./build/tests/tests tests --gtest_output=xml
  • Generate coverage info (slow). With the html argument the script will generate HTML report as well:

./tools/coverage html

if you see genhtml (from lcov) error on macOS like below:

c++filt: Unknown command line argument '--no-strip-underscores'.  Try: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++filt --help'
c++filt: Did you mean '--no-strip-underscore'?
genhtml: ERROR: c++filt output not as expected (0 vs 11) lines

please upgrade lcov to min. 1.16, or patch genhtml (for example /usr/local/Cellar/lcov/1.15/libexec/bin/), change --no-strip-underscores to --no-strip-underscore

Open the generated coverage/index.html to view the report.

Detailed Rust Coverage Report

Detailed Rust coverage report can be generated locally. It includes file and line-level info on coverage.

Steps:

  • Switch to the nightly toolchain and install dev dependencies

tools/install-rust-dependencies dev
  • Run Rust tests and generate coverage info (slow). With the html argument the script will generate HTML report as well:

./tools/rust-coverage html
PreviousWalletConsole utilityNextReleasing

Last updated 2 years ago

Was this helpful?

See also and

tools/coverage
linux-ci.yml