From 5b34122816b74c7b02f61f78dd836d8919167a7e Mon Sep 17 00:00:00 2001 From: qedk <1994constant@gmail.com> Date: Wed, 7 Feb 2024 18:38:31 +0530 Subject: [PATCH] fix: add erc20 sending limit testcase --- test/AvailBridgeTest.t.sol | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/AvailBridgeTest.t.sol b/test/AvailBridgeTest.t.sol index 7b285c3..9b65c3c 100644 --- a/test/AvailBridgeTest.t.sol +++ b/test/AvailBridgeTest.t.sol @@ -733,6 +733,28 @@ contract AvailBridgeTest is Test, MurkyBase { bridge.sendERC20(assetId, dest, amount); } + function testRevertInvalidDestinationOrAmount_sendERC20(bytes32 assetId, bytes32 to, uint256 amount) external { + vm.assume(to != bytes32(0) && amount > type(uint128).max); + address from = makeAddr("from"); + ERC20Mock token = new ERC20Mock(); + token.mint(from, amount); + bytes32[] memory assetIdArr = new bytes32[](1); + assetIdArr[0] = assetId; + address[] memory tokenArr = new address[](1); + tokenArr[0] = address(token); + vm.prank(owner); + bridge.updateTokens(assetIdArr, tokenArr); + vm.startPrank(from); + vm.expectRevert(IAvailBridge.InvalidDestinationOrAmount.selector); + bridge.sendERC20(assetId, 0x0, uint128(amount)); + vm.expectRevert(IAvailBridge.InvalidDestinationOrAmount.selector); + bridge.sendERC20(assetId, to, amount); + vm.expectRevert(IAvailBridge.InvalidDestinationOrAmount.selector); + bridge.sendERC20(assetId, 0x0, amount); + assertEq(bridge.isSent(0), 0x0); + assertEq(token.balanceOf(address(bridge)), 0); + } + function test_sendERC20(bytes32 assetId, bytes32 to, uint128 amount) external { vm.assume(to != bytes32(0) && amount != 0); address from = makeAddr("from");