foundry
foundry copied to clipboard
bug: state appears to be shared between tests when linked libraries are used
Component
Forge
Have you ensured that all of these are up to date?
- [ ] Foundry
- [ ] Foundryup
What version of Foundry are you on?
forge 0.2.0 (1197fbe 2024-08-09T00:25:08.996768000Z)
What command(s) is the bug in?
forge test
Operating System
None
Describe the bug
- Clone the optimism monorepo and check out this branch: https://github.com/ethereum-optimism/optimism/pull/11423
- Run
just test
, and you'll noticetestDebug
fails. That is hardcoded data from a failed CI run - Now, only run the failed test:
forge test --mt testDebug -vvv
. It will pass. If you run the full file containing that test it will also still pass. - Compare the passing and failing traces (see below screenshots). Notice how in the passing one, the call is to an unlabeled address, and in the failing one it's to an address labeled
ForgeArtifacts
. Based on the hardcoded calldata intestDebug
, we can see that address is0x5F65cD7D792E9746EF82929D60de9a1C526f93A5
.
So what appears to be happening here is that when the full suite is run, contracts deployed from another test (1) leak into the fuzzer dictionary of this test, and (2) the state leaks into this test as well.