Skip to content

Commit

Permalink
chore: remove fork tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatil12 committed Oct 28, 2024
1 parent d6c5281 commit 9b9b636
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/testinparallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ jobs:
RPC_HOLESKY: ${{ secrets.RPC_HOLESKY }}
CHAIN_ID: ${{ secrets.CHAIN_ID }}

- name: Run integration mainnet fork tests
run: forge test --match-contract Integration
env:
FOUNDRY_PROFILE: "forktest"
RPC_MAINNET: ${{ secrets.RPC_MAINNET }}
RPC_HOLESKY: ${{ secrets.RPC_HOLESKY }}
CHAIN_ID: ${{ secrets.CHAIN_ID }}
# TODO: uncomment this item once we've added the proper upgrade tests
# - name: Run integration mainnet fork tests
# run: forge test --match-contract Integration
# env:
# FOUNDRY_PROFILE: "forktest"
# RPC_MAINNET: ${{ secrets.RPC_MAINNET }}
# RPC_HOLESKY: ${{ secrets.RPC_HOLESKY }}
# CHAIN_ID: ${{ secrets.CHAIN_ID }}
2 changes: 1 addition & 1 deletion src/test/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function testFuzz_deposit_delegate_EXAMPLE(uint24 _random) public {

**If you want to know about the time travel**, there's a few things to note:

The main feature we're using is foundry's `cheats.snapshot()` and `cheats.revertTo(snapshot)` to zip around in time. You can look at the [Cheatcodes Reference](https://book.getfoundry.sh/cheatcodes/#cheatcodes-interface) to get some idea, but the docs aren't actually correct. The best thing to do is look through our tests and see how it's being used. If you see an assertion called `assert_Snap_...`, that's using the `TimeMachine` under the hood.
The main feature we're using is foundry's `cheats.snapshotState()` and `cheats.revertToState(snapshot)` to zip around in time. You can look at the [Cheatcodes Reference](https://book.getfoundry.sh/cheatcodes/#cheatcodes-interface) to get some idea, but the docs aren't actually correct. The best thing to do is look through our tests and see how it's being used. If you see an assertion called `assert_Snap_...`, that's using the `TimeMachine` under the hood.

Speaking of, the `TimeMachine` is a global contract that controls the time, fate, and destiny of all who use it.
* `Users` use the `TimeMachine` to snapshot chain state *before* every action they perform. (see the [`User.createSnapshot`](https://github.com/layr-labs/eigenlayer-contracts/blob/c5193f7bff00903a4323be2a1500cbf7137a83e9/src/test/integration/User.t.sol#L43-L46) modifier).
Expand Down
8 changes: 4 additions & 4 deletions src/test/integration/TimeMachine.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract TimeMachine is Test {
uint lastSnapshot;

function createSnapshot() public returns (uint) {
uint snapshot = cheats.snapshot();
uint snapshot = cheats.snapshotState();
lastSnapshot = snapshot;
pastExists = true;
return snapshot;
Expand All @@ -22,12 +22,12 @@ contract TimeMachine is Test {
// so we don't accidentally prevent our own births
assertTrue(pastExists, "Global.warpToPast: invalid usage, past does not exist");

curState = cheats.snapshot();
cheats.revertTo(lastSnapshot);
curState = cheats.snapshotState();
cheats.revertToState(lastSnapshot);
return curState;
}

function warpToPresent(uint curState) public {
cheats.revertTo(curState);
cheats.revertToState(curState);
}
}

0 comments on commit 9b9b636

Please sign in to comment.