Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 2.91 KB

File metadata and controls

42 lines (30 loc) · 2.91 KB

Testing Features

This repo is equipped with advanced testing features. See below for more info.

Some features are apart of gitmodules which may need to be initialized. Run yarn init:submodules if you run into issues.

Unit Testing

  1. hardhat testing
    1. yarn test
    2. See template.spec.ts for a template of how to write tests.
  2. forge testing
  3. VS-Code Mocha Test Explorer: Use Mocha Test Explorer to easily choose which tests to run. (Smart Contracts must be manually compiled between updates.)
  4. Debug Solidity unit tests with VS-Code debugger
  5. solidity-coverage: Generate a coverage report by running yarn test:coverage
  6. hardhat-gas-reporter: Check the gas costs of running test transactions with yarn test:gas
    • these tests run slower than yarn test
  7. hardhat-contract-sizer: Check the size of the contracts being developed with yarn size

Security Testing

  1. semgrep smart contract which uses semgrep rules that look for patterns of vulnerabilities in smart contracts based on actual DeFi exploits as well as gas optimization rules that can be used as a part of the CI pipeline.
    • Run yarn semgrep to run the semgrep rules locally.
    • There is also a semgrep GitHub Action that runs on pull requests.

Fork Testing

This repo has support for forking networks and running tests against the forked network. Update hardhat-fork.config.ts with the network you want to fork and run yarn test:fork to run tests against the forked network with the tests in test-fork.

Tenderly TX Simulations

TX Simulations are a form of fork testing and are valuable to test against mainnet forked networks. This repo has support for sending TX data to the simulator API for debugging and simulation.

  • Tenderly Simulation API: This repo has support for sending TX data to the simulator API for debugging and simulation.