Skip to content

Commit

Permalink
♻️ Fix zksync tests (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized authored Jan 27, 2025
1 parent 8abe9a9 commit 8da1db8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/ext/zksync/SafeTransferLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ contract SafeTransferLibTest is SoladyTest {
uint256 internal constant _REVERTS_WITH_SELECTOR = 2;
uint256 internal constant _REVERTS_WITH_ANY = 3;

address internal constant _REGULAR_EVM_PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;

RevertingToken reverting;
ReturnsTwoToken returnsTwo;
ReturnsFalseToken returnsFalse;
Expand Down Expand Up @@ -372,18 +374,22 @@ contract SafeTransferLibTest is SoladyTest {
}

function testApproveWithMissingReturn(address to, uint256 amount) public {
if (to == _REGULAR_EVM_PERMIT2) return;
verifySafeApprove(address(missingReturn), to, amount, _SUCCESS);
}

function testApproveWithStandardERC20(address to, uint256 amount) public {
if (to == _REGULAR_EVM_PERMIT2) return;
verifySafeApprove(address(erc20), to, amount, _SUCCESS);
}

function testApproveWithReturnsTooMuch(address to, uint256 amount) public {
if (to == _REGULAR_EVM_PERMIT2) return;
verifySafeApprove(address(returnsTooMuch), to, amount, _SUCCESS);
}

function testApproveWithNonGarbage(address to, uint256 amount) public {
if (to == _REGULAR_EVM_PERMIT2) return;
returnsRawBytes.setRawBytes(_generateNonGarbage());

verifySafeApprove(address(returnsRawBytes), to, amount, _SUCCESS);
Expand All @@ -392,6 +398,7 @@ contract SafeTransferLibTest is SoladyTest {
function testApproveWithNonContractReverts(address nonContract, address to, uint256 amount)
public
{
if (to == _REGULAR_EVM_PERMIT2) return;
if (uint256(uint160(nonContract)) <= 18 || nonContract.code.length > 0) {
return;
}
Expand All @@ -404,6 +411,7 @@ contract SafeTransferLibTest is SoladyTest {
address to,
uint256 amount
) public {
if (to == _REGULAR_EVM_PERMIT2) return;
if (uint256(uint160(nonContract)) <= 18 || nonContract.code.length > 0) {
return;
}
Expand All @@ -412,6 +420,7 @@ contract SafeTransferLibTest is SoladyTest {
}

function testApproveWithRetry(address to, uint256 amount0, uint256 amount1) public {
if (to == _REGULAR_EVM_PERMIT2) return;
MockERC20LikeUSDT usdt = new MockERC20LikeUSDT();
assertEq(usdt.allowance(address(this), to), 0);
SafeTransferLib.safeApproveWithRetry(address(usdt), _brutalized(to), amount0);
Expand Down

0 comments on commit 8da1db8

Please sign in to comment.