From 9cd3d64f9a6b20f7dbb2895afb4f22907a369d42 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Sun, 28 Apr 2024 13:33:56 +0200 Subject: [PATCH] enable CrossChainCommunicationSettingsTest --- tests/CrossChainCommunicationSettings.t.sol | 250 ++++++++++---------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/tests/CrossChainCommunicationSettings.t.sol b/tests/CrossChainCommunicationSettings.t.sol index 46335253..239b892a 100644 --- a/tests/CrossChainCommunicationSettings.t.sol +++ b/tests/CrossChainCommunicationSettings.t.sol @@ -100,128 +100,128 @@ contract BaseCCCommunicationTest is Test { } } -// contract CrossChainCommunicationSettingsTest is BaseCCCommunicationTest { -// function test_Eth_Eth_Path() public { -// vm.selectFork(ethFork); -// // get bridge adapters configured for the same chain path -// ICrossChainForwarder.ChainIdBridgeConfig[] memory adaptersByChain = ICrossChainForwarder( -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER -// ).getForwarderBridgeAdaptersByChain(ChainIds.ETHEREUM); - -// // there should only be one bridge adapter configured for same chain path -// assertEq(adaptersByChain.length, 1); - -// // for same chain path, origin and destination bridge adapter must be the same. -// assertEq( -// adaptersByChain[0].currentChainBridgeAdapter, -// adaptersByChain[0].destinationBridgeAdapter -// ); - -// // same chain bridge adapter has no trusted remotes, as communication is direct (it only forwards messages) -// assertEq( -// BaseAdapter(adaptersByChain[0].currentChainBridgeAdapter).getTrustedRemoteByChainId( -// ChainIds.ETHEREUM -// ), -// address(0) -// ); -// } - -// function test_Eth_Pol_Path() public { -// _checkPath( -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, -// GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, -// ChainIds.ETHEREUM, -// ChainIds.POLYGON, -// ethFork, -// polFork -// ); -// } - -// function test_Pol_Eth_Path() public { -// _checkPath( -// GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, -// ChainIds.POLYGON, -// ChainIds.ETHEREUM, -// polFork, -// ethFork -// ); -// } - -// function test_Eth_Avax_Path() public { -// _checkPath( -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, -// GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, -// ChainIds.ETHEREUM, -// ChainIds.AVALANCHE, -// ethFork, -// avaxFork -// ); -// } - -// function test_Avax_Eth_Path() public { -// _checkPath( -// GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, -// ChainIds.AVALANCHE, -// ChainIds.ETHEREUM, -// avaxFork, -// ethFork -// ); -// } - -// function test_Eth_Op_Path() public { -// _checkPath( -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, -// GovernanceV3Optimism.CROSS_CHAIN_CONTROLLER, -// ChainIds.ETHEREUM, -// ChainIds.OPTIMISM, -// ethFork, -// opFork -// ); -// } - -// function test_Eth_Arb_Path() public { -// _checkPath( -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, -// GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER, -// ChainIds.ETHEREUM, -// ChainIds.ARBITRUM, -// ethFork, -// arbFork -// ); -// } - -// function test_Eth_Base_Path() public { -// _checkPath( -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, -// GovernanceV3Base.CROSS_CHAIN_CONTROLLER, -// ChainIds.ETHEREUM, -// ChainIds.BASE, -// ethFork, -// baseFork -// ); -// } - -// function test_Eth_BNB_Path() public { -// _checkPath( -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, -// GovernanceV3Binance.CROSS_CHAIN_CONTROLLER, -// ChainIds.ETHEREUM, -// ChainIds.BNB, -// ethFork, -// bnbFork -// ); -// } - -// function test_Eth_Metis_Path() public { -// _checkPath( -// GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, -// GovernanceV3Metis.CROSS_CHAIN_CONTROLLER, -// ChainIds.ETHEREUM, -// ChainIds.METIS, -// ethFork, -// metisFork -// ); -// } -// } +contract CrossChainCommunicationSettingsTest is BaseCCCommunicationTest { + function test_Eth_Eth_Path() public { + vm.selectFork(ethFork); + // get bridge adapters configured for the same chain path + ICrossChainForwarder.ChainIdBridgeConfig[] memory adaptersByChain = ICrossChainForwarder( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER + ).getForwarderBridgeAdaptersByChain(ChainIds.ETHEREUM); + + // there should only be one bridge adapter configured for same chain path + assertEq(adaptersByChain.length, 1); + + // for same chain path, origin and destination bridge adapter must be the same. + assertEq( + adaptersByChain[0].currentChainBridgeAdapter, + adaptersByChain[0].destinationBridgeAdapter + ); + + // same chain bridge adapter has no trusted remotes, as communication is direct (it only forwards messages) + assertEq( + BaseAdapter(adaptersByChain[0].currentChainBridgeAdapter).getTrustedRemoteByChainId( + ChainIds.ETHEREUM + ), + address(0) + ); + } + + function test_Eth_Pol_Path() public { + _checkPath( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, + ChainIds.ETHEREUM, + ChainIds.POLYGON, + ethFork, + polFork + ); + } + + function test_Pol_Eth_Path() public { + _checkPath( + GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + ChainIds.POLYGON, + ChainIds.ETHEREUM, + polFork, + ethFork + ); + } + + function test_Eth_Avax_Path() public { + _checkPath( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, + ChainIds.ETHEREUM, + ChainIds.AVALANCHE, + ethFork, + avaxFork + ); + } + + function test_Avax_Eth_Path() public { + _checkPath( + GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + ChainIds.AVALANCHE, + ChainIds.ETHEREUM, + avaxFork, + ethFork + ); + } + + function test_Eth_Op_Path() public { + _checkPath( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + GovernanceV3Optimism.CROSS_CHAIN_CONTROLLER, + ChainIds.ETHEREUM, + ChainIds.OPTIMISM, + ethFork, + opFork + ); + } + + function test_Eth_Arb_Path() public { + _checkPath( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER, + ChainIds.ETHEREUM, + ChainIds.ARBITRUM, + ethFork, + arbFork + ); + } + + function test_Eth_Base_Path() public { + _checkPath( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + GovernanceV3Base.CROSS_CHAIN_CONTROLLER, + ChainIds.ETHEREUM, + ChainIds.BASE, + ethFork, + baseFork + ); + } + + function test_Eth_BNB_Path() public { + _checkPath( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + GovernanceV3Binance.CROSS_CHAIN_CONTROLLER, + ChainIds.ETHEREUM, + ChainIds.BNB, + ethFork, + bnbFork + ); + } + + function test_Eth_Metis_Path() public { + _checkPath( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + GovernanceV3Metis.CROSS_CHAIN_CONTROLLER, + ChainIds.ETHEREUM, + ChainIds.METIS, + ethFork, + metisFork + ); + } +}