You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a helper contract for errors and reverts in solidity. In `forge`, this contract is particularly helpful for the `expectRevert` cheatcode, as it provides all compiler builtin errors.
14
+
This is a helper contract for errors and reverts. In `forge`, this contract is particularly helpful for the `expectRevert` cheatcode, as it provides all compiler builtin errors.
15
15
16
16
See the contract itself for all error codes.
17
17
@@ -23,7 +23,7 @@ import "ds-test/test.sol";
23
23
import "forge-std/stdlib.sol";
24
24
import "forge-std/Vm.sol";
25
25
26
-
contract TestContract is DSTest, stdError {
26
+
contract TestContract is DSTest {
27
27
Vm public constant vm = Vm(HEVM_ADDRESS);
28
28
29
29
ErrorsTest test;
@@ -47,7 +47,7 @@ contract ErrorsTest {
47
47
48
48
### stdStorage
49
49
50
-
This is a rather large contract due to all of the overloading to make the UX decent. Primarly, it is a wrapper around the `record` and `accesses` cheatcodes. It can *always* find and write the storage slot(s) associated with a particular variable without knowing the storage layout. The one _major_ caveat to this is while a slot can be found for packed storage variables, we can't write to that variable safely. If a user tries to write to a packed slot, the execution throws an error, unless it is uninitialized (`bytes32(0)`).
50
+
This is a rather large contract due to all of the overloading to make the UX decent. Primarily, it is a wrapper around the `record` and `accesses` cheatcodes. It can *always* find and write the storage slot(s) associated with a particular variable without knowing the storage layout. The one _major_ caveat to this is while a slot can be found for packed storage variables, we can't write to that variable safely. If a user tries to write to a packed slot, the execution throws an error, unless it is uninitialized (`bytes32(0)`).
51
51
52
52
This works by recording all `SLOAD`s and `SSTORE`s during a function call. If there is a single slot read or written to, it immediately returns the slot. Otherwise, behind the scenes, we iterate through and check each one (assuming the user passed in a `depth` parameter). If the variable is a struct, you can pass in a `depth` parameter which is basically the field depth.
53
53
@@ -99,14 +99,14 @@ contract TestContract is DSTest {
99
99
100
100
// It supports arbitrary storage layouts, like assembly based storage locations
101
101
function testFindHidden() public {
102
-
// hidden is a random hash of a bytes, iteration through slots would
102
+
// `hidden` is a random hash of a bytes, iteration through slots would
103
103
// not find it. Our mechanism does
104
-
// Also, you can use the selector instead of string
104
+
// Also, you can use the selector instead of a string
// if targeting a mapping, you have to pass in the keys necessary to perform the find
109
+
// If targeting a mapping, you have to pass in the keys necessary to perform the find
110
110
// i.e.:
111
111
function testFindMapping() public {
112
112
uint256 slot = stdstore
@@ -183,7 +183,7 @@ With these 4 functions, you can find any slot (or write to it with their counter
183
183
184
184
### stdCheats
185
185
186
-
This is a wrapper over miscellaneous cheatcodes that need wrappers to be more dev friendly. Currently there are only function related to `prank`. In general, users may expect ETH to be put into an address on `prank`, but this is not the case for safety reasons. Explicitly this `hoax` function should only be used for address that have expected balances as it will get overwritten. If an address already has Eth, you should just use `prank`. If you want to change that balance explicitly, just use `deal`. If you want to do both, `hoax` is also right for you.
186
+
This is a wrapper over miscellaneous cheatcodes that need wrappers to be more dev friendly. Currently there are only functions related to `prank`. In general, users may expect ETH to be put into an address on `prank`, but this is not the case for safety reasons. Explicitly this `hoax` function should only be used for address that have expected balances as it will get overwritten. If an address already has ETH, you should just use `prank`. If you want to change that balance explicitly, just use `deal`. If you want to do both, `hoax` is also right for you.
187
187
188
188
189
189
#### Example usage:
@@ -206,22 +206,22 @@ contract StdCheatsTest is DSTest, stdCheats {
206
206
}
207
207
208
208
function testHoax() public {
209
-
// we call the hoax, which gives the target address
209
+
// we call `hoax`, which gives the target address
210
210
// eth and then calls `prank`
211
211
hoax(address(1337));
212
212
test.bar{value: 100}(address(1337));
213
213
214
214
// overloaded to allow you to specify how much eth to
215
-
// initialize the addres with
215
+
// initialize the address with
216
216
hoax(address(1337), 1);
217
217
test.bar{value: 1}(address(1337));
218
218
}
219
219
220
220
function testStartHoax() public {
221
-
// we call the startHoax, which gives the target address
221
+
// we call `startHoax`, which gives the target address
222
222
// eth and then calls `startPrank`
223
223
//
224
-
// it is also overloaded so that you can specify eth amount
224
+
// it is also overloaded so that you can specify an eth amount
0 commit comments