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.
- hardhat testing
yarn test- See template.spec.ts for a template of how to write tests.
- forge testing
- See README-foundry.md for more info.
yarn forge:test- See Lock.t.sol for an example of how to write tests with Foundry.
- VS-Code Mocha Test Explorer: Use Mocha Test Explorer to easily choose which tests to run. (Smart Contracts must be manually compiled between updates.)
- Debug Solidity unit tests with VS-Code debugger
- solidity-coverage: Generate a coverage report by running
yarn test:coverage - hardhat-gas-reporter: Check the gas costs of running test transactions with
yarn test:gas- these tests run slower than
yarn test
- these tests run slower than
- hardhat-contract-sizer: Check the size of the contracts being developed with
yarn size
- 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 semgrepto run the semgrep rules locally. - There is also a semgrep GitHub Action that runs on pull requests.
- Run
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.
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.
- See tenderly.ts for more info.
- See simulateTxs script for an example of how to send TX data to the simulator API.
- Tenderly Simulation API: This repo has support for sending TX data to the simulator API for debugging and simulation.