Skip to content

Latest commit

 

History

History
115 lines (82 loc) · 5.74 KB

README.md

File metadata and controls

115 lines (82 loc) · 5.74 KB

Create Chimera App

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.

Prerequisites

To use this template you'll need to have Foundry installed and at least one fuzzer (Echidna or Medusa):

Usage

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

Build

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

Property Testing

This template comes with property tests defined for the Counter contract in the Properties contract and in the function handlers in the TargetFunctions contract.

Echidna Property Testing

To locally test properties using Echidna, run the following command in your terminal:

echidna . --contract CryticTester --config echidna.yaml

Medusa Property Testing

To locally test properties using Medusa, run the following command in your terminal:

medusa fuzz

Foundry Testing

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

Halmos Invariant Testing

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

Expanding Target Functions

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.

Uploading Fuzz Job To Recon

You can offload your fuzzing job to Recon to run long duration jobs and share test results with collaborators using the jobs page:

Medusa

  1. Select Medusa as the job type using the radio buttons at the top of the page

  2. Add a name for the job (optional)

  3. Add the link for this repo in the Enter GitHub Repo URL form field (this will prefill the remaining form fields)

image
  1. 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)
image

Echidna

  1. Select Echidna as the job type using the radio buttons at the top of the page

  2. Add a name for the job (optional)

  3. Add the link for this repo in the Enter GitHub Repo URL form field (this will prefill the remaining form fields)

image
  1. To override the testLimit from the echidna.yaml config file change the value in the corresponding form field (optional)
image

Both

  1. Clicking Run Job will add your job to the queue and it will show up below the form

  2. 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.

Credits

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.

Help

Join the Recon Discord: https://getrecon.xyz/discord