/echidna-spearbit-demo

Example code for testing using Echidna explained during the Spearbit presentation

Primary LanguageSolidityGNU General Public License v3.0GPL-3.0

Fuzz tests explained during the Spearbit presentation

Before starting

Install Echidna 2.0.2:

If you do not have experience with Echidna, please start reviewing the Echidna README, as well as the official tutorials.

The demo

This repository contains everything necessary to test simple properties of SomeDeFi, a syntetic minimalistic DeFi protocol. Users should complete the TestSomeDefi contract creating functions to test different invariants from function (e.g. mintShares, withdrawShares, etc) using assertions.

A few pointers to start:

  1. Read the implementation code of SomeDeFi (it is very small).
  2. Think of basic properties for every operation
  3. Consider when an operation should or it should not revert
  4. Optimize the resulting properties, perhaps merging some of them.

To start a Echidna fuzzing campaign use:

$ echidna-test --test-mode assertion --contract TestSomeDefi --config SomeDeFi.yaml SomeDeFi.sol

The recommended Solidity version for the fuzzing campaign is 0.8.1, however, more recent releases can be used as well.