Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
proletesseract committed Oct 24, 2023
1 parent 108abc4 commit abc5c4f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
6 changes: 1 addition & 5 deletions script/InitializeRootContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ contract InitializeRootContracts is Script {
vm.startBroadcast(rootPrivateKey);

rootERC20Bridge.initialize(
address(rootBridgeAdaptor),
childERC20Bridge,
childBridgeAdaptor,
rootChainChildTokenTemplate,
rootIMXToken
address(rootBridgeAdaptor), childERC20Bridge, childBridgeAdaptor, rootChainChildTokenTemplate, rootIMXToken
);

rootBridgeAdaptor.setChildBridgeAdaptor();
Expand Down
19 changes: 12 additions & 7 deletions test/integration/root/RootERC20Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx

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

console2.logBytes(predictedPayload);

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

vm.expectCall(
address(axelarAdaptor),
Expand Down Expand Up @@ -149,7 +151,7 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx
// 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(thisNativePreBal - (depositFee + tokenAmount), address(this).balance, "ETH not paid from user");
assertEq(gasServiceNativePreBal + depositFee, address(axelarGasService).balance, "ETH not paid to adaptor");
}

Expand All @@ -158,9 +160,10 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx
uint256 tokenAmount = 300;
string memory childBridgeAdaptorString = Strings.toHexString(CHILD_BRIDGE_ADAPTOR);

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

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

vm.expectEmit(address(axelarAdaptor));
emit MapTokenAxelarMessage(CHILD_CHAIN_NAME, childBridgeAdaptorString, predictedPayload);
vm.expectEmit(address(rootBridge));
Expand Down Expand Up @@ -203,7 +206,9 @@ contract RootERC20BridgeIntegrationTest is Test, IRootERC20BridgeEvents, IRootAx

// 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");
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");
Expand Down
8 changes: 2 additions & 6 deletions test/unit/root/RootERC20Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid
mockAxelarAdaptor = new MockAdaptor();

// The specific ERC20 token template does not matter for these unit tests
rootBridge.initialize(
address(mockAxelarAdaptor), CHILD_BRIDGE, CHILD_BRIDGE_ADAPTOR, address(token), IMX_TOKEN
);
rootBridge.initialize(address(mockAxelarAdaptor), CHILD_BRIDGE, CHILD_BRIDGE_ADAPTOR, address(token), IMX_TOKEN);
}

/**
Expand All @@ -59,9 +57,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid

function test_RevertIfInitializeTwice() public {
vm.expectRevert("Initializable: contract is already initialized");
rootBridge.initialize(
address(mockAxelarAdaptor), CHILD_BRIDGE, CHILD_BRIDGE_ADAPTOR, address(token), IMX_TOKEN
);
rootBridge.initialize(address(mockAxelarAdaptor), CHILD_BRIDGE, CHILD_BRIDGE_ADAPTOR, address(token), IMX_TOKEN);
}

function test_RevertIf_InitializeWithAZeroAddressRootAdapter() public {
Expand Down
5 changes: 1 addition & 4 deletions test/utils.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ contract Utils is Test {
token = new ERC20PresetMinterPauser("Test", "TST");
token.mint(address(this), 1000000 ether);


deployCodeTo("ERC20PresetMinterPauser.sol", abi.encode("ImmutableX", "IMX"), imxTokenAddress);
imxToken = ERC20PresetMinterPauser(imxTokenAddress);
imxToken.mint(address(this), 1000000 ether);
Expand All @@ -47,9 +46,7 @@ contract Utils is Test {
address(axelarGasService)
);

rootBridge.initialize(
address(axelarAdaptor), childBridge, childBridgeAdaptor, address(token), imxTokenAddress
);
rootBridge.initialize(address(axelarAdaptor), childBridge, childBridgeAdaptor, address(token), imxTokenAddress);
axelarAdaptor.setChildBridgeAdaptor();
}

Expand Down

0 comments on commit abc5c4f

Please sign in to comment.