# Fuzzing Library
## Goals
Goals
- Standardized framework and set of helper functions
- Unified API for multiple tools
- Lightweight
- Solidity only
- Unopinionated
- All helpers functions should be strongly tested using both unit tests and fuzz tests
Tools to be supported
- Echidna
- Medusa
- Foundry
- Halmos
## Library
### Logging
Logging should be able using a single function.
```solidity
function log(string memory message) internal;
```
Ideally, the log function should support all possible argument types that make sense to be logged.
Logging happens by emitting events. The name of the event should reflect the variable type being logged.
```solidity
event Log(string message);
event LogString(string description, string data);
event LogUint(string description, uint256 data);
event LogInt(string description, int256 data);
event LogAddress(string description, address data);
event LogBool(string description, bool data);
```
### Asserts
There are many types of asserts. Some of which are:
```solidity
function assertEq(uint256 a, uint256 b) internal;
function assertNeq(uint256 a, uint256 b) internal;
function assertGte(uint256 a, uint256 b) internal;
function assertGt(uint256 a, uint256 b) internal;
function assertLte(uint256 a, uint256 b) internal;
function assertLt(uint256 a, uint256 b) internal;
```
All asserts should have two versions: one with and one without an extra "reason" argument. The "reason" argument will be used to log information in case an assertion breaks.
Possible naming schemas:
- `assertEq`
- `assEq`
- `eq`
Because of a name collision with Foundry's assertion, it seems impractical to use `assertEq`.
### Clamping
Clamping is used to restrict a value between a minimal and maximal value.
```solidity
function clampBetween(uint256 value, uint256 low, uint256 high) internal returns (uint256);
```
There are multiple ways to clamp values, and different words mean different things between the current tools.
- https://en.wikipedia.org/wiki/Clamping_(graphics)
- https://en.wikipedia.org/wiki/Modular_arithmetic
Possible names:
- `clampBetween`
- `boundBetween`
- `wrapBetween`
- no `*Between` ?
## Todo
- structure
- when abstract class
- when libraries
- how to use, what to inherit, etc..
- logging
- string formatting
- asserts
- approximately equals
- assertion helpers
- assertRevertReasonEqual
- clamping
- clamplte/gte
- account management
- vm.prank
- proxies
- support multiple platforms
- echidna
- medusa
- foundry
- halmos
- toString helpers
- math helpers
- absolute value
- absolute difference
- random number generation
- https://twitter.com/optimizoor/status/1741620566539526367
- `seed = keccak256(bytes.concat(seed));`
- testing
- unit
- fuzz
- licencing