Skip to content

Commit

Permalink
add snapshots to CI with tolerance (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
snreynolds authored and zhongeric committed Dec 14, 2023
1 parent be80868 commit 2743802
Show file tree
Hide file tree
Showing 8 changed files with 346 additions and 6 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FOUNDRY_FUZZ_SEED=0x4444
1 change: 0 additions & 1 deletion .forge-snapshots/swap with native.snap

This file was deleted.

328 changes: 328 additions & 0 deletions .gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
with:
version: nightly

- name: Compile
- name: Lint
run: forge fmt --check
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ jobs:
with:
version: nightly

- name: Build
run: forge build

- name: Run tests
run: forge test -vvv
env:
FOUNDRY_PROFILE: ci

- name: Run forge snapshots
run: forge snapshot --check --tolerance 5
env:
FOUNDRY_FUZZ_SEED: "0x4444"
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ All contributions must follow the below standards. Maintainers will close out PR

## Tests

`forge snapshot`to update the forge gas snapshots
`forge snapshot`to update the forge gas snapshots. Note these must use a static fuzz seed, so please `source .env`, use `FOUNDRY_FUZZ_SEED=0x4444`, or use `just snapshots` when running forge snapshots.

`forge test` to run forge tests

Expand Down
8 changes: 6 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ ffi = true
fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}, { access = "read", path = "./out"}]
evm_version = 'paris'

[profile.ci]
fuzz_runs = 100000
[profile.default.fuzz]
runs = 100
seed = "0x4444"

[profile.ci.fuzz]
runs = 1000

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-forge: install-forge
forge build

snapshots-forge: install-forge test-forge
forge snapshot
FOUNDRY_FUZZ_SEED=0x4444 forge snapshot

install-forge:
forge install
Expand Down

0 comments on commit 2743802

Please sign in to comment.