Forge supports testing in a forked environment by using --fork-url option. We utilize this to test the V1 contracts that were deployed to Ethereum mainnet.
✔️ Solution
The solution is pushed to branch feature/test-mainnet-fork
Some fuzz test parameters are simplified as it takes a very long time to run, for example, bytes32[] -> bytes32
Invariant tests don't seem to work well and they resulted in errors like:
2023-08-14T14:52:59.492059Z ERROR forge::runner: Failed to replay invariant error err=
Failed to create counter example
Context:
Couldn't call unknown contract
, also some invariant test failed on test cases that were ruled out by the code. For example, [here](https://github.com/cartesi/rollups/blob/c6f5d9953478896fed2affd820766bbce2d6d211/onchain/rollups/test/foundry/portals/EtherPortal.t.sol#L168) we eliminate the cases when ether sender is overlapped with one of the receivers, and it works well without forking. But in the forked environment, this failed.
So the final command to run tests in mainnet fork is:
forge test -vvv --fork-url <your_rpc_url> --no-match-test invariant
P.S. also need to run ./update-proofs.sh to update proofs
📚 Context
Forge supports testing in a forked environment by using
--fork-url
option. We utilize this to test the V1 contracts that were deployed to Ethereum mainnet.✔️ Solution
The solution is pushed to branch
feature/test-mainnet-fork
bytes32[]
->bytes32
Context:
So the final command to run tests in mainnet fork is:
forge test -vvv --fork-url <your_rpc_url> --no-match-test invariant
P.S. also need to run
./update-proofs.sh
to update proofs@cartesi/rollups-unit