Skip to content

Commit

Permalink
♻️ Update revertTo and snapshot Cheat Codes (#275)
Browse files Browse the repository at this point in the history
### 🕓 Changelog

The Foundry PR [#8945](foundry-rs/foundry#8945)
introduced a renaming of the `snapshot` and `revertTo` cheat codes, now
referred to as `snapshotState` and `revertToState`. In response, this PR
updates our test suite—specifically the `ERC721Test` contract—to align
with these revised cheat codes. Additionally, `ethers` has been upgraded
to the latest version
[`6.13.3`](https://github.com/ethers-io/ethers.js/releases/tag/v6.13.3),
and all submodules have been updated to their most recent available
commits.

---------

Signed-off-by: Pascal Marco Caversaccio <[email protected]>
  • Loading branch information
pcaversaccio authored Oct 3, 2024
1 parent 1ff03b4 commit 949adb5
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 174 deletions.
268 changes: 134 additions & 134 deletions .gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/create-util
Submodule create-util updated 2 files
+2 −2 package.json
+79 −79 pnpm-lock.yaml
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 2 files
+22 −7 src/Vm.sol
+1 −1 test/Vm.t.sol
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@openzeppelin/merkle-tree": "^1.0.7",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
"ethers": "^6.13.2",
"ethers": "^6.13.3",
"keccak256": "^1.0.6",
"merkletreejs": "^0.4.0",
"prettier": "^3.3.3",
Expand Down
34 changes: 17 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions test/tokens/ERC721.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ contract ERC721Test is Test {
bool withData,
bytes memory data
) internal {
uint256 snapshot = vm.snapshot();
uint256 snapshot = vm.snapshotState();
vm.startPrank(owner);
vm.expectEmit(true, true, true, false);
emit IERC721.Transfer(owner, receiver, tokenId);
Expand Down Expand Up @@ -249,9 +249,9 @@ contract ERC721Test is Test {
}
_transferSuccess(owner, tokenId, receiver);
vm.stopPrank();
vm.revertTo(snapshot);
vm.revertToState(snapshot);

snapshot = vm.snapshot();
snapshot = vm.snapshotState();
vm.startPrank(approved);
vm.expectEmit(true, true, true, false);
emit IERC721.Transfer(owner, receiver, tokenId);
Expand Down Expand Up @@ -279,9 +279,9 @@ contract ERC721Test is Test {
}
_transferSuccess(owner, tokenId, receiver);
vm.stopPrank();
vm.revertTo(snapshot);
vm.revertToState(snapshot);

snapshot = vm.snapshot();
snapshot = vm.snapshotState();
vm.startPrank(operator);
vm.expectEmit(true, true, true, false);
emit IERC721.Transfer(owner, receiver, tokenId);
Expand Down Expand Up @@ -309,9 +309,9 @@ contract ERC721Test is Test {
}
_transferSuccess(owner, tokenId, receiver);
vm.stopPrank();
vm.revertTo(snapshot);
vm.revertToState(snapshot);

snapshot = vm.snapshot();
snapshot = vm.snapshotState();
vm.startPrank(owner);
ERC721Extended.approve(zeroAddress, tokenId);
vm.stopPrank();
Expand Down Expand Up @@ -342,9 +342,9 @@ contract ERC721Test is Test {
}
_transferSuccess(owner, tokenId, receiver);
vm.stopPrank();
vm.revertTo(snapshot);
vm.revertToState(snapshot);

snapshot = vm.snapshot();
snapshot = vm.snapshotState();
vm.startPrank(owner);
vm.expectEmit(true, true, true, false);
emit IERC721.Transfer(owner, owner, tokenId);
Expand All @@ -371,7 +371,7 @@ contract ERC721Test is Test {
assertEq(ERC721Extended.tokenOfOwnerByIndex(owner, 0), tokenId);
assertTrue(ERC721Extended.tokenOfOwnerByIndex(owner, 1) == tokenId + 1);
vm.stopPrank();
vm.revertTo(snapshot);
vm.revertToState(snapshot);

/**
* @dev Validates all possible reverts.
Expand Down Expand Up @@ -408,7 +408,7 @@ contract ERC721Test is Test {
address receiver,
bytes memory data
) internal {
uint256 snapshot = vm.snapshot();
uint256 snapshot = vm.snapshotState();
_shouldTransferTokensByUsers(
transferFunction,
owner,
Expand All @@ -419,9 +419,9 @@ contract ERC721Test is Test {
true,
data
);
vm.revertTo(snapshot);
vm.revertToState(snapshot);

snapshot = vm.snapshot();
snapshot = vm.snapshotState();
_shouldTransferTokensByUsers(
transferFunction,
owner,
Expand All @@ -432,9 +432,9 @@ contract ERC721Test is Test {
true,
data
);
vm.revertTo(snapshot);
vm.revertToState(snapshot);

snapshot = vm.snapshot();
snapshot = vm.snapshotState();
vm.startPrank(owner);
vm.expectEmit(true, true, true, true, receiver);
emit ERC721ReceiverMock.Received(owner, owner, tokenId, data);
Expand All @@ -450,9 +450,9 @@ contract ERC721Test is Test {
);
_transferSuccess(owner, tokenId, receiver);
vm.stopPrank();
vm.revertTo(snapshot);
vm.revertToState(snapshot);

snapshot = vm.snapshot();
snapshot = vm.snapshotState();
vm.startPrank(approved);
vm.expectEmit(true, true, true, true, receiver);
emit ERC721ReceiverMock.Received(approved, owner, tokenId, data);
Expand All @@ -468,7 +468,7 @@ contract ERC721Test is Test {
);
_transferSuccess(owner, tokenId, receiver);
vm.stopPrank();
vm.revertTo(snapshot);
vm.revertToState(snapshot);

vm.startPrank(owner);
vm.expectRevert(bytes("erc721: invalid token ID"));
Expand Down

0 comments on commit 949adb5

Please sign in to comment.