In this repo I will be fuzzing OpenZeppelin SafeMath library with woke.
Note: You can set up your you woke environment with my Template here or clone this repo
-
Setup your environment
python -m venv venv source ./venv/bin/activate pip install woke
-
Install openzepelin contracts you want to fuzz
pnpm install @openzeppelin/contracts # or npm install @openzeppelin/contracts
If you are cloning this project just run
npm install
orpnpm install
-
Import contracts and libraries in
./contracts/Imports.sol
-
Write your contracts in
./contracts/Math.sol
-
Generate pytypes
woke init pytypes -w
-
Let's fuzz the signed math average function in
./tests/test_signed_math.py
function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); }
-
Run woke fuzzer
woke fuzz tests/test_signed_math.py -n 8