Skip to content

Commit

Permalink
Address PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjimmutable committed Nov 3, 2023
1 parent 024b4d9 commit ff6b92d
Showing 1 changed file with 0 additions and 355 deletions.
355 changes: 0 additions & 355 deletions test/integration/child/withdrawals/ChildAxelarBridgeWithdraw.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,359 +138,4 @@ contract ChildERC20BridgeWithdrawIntegrationTest is
vm.expectRevert(NoGas.selector);
childBridge.withdraw(childToken, withdrawAmount);
}

// 7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e982869
// 000000000000000000000000000000000000000000000000000000000000ad9c
// 0000000000000000000000007fa9385be102ac3eac297483dd6233d62b3e1496
// 0000000000000000000000007fa9385be102ac3eac297483dd6233d62b3e1496
// 000000000000000000000000000000000000000000000000000000174876e7ff
// 0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496

// f20755ba
// 0000000000000000000000000000000000000000000000000000000000000040
// 0000000000000000000000007fa9385be102ac3eac297483dd6233d62b3e1496
// 00000000000000000000000000000000000000000000000000000000000000a0
// 2cef46a936bdc5b7e6e8c71aa04560c41cf7d88bb26901a7e7f4936ff02accad
// 000000000000000000000000000000000000000000000000000000000000ad9c
// 0000000000000000000000007fa9385be102ac3eac297483dd6233d62b3e1496
// 0000000000000000000000007fa9385be102ac3eac297483dd6233d62b3e1496
// 000000000000000000000000000000000000000000000000000000174876e7ff

// bytes memory payload = abi.encode(MAP_TOKEN_SIG, address(token), token.name(), token.symbol(), token.decimals());
// vm.expectEmit(true, true, true, false, address(axelarAdaptor));
// emit AxelarMessage(CHILD_CHAIN_NAME, Strings.toHexString(CHILD_BRIDGE_ADAPTOR), payload);

// vm.expectEmit(true, true, false, false, address(rootBridge));
// emit L1TokenMapped(address(token), childToken);

// // Instead of using expectCalls, we could use expectEmit in combination with mock contracts emitting events.
// // expectCalls requires less boilerplate and is less dependant on mock code.
// vm.expectCall(
// address(axelarAdaptor),
// mapTokenFee,
// abi.encodeWithSelector(axelarAdaptor.sendMessage.selector, payload, address(this))
// );

// // These are calls that the axelarAdaptor should make.
// vm.expectCall(
// address(axelarGasService),
// mapTokenFee,
// abi.encodeWithSelector(
// axelarGasService.payNativeGasForContractCall.selector,
// address(axelarAdaptor),
// CHILD_CHAIN_NAME,
// Strings.toHexString(CHILD_BRIDGE_ADAPTOR),
// payload,
// address(this)
// )
// );

// vm.expectCall(
// address(mockAxelarGateway),
// 0,
// abi.encodeWithSelector(
// mockAxelarGateway.callContract.selector,
// CHILD_CHAIN_NAME,
// Strings.toHexString(CHILD_BRIDGE_ADAPTOR),
// payload
// )
// );

// // Check that we pay mapTokenFee to the axelarGasService.
// uint256 thisPreBal = address(this).balance;
// uint256 axelarGasServicePreBal = address(axelarGasService).balance;

// rootBridge.mapToken{value: mapTokenFee}(token);

// // Should update ETH balances as gas payment for message.
// assertEq(address(this).balance, thisPreBal - mapTokenFee, "ETH balance not decreased");
// assertEq(address(axelarGasService).balance, axelarGasServicePreBal + mapTokenFee, "ETH not paid to gas service");

// assertEq(rootBridge.rootTokenToChildToken(address(token)), childToken, "childToken not set");
// }

// // TODO split into multiple tests
// function test_depositETH() public {
// uint256 tokenAmount = 300;
// string memory childBridgeAdaptorString = Strings.toHexString(CHILD_BRIDGE_ADAPTOR);

// (, bytes memory predictedPayload) =
// setupDeposit(NATIVE_ETH, rootBridge, mapTokenFee, depositFee, tokenAmount, false);

// console2.logBytes(predictedPayload);

// vm.expectEmit(address(axelarAdaptor));
// emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
// vm.expectEmit(address(rootBridge));
// emit NativeEthDeposit(
// address(NATIVE_ETH), rootBridge.childETHToken(), address(this), address(this), tokenAmount
// );

// vm.expectCall(
// address(axelarAdaptor),
// depositFee,
// abi.encodeWithSelector(axelarAdaptor.sendMessage.selector, predictedPayload, address(this))
// );

// vm.expectCall(
// address(axelarGasService),
// depositFee,
// abi.encodeWithSelector(
// axelarGasService.payNativeGasForContractCall.selector,
// address(axelarAdaptor),
// CHILD_CHAIN_NAME,
// childBridgeAdaptorString,
// predictedPayload,
// address(this)
// )
// );

// vm.expectCall(
// address(mockAxelarGateway),
// 0,
// abi.encodeWithSelector(
// mockAxelarGateway.callContract.selector, CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload
// )
// );

// uint256 bridgePreBal = address(rootBridge).balance;

// uint256 thisNativePreBal = address(this).balance;
// uint256 gasServiceNativePreBal = address(axelarGasService).balance;

// rootBridge.depositETH{value: tokenAmount + depositFee}(tokenAmount);

// // Check that tokens are transferred
// assertEq(bridgePreBal + tokenAmount, address(rootBridge).balance, "ETH not transferred to bridge");
// // Check that native asset transferred to gas service
// assertEq(thisNativePreBal - (depositFee + tokenAmount), address(this).balance, "ETH not paid from user");
// assertEq(gasServiceNativePreBal + depositFee, address(axelarGasService).balance, "ETH not paid to adaptor");
// }

// // TODO split into multiple tests
// function test_depositIMXToken() public {
// uint256 tokenAmount = 300;
// string memory childBridgeAdaptorString = Strings.toHexString(CHILD_BRIDGE_ADAPTOR);

// (, bytes memory predictedPayload) =
// setupDeposit(IMX_TOKEN_ADDRESS, rootBridge, mapTokenFee, depositFee, tokenAmount, false);

// vm.expectEmit(address(axelarAdaptor));
// emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
// vm.expectEmit(address(rootBridge));
// emit IMXDeposit(address(IMX_TOKEN_ADDRESS), address(this), address(this), tokenAmount);

// vm.expectCall(
// address(axelarAdaptor),
// depositFee,
// abi.encodeWithSelector(axelarAdaptor.sendMessage.selector, predictedPayload, address(this))
// );

// vm.expectCall(
// address(axelarGasService),
// depositFee,
// abi.encodeWithSelector(
// axelarGasService.payNativeGasForContractCall.selector,
// address(axelarAdaptor),
// CHILD_CHAIN_NAME,
// childBridgeAdaptorString,
// predictedPayload,
// address(this)
// )
// );

// vm.expectCall(
// address(mockAxelarGateway),
// 0,
// abi.encodeWithSelector(
// mockAxelarGateway.callContract.selector, CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload
// )
// );

// uint256 thisPreBal = imxToken.balanceOf(address(this));
// uint256 bridgePreBal = imxToken.balanceOf(address(rootBridge));

// uint256 thisNativePreBal = address(this).balance;
// uint256 gasServiceNativePreBal = address(axelarGasService).balance;

// rootBridge.deposit{value: depositFee}(IERC20Metadata(IMX_TOKEN_ADDRESS), tokenAmount);

// // Check that tokens are transferred
// assertEq(thisPreBal - tokenAmount, imxToken.balanceOf(address(this)), "Tokens not transferred from user");
// assertEq(
// bridgePreBal + tokenAmount, imxToken.balanceOf(address(rootBridge)), "Tokens not transferred to bridge"
// );
// // Check that native asset transferred to gas service
// assertEq(thisNativePreBal - depositFee, address(this).balance, "ETH not paid from user");
// assertEq(gasServiceNativePreBal + depositFee, address(axelarGasService).balance, "ETH not paid to adaptor");
// }

// // TODO split into multiple tests
// function test_depositWETH() public {
// uint256 tokenAmount = 300;
// string memory childBridgeAdaptorString = Strings.toHexString(CHILD_BRIDGE_ADAPTOR);
// (, bytes memory predictedPayload) =
// setupDeposit(WRAPPED_ETH, rootBridge, mapTokenFee, depositFee, tokenAmount, false);

// vm.expectEmit(address(axelarAdaptor));
// emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
// vm.expectEmit(address(rootBridge));
// emit WETHDeposit(address(WRAPPED_ETH), rootBridge.childETHToken(), address(this), address(this), tokenAmount);
// vm.expectCall(
// address(axelarAdaptor),
// depositFee,
// abi.encodeWithSelector(axelarAdaptor.sendMessage.selector, predictedPayload, address(this))
// );

// vm.expectCall(
// address(axelarGasService),
// depositFee,
// abi.encodeWithSelector(
// axelarGasService.payNativeGasForContractCall.selector,
// address(axelarAdaptor),
// CHILD_CHAIN_NAME,
// childBridgeAdaptorString,
// predictedPayload,
// address(this)
// )
// );

// vm.expectCall(
// address(mockAxelarGateway),
// 0,
// abi.encodeWithSelector(
// mockAxelarGateway.callContract.selector, CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload
// )
// );

// uint256 thisPreBal = IERC20Metadata(WRAPPED_ETH).balanceOf(address(this));
// uint256 bridgePreBal = address(rootBridge).balance;

// uint256 thisNativePreBal = address(this).balance;
// uint256 gasServiceNativePreBal = address(axelarGasService).balance;

// rootBridge.deposit{value: depositFee}(IERC20Metadata(WRAPPED_ETH), tokenAmount);

// // Check that tokens are transferred
// assertEq(
// thisPreBal - tokenAmount,
// IERC20Metadata(WRAPPED_ETH).balanceOf(address(this)),
// "Tokens not transferred from user"
// );
// assertEq(bridgePreBal + tokenAmount, address(rootBridge).balance, "ETH not transferred to Bridge");
// // Check that native asset transferred to gas service
// assertEq(thisNativePreBal - depositFee, address(this).balance, "ETH for fee not paid from user");
// assertEq(gasServiceNativePreBal + depositFee, address(axelarGasService).balance, "ETH not paid to adaptor");
// }

// // TODO split into multiple tests
// function test_depositToken() public {
// uint256 tokenAmount = 300;
// string memory childBridgeAdaptorString = Strings.toHexString(CHILD_BRIDGE_ADAPTOR);
// (address childToken, bytes memory predictedPayload) =
// setupDeposit(address(token), rootBridge, mapTokenFee, depositFee, tokenAmount, true);

// vm.expectEmit(address(axelarAdaptor));
// emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
// vm.expectEmit(address(rootBridge));
// emit ChildChainERC20Deposit(address(token), childToken, address(this), address(this), tokenAmount);

// vm.expectCall(
// address(axelarAdaptor),
// depositFee,
// abi.encodeWithSelector(axelarAdaptor.sendMessage.selector, predictedPayload, address(this))
// );

// vm.expectCall(
// address(axelarGasService),
// depositFee,
// abi.encodeWithSelector(
// axelarGasService.payNativeGasForContractCall.selector,
// address(axelarAdaptor),
// CHILD_CHAIN_NAME,
// childBridgeAdaptorString,
// predictedPayload,
// address(this)
// )
// );

// vm.expectCall(
// address(mockAxelarGateway),
// 0,
// abi.encodeWithSelector(
// mockAxelarGateway.callContract.selector, CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload
// )
// );

// uint256 thisPreBal = token.balanceOf(address(this));
// uint256 bridgePreBal = token.balanceOf(address(rootBridge));

// uint256 thisNativePreBal = address(this).balance;
// uint256 gasServiceNativePreBal = address(axelarGasService).balance;

// rootBridge.deposit{value: depositFee}(token, tokenAmount);

// // Check that tokens are transferred
// assertEq(thisPreBal - tokenAmount, token.balanceOf(address(this)), "Tokens not transferred from user");
// assertEq(bridgePreBal + tokenAmount, token.balanceOf(address(rootBridge)), "Tokens not transferred to bridge");
// // Check that native asset transferred to gas service
// assertEq(thisNativePreBal - depositFee, address(this).balance, "ETH not paid from user");
// assertEq(gasServiceNativePreBal + depositFee, address(axelarGasService).balance, "ETH not paid to adaptor");
// }

// // TODO split into multiple tests
// function test_depositTo() public {
// uint256 tokenAmount = 300;
// address recipient = address(9876);
// string memory childBridgeAdaptorString = Strings.toHexString(CHILD_BRIDGE_ADAPTOR);
// (address childToken, bytes memory predictedPayload) =
// setupDepositTo(address(token), rootBridge, mapTokenFee, depositFee, tokenAmount, recipient, true);

// vm.expectEmit(address(axelarAdaptor));
// emit AxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
// vm.expectEmit(address(rootBridge));
// emit ChildChainERC20Deposit(address(token), childToken, address(this), recipient, tokenAmount);

// vm.expectCall(
// address(axelarAdaptor),
// depositFee,
// abi.encodeWithSelector(axelarAdaptor.sendMessage.selector, predictedPayload, address(this))
// );

// vm.expectCall(
// address(axelarGasService),
// depositFee,
// abi.encodeWithSelector(
// axelarGasService.payNativeGasForContractCall.selector,
// address(axelarAdaptor),
// CHILD_CHAIN_NAME,
// childBridgeAdaptorString,
// predictedPayload,
// address(this)
// )
// );

// vm.expectCall(
// address(mockAxelarGateway),
// 0,
// abi.encodeWithSelector(
// mockAxelarGateway.callContract.selector, CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload
// )
// );

// uint256 thisPreBal = token.balanceOf(address(this));
// uint256 bridgePreBal = token.balanceOf(address(rootBridge));

// uint256 thisNativePreBal = address(this).balance;
// uint256 gasServiceNativePreBal = address(axelarGasService).balance;

// rootBridge.depositTo{value: depositFee}(token, recipient, tokenAmount);

// // Check that tokens are transferred
// assertEq(thisPreBal - tokenAmount, token.balanceOf(address(this)), "Tokens not transferred from user");
// assertEq(bridgePreBal + tokenAmount, token.balanceOf(address(rootBridge)), "Tokens not transferred to bridge");
// // Check that native asset transferred to gas service
// assertEq(thisNativePreBal - depositFee, address(this).balance, "ETH not paid from user");
// assertEq(gasServiceNativePreBal + depositFee, address(axelarGasService).balance, "ETH not paid to adaptor");
// }
}

0 comments on commit ff6b92d

Please sign in to comment.