From eb4134ed3d99d9d091ca38acfc75e365db5dc7ed Mon Sep 17 00:00:00 2001 From: Craig M Date: Tue, 24 Oct 2023 15:13:35 +1300 Subject: [PATCH] integration tests for IMX and Native events --- .../integration/child/ChildAxelarBridge.t.sol | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/integration/child/ChildAxelarBridge.t.sol b/test/integration/child/ChildAxelarBridge.t.sol index d5c660b7..1bdbd36b 100644 --- a/test/integration/child/ChildAxelarBridge.t.sol +++ b/test/integration/child/ChildAxelarBridge.t.sol @@ -19,6 +19,7 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil string public ROOT_ADAPTOR_ADDRESS = Strings.toHexString(address(1)); string public ROOT_CHAIN_NAME = "ROOT_CHAIN"; address constant IMX_TOKEN_ADDRESS = address(0xccc); + address constant NATIVE_ETH = address(0xeee); ChildERC20Bridge public childERC20Bridge; ChildERC20 public childERC20; @@ -147,6 +148,47 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil ); } + function test_deposit_EmitsNativeDeposit() public { + address sender = address(0xff); + address receiver = address(0xee); + uint256 amount = 100; + + address predictedChildETHToken = Clones.predictDeterministicAddress( + address(childERC20), keccak256(abi.encodePacked(NATIVE_ETH)), address(childERC20Bridge) + ); + + bytes32 commandId = bytes32("testCommandId"); + + vm.expectEmit(address(childERC20Bridge)); + emit NativeEthDeposit(NATIVE_ETH, predictedChildETHToken, sender, receiver, amount); + + childAxelarBridgeAdaptor.execute( + commandId, + ROOT_CHAIN_NAME, + ROOT_ADAPTOR_ADDRESS, + abi.encode(childERC20Bridge.DEPOSIT_SIG(), NATIVE_ETH, sender, receiver, amount) + ); + } + + function test_deposit_EmitsIMXDeposit() public { + address sender = address(0xff); + address receiver = address(0xee); + uint256 amount = 100; + bytes32 commandId = bytes32("testCommandId"); + + vm.deal(address(childERC20Bridge), 1 ether); + + vm.expectEmit(address(childERC20Bridge)); + emit IMXDeposit(IMX_TOKEN_ADDRESS, sender, receiver, amount); + + childAxelarBridgeAdaptor.execute( + commandId, + ROOT_CHAIN_NAME, + ROOT_ADAPTOR_ADDRESS, + abi.encode(childERC20Bridge.DEPOSIT_SIG(), IMX_TOKEN_ADDRESS, sender, receiver, amount) + ); + } + function test_deposit_TransfersTokenToReceiver() public { address rootTokenAddress = address(456); address sender = address(0xff);