Skip to content

Commit

Permalink
tests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Oct 14, 2024
1 parent a00918b commit 46dcff9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
15 changes: 15 additions & 0 deletions v2/test/GatewayEVM.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ contract GatewayEVMInboundTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IR
gateway.deposit(destination, amount, address(token), revertOptions);
}

function testDepositERC20ToCustodyFailsIfPayloadSizeExceeded() public {
uint256 amount = 100_000;
token.approve(address(gateway), amount);
revertOptions.revertMessage = new bytes(gateway.MAX_PAYLOAD_SIZE() + 1);

vm.expectRevert(PayloadSizeExceeded.selector);
gateway.deposit(destination, amount, address(token), revertOptions);
}

function testDepositZetaToConnector() public {
uint256 amount = 100_000;
zeta.approve(address(gateway), amount);
Expand Down Expand Up @@ -492,6 +501,12 @@ contract GatewayEVMInboundTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IR
gateway.deposit{ value: amount }(destination, revertOptions);
}

function testFailDepositEthToTssIfPayloadSizeExceeded() public {
revertOptions.revertMessage = new bytes(gateway.MAX_PAYLOAD_SIZE() + 1);
vm.expectRevert("PayloadSizeExceeded");
gateway.deposit{ value: 1 }(destination, revertOptions);
}

function testFailDepositEthToTssIfReceiverIsZeroAddress() public {
uint256 amount = 1;

Expand Down
20 changes: 16 additions & 4 deletions v2/test/GatewayZEVM.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ contract GatewayZEVMInboundTest is Test, IGatewayZEVMEvents, IGatewayZEVMErrors
gateway.withdraw(abi.encodePacked(addr1), amount, address(zrc20), revertOptions);
}

function testWithdrawZRC20FailsIfMessageSizeExceeded() public {
revertOptions.revertMessage = new bytes(gateway.MAX_MESSAGE_SIZE() + 1);
vm.expectRevert(MessageSizeExceeded.selector);
gateway.withdraw(abi.encodePacked(addr1), 2, address(zrc20), revertOptions);
}

function testWithdrawZRC20FailsIsAmountIs0() public {
vm.expectRevert(InsufficientZRC20Amount.selector);
gateway.withdraw(abi.encodePacked(addr1), 0, address(zrc20), revertOptions);
Expand Down Expand Up @@ -164,8 +170,8 @@ contract GatewayZEVMInboundTest is Test, IGatewayZEVMEvents, IGatewayZEVMErrors
}

function testWithdrawAndCallZRC20FailsIfMessageSizeExceeded() public {
bytes memory message = new bytes(512);
revertOptions.revertMessage = new bytes(512);
bytes memory message = new bytes(gateway.MAX_MESSAGE_SIZE() / 2);
revertOptions.revertMessage = new bytes(gateway.MAX_MESSAGE_SIZE() / 2 + 1);

vm.expectRevert(MessageSizeExceeded.selector);
gateway.withdrawAndCall(abi.encodePacked(addr1), 1, address(zrc20), message, 1, revertOptions);
Expand Down Expand Up @@ -231,6 +237,12 @@ contract GatewayZEVMInboundTest is Test, IGatewayZEVMEvents, IGatewayZEVMErrors
// gateway.withdraw(abi.encodePacked(addr1), 0, 1, revertOptions);
// }

// function testWithdrawZETAFailsIfMessageSizeExceeded() public {
// revertOptions.revertMessage = new bytes(gateway.MAX_MESSAGE_SIZE() + 1);
// vm.expectRevert(MessageSizeExceeded.selector);
// gateway.withdraw(abi.encodePacked(addr1), 1, 1, revertOptions);
// }

// function testWithdrawZETAFailsIfReceiverIsZeroAddress() public {
// vm.expectRevert(ZeroAddress.selector);
// gateway.withdraw(abi.encodePacked(""), 0, 1, revertOptions);
Expand Down Expand Up @@ -367,8 +379,8 @@ contract GatewayZEVMInboundTest is Test, IGatewayZEVMEvents, IGatewayZEVMErrors
}

function testCallFailsIfMessageSizeExceeded() public {
bytes memory message = new bytes(512);
revertOptions.revertMessage = new bytes(512);
bytes memory message = new bytes(gateway.MAX_MESSAGE_SIZE() / 2);
revertOptions.revertMessage = new bytes(gateway.MAX_MESSAGE_SIZE() / 2 + 1);
vm.expectRevert(MessageSizeExceeded.selector);
gateway.call(abi.encodePacked(addr1), address(zrc20), message, 1, revertOptions);
}
Expand Down

0 comments on commit 46dcff9

Please sign in to comment.