Skip to content

Commit 79d1881

Browse files
committed
update docs in accordance to foundry-rs/foundry#9791 and foundry-rs/foundry#9645
1 parent fd5a204 commit 79d1881

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/cheatcodes/gas-snapshots.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,17 @@ function snapshotGasLastCall(string calldata group, string calldata name) extern
3838

3939
`snapshotGas*` cheatcodes allow you to capture gas usage in your tests. This can be useful to track how much gas your logic is consuming. You can capture the gas usage of the last call by name, capture an arbitrary numerical value by name, or start and stop a snapshot capture of the current gas usage by name.
4040

41-
In order to strictly compare gas usage across test runs, set the `FORGE_SNAPSHOT_CHECK` environment variable to `true` before running your tests. This will compare the gas usage of your tests against the last snapshot and fail if the gas usage has changed. By default the snapshots directory will be newly created and its contents removed before each test run to ensure no stale data is present.
41+
In order to strictly compare gas usage across test runs you can do one of the following:
4242

43-
It is intended that the `snapshots` directory created when using the `snapshotGas*` cheatcodes is checked into version control. This allows you to track changes in gas usage over time and compare gas usage during code reviews.
43+
- Set the `FORGE_SNAPSHOT_CHECK=true` environment variable
44+
- Set `gas_snapshot_check` in `foundry.toml`
45+
- Pass `--gas-snapshot-check=true`
46+
47+
By default this is not enabled and passing `--gas-snapshot-check=false` will override all others.
4448

45-
When running `forge clean` the `snapshots` directory will be deleted.
49+
This will compare the gas usage of your tests against the last snapshot and fail if the gas usage has changed.
50+
51+
It is intended that the `snapshots` directory created when using the `snapshotGas*` cheatcodes is checked into version control. This allows you to track changes in gas usage over time and compare gas usage during code reviews.
4652

4753
### Examples
4854

@@ -68,7 +74,6 @@ contract SnapshotGasTest is Test {
6874

6975
Capturing the gas usage of multiple sections of code that modify the internal state:
7076

71-
7277
```solidity
7378
contract SnapshotGasTest is Test {
7479
uint256 public slot0;

0 commit comments

Comments
 (0)