Introducing Create-Chimera-App
A testing framework to get you running invariant tests with one command
Inspired by Create React App, Recon has created a template that allows you to bootstrap an invariant testing project with the most popular invariant testing tools using a single command:
forge init --template https://github.com/Recon-Fuzz/create-chimera-app

What is it?
Create-chimera-app is fundamentally a combination of three things: the Chimera framework, the default template that ships with Foundry, and a Recon scaffolding built around this template.
Chimera lets you use a single interface for invariant testing with Foundry + Echidna + Medusa so you don’t have to rewrite tests or their setup in a semi-opinionated manner. The Recon scaffolding then implements this framework into a test harness for easily defining tests and their helpers. All this gets added to the default Foundry template where you can modify the existing source and test files or start completely from scratch.
Invariant testing in minutes
Like how Create React App allows you to create a default React app which serves as the base for a web-app without any configuration overhead, Chimera was designed to facilitate bootstrapping a Foundry project with invariant testing preconfigured so you can develop your invariant tests alongside your smart contract system.
Without using create-chimera-app you’d typically create a new project by running forge init
which creates a project structured around a Counter
contract, a simple unit + stateless fuzzing test suite, and provides the required utilities to make everything work.
Foundry’s native invariant fuzzer is useful but not as feature rich as some others like Echidna or Medusa. After initializing a Foundry project with the above method, if you then decide that you need the added benefits you get from these fuzzers it can introduce added complexity to your project structure and require decisions that if not made carefully when integrating can complicate the maintainability of your codebase over time.
The typical approach
As the interface for Echidna and Medusa differs from Foundry there are more considerations that must be take into account when adding them to your system.
Whether to use an internal or external testing setup:
If internal, inherit from your target contract in your entry-point contract
If external, instantiate your target contract and call it from your entry-point contract
Refactor Foundry’s
setUp
function to work with Echidna/Medusa setup using entry-point contract constructorCreate and setup your configuration files for Echidna and Medusa to target your entry-point contract correctly.
I could go on but hopefully you see by now why adding all your testing structure is certainly doable and within the abilities of a junior developer, but requires extra mental overhead and time in sorting out the structure of your test suite and how to get things to play nicely together.
A new approach
The time spent setting up a testing harness is time that we believe is better spent actually writing tests and proving invariants, which is why create-chimera-app lets you do all of the above with a single command.
With this single command you get:
A single interface for writing Echidna + Medusa + Foundry tests.
A single
setup
function that you write once and it just works.All HEVM compatible cheatcodes across your project by importing
vm
from Chimera into your contract.
The Recon scaffolding on top of this helps guide you in the layout of your invariant testing suite by providing separation of concerns which leads to a more maintainable and easier to understand codebase using the following file structure:
recon/
│
├── BeforeAfter
├── CryticTester
├── CryticToFoundry
├── Properties
├── Setup
└── TargetFunctions
This allows separating your invariant/property tests by locating them in the TargetFunctions
(assertion property tests) or Properties
(boolean property tests) and all required utility or setup to be done in the other contracts which get inherited from to provide a single entry-point for Echidna and Medusa via CryticTester
and the Foundry fuzzer via CryticToFoundry
.
In addition to all this, you get the ability to easily find compilation errors using the Foundry build process via forge build
which provides better syntax highlighting than the Crytic-Compile build process standard to Echidna and Medusa. Similarly, finding the cause of properties that have been broken by one of the fuzzers is simplified by turning output logs into a Foundry unit test that can be run in CryticToFoundry
which offers better debugging features like console logging.
If you have questions or difficulties with using create-chimera-app or Recon feel free to reach out on our discord.
If you've made it this far you value the security of your protocol.
At Recon we offer boutique audits powered by invariant testing. With this you get the best of both worlds, a security audit done by an elite researcher paired with a cutting edge invariant testing suite.
Sound interesting? Reach out to us here: