Skip to content

Commit b116abd

Browse files
committed
2 parents aa8d975 + bd0a26a commit b116abd

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Setup Helpers
2+
These contracts were created with the intention of speeding up the setup process for an invariant testing suite.
3+
4+
For an example implementation of these contracts in use see the [create-chimera-app](https://github.com/Recon-Fuzz/create-chimera-app-2) repo.
5+
6+
## [ActorManager](https://github.com/Recon-Fuzz/setup-helpers/blob/main/src/ActorManager.sol)
7+
The `ActorManager` contract serves as the source of truth for actors that are being used in the fuzzing suite setup.
8+
9+
The primary functions of interest when setting up a suite are:
10+
- `_addActor` - allows adding a new address as an actor that can be tracked
11+
- `_switchActor` - this should be exposed in a target function that can be called by the fuzzer to randomly switch between actors
12+
13+
To use the actors stored in the ActorManager, add the `asActor` modifier on all of your target function handlers which pranks as the currently set actor.
14+
15+
For privileged functions you can use the `asAdmin` modifier which calls the target functions as the tester contract (`address(this)`). The tester contract is typically set as the default admin address by convention.
16+
17+
## [AssetManager](https://github.com/Recon-Fuzz/setup-helpers/blob/main/src/AssetManager.sol)
18+
19+
The `AssetManager` allows tracking all assets being used in the fuzz suite setup.
20+
Similar to the `ActorManager` this serves as the source of truth for all assets used in the test suite and therefore no target function should be called that may transfer an asset not tracked in the `AssetManager`.
21+
22+
The primary functions of interest when setting up a suite are:
23+
- `_newAsset` - deploys an instance of the `MockERC20 `contract and adds it to tracking so it can be accessed as needed
24+
- `_getAsset` - used to clamp values used for tokens in calls to target functions
25+
- `_finalizeAssetDeployment` - a utility for minting tokens added via `_newAsset` to all actors that have been setup and approving it to all contracts in the the system that may need to call `transferFrom` on it
26+
27+
## [Utils](https://github.com/Recon-Fuzz/setup-helpers/blob/main/src/Utils.sol)
28+
Provides utilities for invariant testing
29+
- `checkError` - allows checking if a revert reason from a function call is equivalent to the reason passed in as the `expected` argument
30+
31+
## [Panic](https://github.com/Recon-Fuzz/setup-helpers/blob/main/src/Panic.sol)
32+
A library that provides named variables corresponding to compiler panic messages. Used to more easily access these messages when using the `checkError` utility.
33+
34+
```solidity
35+
library Panic {
36+
// compiler panics
37+
string constant assertionPanic = "Panic(1)";
38+
string constant arithmeticPanic = "Panic(17)";
39+
string constant divisionPanic = "Panic(18)";
40+
string constant enumPanic = "Panic(33)";
41+
string constant arrayPanic = "Panic(34)";
42+
string constant emptyArrayPanic = "Panic(49)";
43+
string constant outOfBoundsPanic = "Panic(50)";
44+
string constant memoryPanic = "Panic(65)";
45+
string constant functionPanic = "Panic(81)";
46+
}
47+
```
48+
49+
## [MockERC20](https://github.com/Recon-Fuzz/setup-helpers/blob/main/src/MockERC20.sol)
50+
A minimal `MockERC20` contract that lets you mock any standard ERC20 tokens that will be interacting with the system without requiring external dependencies.

0 commit comments

Comments
 (0)