Conversation
|
Tried to stick to their testing standard. But I'm unsure if the |
|
|
||
| // Mint some tokens to `_from` so then they can be burned | ||
| vm.prank(BRIDGE); | ||
| superchainERC20.mint(_from, _amount); |
There was a problem hiding this comment.
deal() didn't work here so I used the mint()
There was a problem hiding this comment.
I believe it's okay. I'm not sure if deal increases the totalSupply, and the SuperchainERC20 tokens start with a totalSupply of 0. If you don't mint, the totalSupply would underflow. Either way, how did you attempt to use deal here, and with what error did it fail?
deal(address(SuperchainERC20), _from, _amount) didn't work?
|
|
||
| // Mint some tokens to the sender so then they can be sent | ||
| vm.prank(BRIDGE); | ||
| superchainERC20.mint(_sender, _amount); |
There was a problem hiding this comment.
Same here, deal() didn't work here so I used mint()
Let's leave them for now. They shouldn't be tested, as this is functionality incorporated by OZ, but as long as we use OZ it's ok to have them. If we switch to solady or solmate, we will need to remove it (plus they should fail if we do so) |
| vm.assume(_caller != BRIDGE); | ||
|
|
||
| // Expect the revert with `CallerNotBridge` selector | ||
| vm.expectRevert(abi.encodeWithSelector(CallerNotBridge.selector)); |
There was a problem hiding this comment.
no need to encode it, should allow you to do vm.expectRevert(CallerNotBridge.selector);
|
|
||
| // Call the `mint` function with the zero address | ||
| vm.prank(BRIDGE); | ||
| address _to = address(0); |
There was a problem hiding this comment.
check if there's a ZERO_ADDRESS constant, or create it otherwise and replace, you can probably do some:
``superchainERC20.mint({_to: ZERO_ADDRESS, _amount})` kind of thing to have it as a one liner
|
|
||
| // Mint some tokens to `_from` so then they can be burned | ||
| vm.prank(BRIDGE); | ||
| superchainERC20.mint(_from, _amount); |
There was a problem hiding this comment.
I believe it's okay. I'm not sure if deal increases the totalSupply, and the SuperchainERC20 tokens start with a totalSupply of 0. If you don't mint, the totalSupply would underflow. Either way, how did you attempt to use deal here, and with what error did it fail?
deal(address(SuperchainERC20), _from, _amount) didn't work?
| bytes memory _message = abi.encodeCall(superchainERC20.relayERC20, (_to, _amount)); | ||
| _mockAndExpect( | ||
| MESSENGER, | ||
| abi.encodeWithSelector( |
There was a problem hiding this comment.
abi.encodeCall here would be tidier
| // Expect the revert with `CallerNotBridge` selector | ||
| vm.expectRevert(abi.encodeWithSelector(RelayMessageCallerNotL2ToL2CrossDomainMessenger.selector)); | ||
|
|
||
| // Call the `sendERC20` function with the non-messenger caller |
There was a problem hiding this comment.
| // Call the `sendERC20` function with the non-messenger caller | |
| // Call the `relayERC20` function with the non-messenger caller |
| // Ensure the caller is not the messenger | ||
| vm.assume(_caller != MESSENGER); | ||
|
|
||
| // Expect the revert with `CallerNotBridge` selector |
There was a problem hiding this comment.
| // Expect the revert with `CallerNotBridge` selector | |
| // Expect the revert with `RelayMesasgeCallerNotL2ToL2CrossDomainMessenger` selector |
| assertEq(superchainERC20.balanceOf(_sender), _senderBalanceBefore - _amount); | ||
| } | ||
|
|
||
| /// @dev Tests the `sendERC20` function reverts when the caller is not the bridge. |
There was a problem hiding this comment.
| /// @dev Tests the `sendERC20` function reverts when the caller is not the bridge. | |
| /// @dev Tests the `relayERC20` function reverts when the caller is not the L2ToL2CrossDomainMessenger. |
Since this pov, I'm more inclined to removing those tests. But lmk which is your decision 👍 |
| } | ||
|
|
||
| /// @dev Tests the `burn` succeeds and emits the `Burn` event. | ||
| /// @dev Tests the `burn` bruns the amount and emits the `Burn` event. |
| // Mock the call over the `sendMessage` function and expect it to be called properly | ||
| _mockAndExpect( | ||
| MESSENGER, | ||
| abi.encodeWithSelector( |
There was a problem hiding this comment.
hehe i meant using abi.encodeCall instead of abi.encodeWithSelector not moving the message declaration within the body, but it's ok
There was a problem hiding this comment.
ah jaja, will undo that and use abi.encodeCall then
…thereum-optimism#19272) * contracts: implement audit code fixes and add tests Add onlyDelegateCall enforcement to upgradeSuperchain, upgrade, and migrate functions (#17). Include msg.sender in deploy salt to prevent cross-caller CREATE2 collisions (#17). Add duplicate instruction key detection in upgrade validation (#9). Validate startingRespectedGameType against enabled game configs (#10). Add code-existence check in loadBytes (#18). Add setUp guard to VerifyOPCM.runSingle (#4). Remove unused _findChar function (#5). Pass real AddressManager in migrator proxy deploy args (#11). Add tests covering all audit fix behaviors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * contracts: regenerate semver-lock.json for OPContractsManagerV2 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * contracts: bump OPContractsManagerV2 version to 7.0.10 Semver-diff requires a patch version bump when bytecode changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

CLOSES OPT-143