Skip to content

Commit

Permalink
integration tests for IMX and Native events
Browse files Browse the repository at this point in the history
  • Loading branch information
proletesseract committed Oct 24, 2023
1 parent c597a9f commit eb4134e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/integration/child/ChildAxelarBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit eb4134e

Please sign in to comment.