Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 2.97 KB

README-testing.md

File metadata and controls

44 lines (31 loc) · 2.97 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 a helper function included to be able to fork any network when deploying on hardhat. Use the setupFork function to fork a network and the resetFork function to reset the fork.

This can be used inside of tests or scripts to fork a network and test against it.

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.