From f7622714ad3e7091478cf98abedae17146a24ec8 Mon Sep 17 00:00:00 2001 From: wcgcyx Date: Mon, 11 Dec 2023 12:21:11 +0800 Subject: [PATCH] Update tests --- test/unit/root/RootERC20Bridge.t.sol | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/unit/root/RootERC20Bridge.t.sol b/test/unit/root/RootERC20Bridge.t.sol index 586cef74..fb4e7946 100644 --- a/test/unit/root/RootERC20Bridge.t.sol +++ b/test/unit/root/RootERC20Bridge.t.sol @@ -441,6 +441,32 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid rootBridge.mapToken{value: 300}(IERC20Metadata(NATIVE_ETH)); } + function test_SucceedIf_mapTokenWithSupportedMethods() public { + rootBridge.mapToken{value: 300}(token); + } + + function test_RevertIf_mapTokenWithoutName() public { + vm.mockCallRevert(address(token), abi.encodeWithSelector(IERC20Metadata.name.selector), "Unsupported operation"); + vm.expectRevert(NotSupportedToken.selector); + rootBridge.mapToken{value: 300}(token); + } + + function test_RevertIf_mapTokenWithoutSymbol() public { + vm.mockCallRevert( + address(token), abi.encodeWithSelector(IERC20Metadata.symbol.selector), "Unsupported operation" + ); + vm.expectRevert(NotSupportedToken.selector); + rootBridge.mapToken{value: 300}(token); + } + + function test_RevertIf_mapTokenWithoutDecimals() public { + vm.mockCallRevert( + address(token), abi.encodeWithSelector(IERC20Metadata.decimals.selector), "Unsupported operation" + ); + vm.expectRevert(NotSupportedToken.selector); + rootBridge.mapToken{value: 300}(token); + } + function test_updateRootBridgeAdaptor_UpdatesRootBridgeAdaptor() public { address newAdaptorAddress = address(0x11111);