Skip to content

Commit

Permalink
Rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
wcgcyx committed Nov 6, 2023
1 parent 6b8bd55 commit 0044293
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/child/ChildERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ contract ChildERC20Bridge is
_withdrawIMX(msg.sender, amount);
}

function withdrawToIMX(address receiver, uint256 amount) external payable {
function withdrawIMXTo(address receiver, uint256 amount) external payable {
_withdrawIMX(receiver, amount);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {Utils} from "../../../utils.t.sol";
import {WETH} from "../../../../src/test/root/WETH.sol";
import {ChildERC20} from "../../../../src/child/ChildERC20.sol";

contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
contract ChildERC20BridgewithdrawIMXToIntegrationTest is
Test,
IChildERC20BridgeEvents,
IChildAxelarBridgeAdaptorEvents,
Expand All @@ -44,7 +44,7 @@ contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
childIntegrationSetup();
}

function test_WithdrawToIMX_CallsBridgeAdaptor() public {
function test_withdrawIMXTo_CallsBridgeAdaptor() public {
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;

Expand All @@ -56,10 +56,10 @@ contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
abi.encodeWithSelector(axelarAdaptor.sendMessage.selector, predictedPayload, address(this))
);

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
}

function test_WithdrawToIMXWithDifferentAccount_CallsBridgeAdaptor() public {
function test_withdrawIMXToWithDifferentAccount_CallsBridgeAdaptor() public {
address receiver = address(0xabcd);
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;
Expand All @@ -72,10 +72,10 @@ contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
abi.encodeWithSelector(axelarAdaptor.sendMessage.selector, predictedPayload, address(this))
);

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
}

function test_WithdrawToIMX_CallsAxelarGateway() public {
function test_withdrawIMXTo_CallsAxelarGateway() public {
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;

Expand All @@ -92,10 +92,10 @@ contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
)
);

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
}

function test_WithdrawToIMXWithDifferentAccount_CallsAxelarGateway() public {
function test_withdrawIMXToWithDifferentAccount_CallsAxelarGateway() public {
address receiver = address(0xabcd);
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;
Expand All @@ -113,10 +113,10 @@ contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
)
);

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
}

function test_WithdrawToIMX_CallsGasService() public {
function test_withdrawIMXTo_CallsGasService() public {
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;

Expand All @@ -136,10 +136,10 @@ contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
)
);

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
}

function test_WithdrawToIMXWithDifferentAccount_CallsGasService() public {
function test_withdrawIMXToWithDifferentAccount_CallsGasService() public {
address receiver = address(0xabcd);
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;
Expand All @@ -160,10 +160,10 @@ contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
)
);

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
}

function test_WithdrawToIMX_EmitsAxelarMessageEvent() public {
function test_withdrawIMXTo_EmitsAxelarMessageEvent() public {
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;

Expand All @@ -173,10 +173,10 @@ contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
vm.expectEmit(address(axelarAdaptor));
emit AxelarMessage(childBridge.rootChain(), childBridge.rootERC20BridgeAdaptor(), predictedPayload);

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
}

function test_WithdrawToIMXWithDifferentAccount_EmitsAxelarMessageEvent() public {
function test_withdrawIMXToWithDifferentAccount_EmitsAxelarMessageEvent() public {
address receiver = address(0xabcd);
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;
Expand All @@ -187,17 +187,17 @@ contract ChildERC20BridgeWithdrawToIMXIntegrationTest is
vm.expectEmit(address(axelarAdaptor));
emit AxelarMessage(childBridge.rootChain(), childBridge.rootERC20BridgeAdaptor(), predictedPayload);

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
}

function test_WithdrawToIMX_ReducesBalance() public {
function test_withdrawIMXTo_ReducesBalance() public {
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;

uint256 preBal = address(this).balance;
uint256 preGasBal = address(axelarGasService).balance;

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);

uint256 postBal = address(this).balance;
uint256 postGasBal = address(axelarGasService).balance;
Expand Down
28 changes: 14 additions & 14 deletions test/unit/child/withdrawals/ChildERC20BridgeWithdrawToIMX.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {ChildERC20} from "../../../../src/child/ChildERC20.sol";
import {MockAdaptor} from "../../../../src/test/root/MockAdaptor.sol";
import {Utils} from "../../../utils.t.sol";

contract ChildERC20BridgeWithdrawToIMXUnitTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils {
contract ChildERC20BridgewithdrawIMXToUnitTest is Test, IChildERC20BridgeEvents, IChildERC20BridgeErrors, Utils {
address constant ROOT_BRIDGE = address(3);
string public ROOT_BRIDGE_ADAPTOR = Strings.toHexString(address(4));
string constant ROOT_CHAIN_NAME = "test";
Expand All @@ -41,21 +41,21 @@ contract ChildERC20BridgeWithdrawToIMXUnitTest is Test, IChildERC20BridgeEvents,
);
}

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

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

function test_RevertIf_ZeroAmountIsProvided() public {
uint256 withdrawFee = 300;

vm.expectRevert(ZeroAmount.selector);
childBridge.withdrawToIMX{value: withdrawFee}(address(this), 0);
childBridge.withdrawIMXTo{value: withdrawFee}(address(this), 0);
}

function test_WithdrawToIMX_CallsBridgeAdaptor() public {
function test_withdrawIMXTo_CallsBridgeAdaptor() public {
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;

Expand All @@ -67,10 +67,10 @@ contract ChildERC20BridgeWithdrawToIMXUnitTest is Test, IChildERC20BridgeEvents,
withdrawFee,
abi.encodeWithSelector(mockAdaptor.sendMessage.selector, predictedPayload, address(this))
);
childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
}

function test_WithdrawToIMXWithDifferentAccount_CallsBridgeAdaptor() public {
function test_withdrawIMXToWithDifferentAccount_CallsBridgeAdaptor() public {
address receiver = address(0xabcd);
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;
Expand All @@ -83,26 +83,26 @@ contract ChildERC20BridgeWithdrawToIMXUnitTest is Test, IChildERC20BridgeEvents,
withdrawFee,
abi.encodeWithSelector(mockAdaptor.sendMessage.selector, predictedPayload, address(this))
);
childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
}

function test_WithdrawToIMX_EmitsNativeIMXWithdrawEvent() public {
function test_withdrawIMXTo_EmitsNativeIMXWithdrawEvent() public {
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;

vm.expectEmit(address(childBridge));
emit ChildChainNativeIMXWithdraw(ROOT_IMX_TOKEN, address(this), address(this), withdrawAmount);
childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
}

function test_WithdrawToIMXWithDifferentAccount_EmitsNativeIMXWithdrawEvent() public {
function test_withdrawIMXToWithDifferentAccount_EmitsNativeIMXWithdrawEvent() public {
address receiver = address(0xabcd);
uint256 withdrawFee = 300;
uint256 withdrawAmount = 7 ether;

vm.expectEmit(address(childBridge));
emit ChildChainNativeIMXWithdraw(ROOT_IMX_TOKEN, address(this), receiver, withdrawAmount);
childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(receiver, withdrawAmount);
}

function test_WithdrawIMX_ReducesBalance() public {
Expand All @@ -111,7 +111,7 @@ contract ChildERC20BridgeWithdrawToIMXUnitTest is Test, IChildERC20BridgeEvents,

uint256 preBal = address(this).balance;

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);

uint256 postBal = address(this).balance;
assertEq(postBal, preBal - withdrawAmount - withdrawFee, "Balance not reduced");
Expand All @@ -123,7 +123,7 @@ contract ChildERC20BridgeWithdrawToIMXUnitTest is Test, IChildERC20BridgeEvents,

uint256 preBal = address(mockAdaptor).balance;

childBridge.withdrawToIMX{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);
childBridge.withdrawIMXTo{value: withdrawFee + withdrawAmount}(address(this), withdrawAmount);

uint256 postBal = address(mockAdaptor).balance;
assertEq(postBal, preBal + withdrawFee, "Adaptor balance not increased");
Expand Down

0 comments on commit 0044293

Please sign in to comment.