Skip to content

Commit a17bc74

Browse files
authored
Added changes in cheatcodes (#79)
1 parent c8d93d6 commit a17bc74

3 files changed

Lines changed: 55 additions & 8 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Fuzzlib
22

3-
General purpose unopinionated Solidity fuzzing library for stateful and stateless fuzzing. Compatible with Echidna, Medusa, and Foundry.
3+
Fuzzlib is a general purpose unopinionated Solidity fuzzing library for stateful and stateless fuzzing. Compatible with Echidna, Medusa, and Foundry.
44

55
Provides common utilities for fuzz testing through a simple `fl` namespace: assertions, value clamping, logging, math operations, and more.
66

7+
Maintained by [Perimeter](https://www.perimetersec.io) – Leaders in securing DeFi using fuzzing since 2022.
8+
79
## Key Features
810

911
- **Basic Assertions**: Helpers for common test conditions and equality checks

src/IHevm.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ interface IHevm {
5959
*/
6060
function prank(address newSender) external;
6161

62+
/**
63+
* @dev Sets msg.sender to the specified sender until stopPrank() is called
64+
*/
65+
function startPrank(address sender) external;
66+
67+
/**
68+
* @dev Resets msg.sender to the default sender.
69+
*/
70+
function stopPrank() external;
71+
6272
/**
6373
* @dev Creates a new fork with the given endpoint and the latest block and returns the identifier of the fork
6474
*/

src/IStdCheats.sol

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import {Constants} from "./Constants.sol";
55

66
/**
77
* @dev Available cheat codes for Medusa.
8-
* Documentation: https://github.com/crytic/medusa/tree/dev/mdbook/docs/src/cheatcodes
9-
* Usage: https://github.com/crytic/medusa/blob/dev/mdbook/docs/src/cheatcodes_overview.md
8+
* Documentation: https://github.com/crytic/medusa/blob/master/docs/src/cheatcodes/cheatcodes_overview.md
9+
* Usage: https://github.com/crytic/medusa/blob/master/docs/src/cheatcodes/cheatcodes_overview.md#cheatcode-interface
1010
* @author Perimeter <info@perimetersec.io>
1111
*/
1212
interface IStdCheats {
13-
/**
13+
/**
1414
* @dev Set block.timestamp
1515
*/
1616
function warp(uint256 x) external;
@@ -23,20 +23,25 @@ interface IStdCheats {
2323
/**
2424
* @dev Set block.basefee
2525
*/
26-
function fee(uint256 x) external;
26+
function fee(uint256 fee) external;
27+
28+
/**
29+
* @dev Set block.difficulty (deprecated in `medusa`)
30+
*/
31+
function difficulty(uint256 difficulty) external;
2732

2833
/**
29-
* @dev Set block.difficulty and block.prevrandao
34+
* @dev Set block.prevrandao
3035
*/
31-
function difficulty(uint256 x) external;
36+
function prevrandao(bytes32 x) external;
3237

3338
/**
3439
* @dev Set block.chainid
3540
*/
3641
function chainId(uint256 x) external;
3742

3843
/**
39-
* @dev Sets the block.coinbase
44+
* @dev Set block.coinbase
4045
*/
4146
function coinbase(address x) external;
4247

@@ -55,6 +60,16 @@ interface IStdCheats {
5560
*/
5661
function prank(address sender) external;
5762

63+
/**
64+
* @dev Sets all subsequent call's msg.sender (until stopPrank is called) to be the input address
65+
*/
66+
function startPrank(address sender) external;
67+
68+
/**
69+
* @dev Stops a previously called startPrank
70+
*/
71+
function stopPrank() external;
72+
5873
/**
5974
* @dev Set msg.sender to the input address until the current call exits
6075
*/
@@ -70,6 +85,11 @@ interface IStdCheats {
7085
*/
7186
function etch(address who, bytes calldata code) external;
7287

88+
/**
89+
* @dev Sets a label for an address (for debugging purposes)
90+
*/
91+
function label(address account, string calldata label) external;
92+
7393
/**
7494
* @dev Signs data
7595
*/
@@ -80,6 +100,11 @@ interface IStdCheats {
80100
*/
81101
function addr(uint256 privateKey) external returns (address);
82102

103+
/**
104+
* @dev Gets the creation bytecode of a contract
105+
*/
106+
function getCode(string calldata) external returns (bytes memory);
107+
83108
/**
84109
* @dev Gets the nonce of an account
85110
*/
@@ -96,6 +121,16 @@ interface IStdCheats {
96121
*/
97122
function ffi(string[] calldata) external returns (bytes memory);
98123

124+
/**
125+
* @dev Take a snapshot of the current state of the EVM
126+
*/
127+
function snapshot() external returns (uint256);
128+
129+
/**
130+
* @dev Revert state back to a snapshot
131+
*/
132+
function revertTo(uint256) external returns (bool);
133+
99134
/**
100135
* @dev Convert Solidity types to strings
101136
*/

0 commit comments

Comments
 (0)