Skip to content

Commit

Permalink
implement zero fee tests across withdraw tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tsnewnami committed Nov 14, 2023
1 parent 77cb9b3 commit bda3ef2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 1 deletion.
7 changes: 7 additions & 0 deletions test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ contract ChildERC20BridgeWithdrawUnitTest is Test, IChildERC20BridgeEvents, IChi
childToken.approve(address(childBridge), 1000000 ether);
}

function test_RevertsIf_WithdrawCalledWithZeroFee() public {
uint256 withdrawAmount = 100;

vm.expectRevert(ZeroValue.selector);
childBridge.withdraw(IChildERC20(address(2222222)), withdrawAmount);
}

function test_RevertsIf_WithdrawCalledWithEmptyChildToken() public {
vm.expectRevert(EmptyTokenContract.selector);
childBridge.withdraw{value: 1 ether}(IChildERC20(address(2222222)), 100);
Expand Down
7 changes: 7 additions & 0 deletions test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ contract ChildERC20BridgeWithdrawIMXUnitTest is Test, IChildERC20BridgeEvents, I
);
}

function test_RevertIf_WithdrawIMXCalledWithZeroFee() public {
uint256 withdrawAmount = 300;

vm.expectRevert(ZeroValue.selector);
childBridge.withdrawIMX(withdrawAmount);
}

function test_RevertsIf_WithdrawIMXCalledWithInsufficientFund() public {
uint256 withdrawAmount = 7 ether;

Expand Down
7 changes: 7 additions & 0 deletions test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ contract ChildERC20BridgeWithdrawToUnitTest is Test, IChildERC20BridgeEvents, IC
childToken.approve(address(childBridge), 1000000 ether);
}

function test_RevertsIf_WithdrawToCalledWithZeroFee() public {
uint256 withdrawAmount = 300;

vm.expectRevert(ZeroValue.selector);
childBridge.withdrawTo(IChildERC20(address(2222222)), address(this), withdrawAmount);
}

function test_RevertsIf_WithdrawToCalledWithEmptyChildToken() public {
vm.expectRevert(EmptyTokenContract.selector);
childBridge.withdrawTo{value: 1 ether}(IChildERC20(address(2222222)), address(this), 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,21 @@ contract ChildERC20BridgeWithdrawIMXToUnitTest is Test, IChildERC20BridgeEvents,
);
}

function test_RevertsIf_withdrawIMXToCalledWithZeroFee() public {
uint256 withdrawAmount = 7 ether;

vm.expectRevert(ZeroValue.selector);
childBridge.withdrawIMXTo(address(this), withdrawAmount);
}

function test_RevertsIf_withdrawIMXToCalledWithInsufficientFund() public {
uint256 withdrawAmount = 7 ether;

vm.expectRevert(InsufficientValue.selector);
childBridge.withdrawIMXTo{value: withdrawAmount - 1}(address(this), withdrawAmount);
}

function test_RevertIf_ZeroAmountIsProvided() public {
function test_RevertIf_withdrawIMXToZeroAmountIsProvided() public {
uint256 withdrawFee = 300;

vm.expectRevert(ZeroAmount.selector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ contract ChildERC20BridgeWithdrawWIMXUnitTest is Test, IChildERC20BridgeEvents,
);
}

function test_RevertsIf_withdrawIMXCalledWithZeroFee() public {
uint256 withdrawAmount = 7 ether;

vm.expectRevert(ZeroValue.selector);
childBridge.withdrawIMX(withdrawAmount);
}

function test_RevertsIf_WithdrawWIMXCalledWithInsufficientFund() public {
uint256 withdrawAmount = 101 ether;
uint256 withdrawFee = 300;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ contract ChildERC20BridgeWithdrawWIMXToUnitTest is Test, IChildERC20BridgeEvents
);
}

function test_RevertsIf_withdrawWIMXToCalledWithZeroFee() public {
uint256 withdrawAmount = 7 ether;

vm.expectRevert(ZeroValue.selector);
childBridge.withdrawWIMXTo(address(this), withdrawAmount);
}

function test_RevertsIf_WithdrawWIMXToCalledWithInsufficientFund() public {
uint256 withdrawAmount = 101 ether;
uint256 withdrawFee = 300;
Expand Down

0 comments on commit bda3ef2

Please sign in to comment.