This Foundry template allows you to bootstrap an invariant fuzz testing suite using a scaffolding provided by the Recon tool.
It extends the default Foundry template used when running forge init
to include example property tests supported by Echidna and Medusa.
To use this template you'll need to have Foundry installed and at least one fuzzer (Echidna or Medusa):
To initialize a new Foundry repo using this template run the following command in the terminal.
forge init --template https://github.com/Recon-Fuzz/create-chimera-app
This template is configured to use Foundry as it's build system for Echidna and Medusa so after making any changes the project must successfully compile using the following command before running either fuzzer:
forge build
This template comes with property tests defined for the Counter
contract in the Properties
contract and in the function handlers in the TargetFunctions
contract.
To locally test properties using Echidna, run the following command in your terminal:
echidna . --contract CryticTester --config echidna.yaml
To locally test properties using Medusa, run the following command in your terminal:
medusa fuzz
Broken properties found when running Echidna and/or Medusa can be turned into unit tests for easier debugging with Recon (for Echidna/for Medusa) and added to the CryticToFoundry
contract.
forge test --match-contract CryticToFoundry -vv
The template works out of the box with Halmos, however Halmos Invariant Testing is currently in preview
Simply run halmos
on the root of this repository to run Halmos for Invariant Testing
After you've added new contracts in the src
directory, they can then be deployed in the Setup
contract.
The ABIs of these contracts can be taken from the out
directory and added to Recon's Sandbox. The target functions that the sandbox generates can then be added to the existing TargetFunctions
contract.
You can offload your fuzzing job to Recon to run long duration jobs and share test results with collaborators using the jobs page:
-
Select Medusa as the job type using the radio buttons at the top of the page
-
Add a name for the job (optional)
-
Add the link for this repo in the Enter GitHub Repo URL form field (this will prefill the remaining form fields)
- To override the timeout value in the Medusa config file for longer duration runs enter a value (in seconds) into the "Test Time Limit" field (optional)
-
Select Echidna as the job type using the radio buttons at the top of the page
-
Add a name for the job (optional)
-
Add the link for this repo in the Enter GitHub Repo URL form field (this will prefill the remaining form fields)
- To override the
testLimit
from theechidna.yaml
config file change the value in the corresponding form field (optional)
-
Clicking Run Job will add your job to the queue and it will show up below the form
-
Clicking View Details button for a job lets you see the fuzzer logs and coverage report (only generated after the run is complete). You can share a fuzz run with any collaborators using the Share Job Results button.
This template implements the EnumerableSet
contract from OpenZeppelin and the ERC20
contract from Solmate to reduce the number of dependencies and make it simpler to get started.
Join the Recon Discord: https://getrecon.xyz/discord