Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (1a4960d 2024-03-20T00:19:54.542150000Z)
What command(s) is the bug in?
No response
Operating System
macOS (Apple Silicon)
Describe the bug
Our code in the UniStaker repo has unit tests that will fail if certain addresses are selected from storage by the fuzzer so we turned off include_storage in our foundry toml. This has worked fine for a long time. When we added invariant tests, we turned it on for those tests as the same restriction didn't exists. This worked fine across many thousands of fuzz runs locally and in CI.
Sometime recently, something seems to have changed. Now, we see CI failures where the fuzzer is clearly selecting values from storage for our unit tests.
Here's how you can reproduce.
- Clone the UniStaker repo
- Copy the
.env.template to .env and put in a valid RPC URL (we can avoid actually hitting it by not running integration tests) and deployer private key (it can be the default anvil account)
- Edit your foundry.toml, under the
[profile.default] section add fuzz = { runs = 100000 }
- Run locally
forge test --mt testFuzz_CalculatesCorrectEarningsForFourUsersWhenTwoStakeMorePartiallyThroughTheDurationAndOneBeneficiary
- You should see a test failures. It may take a bit to run. If you don't see failures, you got "lucky", run the command again
Using older values of Foundry this didn't occur.
Edit: Updated this to remove some comments about the settings in the invariant section impacting the fuzz runs. This seems not to be the case. It simply seems like we're getting values picked from storage now (despite the setting) when previously we weren't.
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (1a4960d 2024-03-20T00:19:54.542150000Z)
What command(s) is the bug in?
No response
Operating System
macOS (Apple Silicon)
Describe the bug
Our code in the UniStaker repo has unit tests that will fail if certain addresses are selected from storage by the fuzzer so we turned off
include_storagein our foundry toml. This has worked fine for a long time. When we added invariant tests, we turned it on for those tests as the same restriction didn't exists. This worked fine across many thousands of fuzz runs locally and in CI.Sometime recently, something seems to have changed. Now, we see CI failures where the fuzzer is clearly selecting values from storage for our unit tests.
Here's how you can reproduce.
.env.templateto.envand put in a valid RPC URL (we can avoid actually hitting it by not running integration tests) and deployer private key (it can be the default anvil account)[profile.default]section addfuzz = { runs = 100000 }forge test --mt testFuzz_CalculatesCorrectEarningsForFourUsersWhenTwoStakeMorePartiallyThroughTheDurationAndOneBeneficiaryUsing older values of Foundry this didn't occur.
Edit: Updated this to remove some comments about the settings in the
invariantsection impacting the fuzz runs. This seems not to be the case. It simply seems like we're getting values picked from storage now (despite the setting) when previously we weren't.