From d9450692fd44948513caf37132a1a5ea4f9da4a0 Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Thu, 21 Dec 2023 01:01:41 +0200 Subject: [PATCH] pr feedback --- Cargo.lock | 3 - .../bridges/bridge-hub-rococo/Cargo.toml | 3 - .../bridge-hub-rococo/src/tests/snowbridge.rs | 55 ++++++------------- 3 files changed, 17 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54fdebe1c675..382fb942aa1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1989,11 +1989,9 @@ dependencies = [ name = "bridge-hub-rococo-integration-tests" version = "1.0.0" dependencies = [ - "asset-hub-rococo-emulated-chain", "asset-hub-rococo-runtime", "asset-test-utils", "bp-messages", - "bridge-hub-rococo-emulated-chain", "bridge-hub-rococo-runtime", "cumulus-pallet-dmp-queue", "cumulus-pallet-xcmp-queue", @@ -2008,7 +2006,6 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", - "penpal-emulated-chain", "penpal-runtime", "rococo-system-emulated-network", "rococo-westend-system-emulated-network", diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml index 53b667e63402..ba31cf68b56f 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml @@ -41,9 +41,6 @@ cumulus-pallet-dmp-queue = { path = "../../../../../../pallets/dmp-queue", defau bridge-hub-rococo-runtime = { path = "../../../../../../parachains/runtimes/bridge-hubs/bridge-hub-rococo", default-features = false } emulated-integration-tests-common = { path = "../../../common", default-features = false } rococo-westend-system-emulated-network = { path = "../../../networks/rococo-westend-system" } -bridge-hub-rococo-emulated-chain = { path = "../../../chains/parachains/bridges/bridge-hub-rococo" } -asset-hub-rococo-emulated-chain = { path = "../../../chains/parachains/assets/asset-hub-rococo" } -penpal-emulated-chain = { path = "../../../chains/parachains/testing/penpal" } penpal-runtime = { path = "../../../../../runtimes/testing/penpal", default-features = false } rococo-system-emulated-network = { path = "../../../networks/rococo-system" } asset-hub-rococo-runtime = { path = "../../../../../runtimes/assets/asset-hub-rococo", default-features = false } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 763b16fdaab6..e62a73caff58 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -13,14 +13,15 @@ // See the License for the specific language governing permissions and // limitations under the License. use crate::*; -use asset_hub_rococo_emulated_chain::AssetHubRococoParaPallet as AssetHubRococoPallet; -use bridge_hub_rococo_emulated_chain::BridgeHubRococoParaPallet as BridgeHubRococoPallet; use codec::{Decode, Encode}; +use emulated_integration_tests_common::xcm_emulator::ConvertLocation; use frame_support::pallet_prelude::TypeInfo; use hex_literal::hex; use snowbridge_core::outbound::OperatingMode; use snowbridge_rococo_common::EthereumNetwork; -use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage}; +use snowbridge_router_primitives::inbound::{ + Command, Destination, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage, +}; use snowbridge_system; use sp_core::H256; @@ -51,13 +52,7 @@ pub enum SnowbridgeControl { fn create_agent() { let origin_para: u32 = 1001; - BridgeHubRococo::fund_accounts(vec![( - BridgeHubRococo::sovereign_account_id_of(MultiLocation { - parents: 1, - interior: X1(Parachain(origin_para)), - }), - INITIAL_FUND, - )]); + BridgeHubRococo::fund_para_sovereign(origin_para.into(), INITIAL_FUND); let sudo_origin = ::RuntimeOrigin::root(); let destination = Rococo::child_location_of(BridgeHubRococo::para_id()).into(); @@ -111,12 +106,7 @@ fn create_agent() { fn create_channel() { let origin_para: u32 = 1001; - let source_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para)) }; - - BridgeHubRococo::fund_accounts(vec![( - BridgeHubRococo::sovereign_account_id_of(source_location), - INITIAL_FUND, - )]); + BridgeHubRococo::fund_para_sovereign(origin_para.into(), INITIAL_FUND); let sudo_origin = ::RuntimeOrigin::root(); let destination: VersionedMultiLocation = @@ -187,14 +177,8 @@ fn create_channel() { } #[test] -fn register_token() { - BridgeHubRococo::fund_accounts(vec![( - BridgeHubRococo::sovereign_account_id_of(MultiLocation { - parents: 1, - interior: X1(Parachain(AssetHubRococo::para_id().into())), - }), - INITIAL_FUND, - )]); +fn register_weth_token_from_ethereum_to_asset_hub() { + BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id().into(), INITIAL_FUND); let message_id_: H256 = [1; 32].into(); @@ -230,7 +214,7 @@ fn register_token() { } #[test] -fn send_token_to_penpal() { +fn send_token_from_ethereum_to_penpal() { let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation { parents: 1, interior: X1(Parachain(AssetHubRococo::para_id().into())), @@ -246,13 +230,14 @@ fn send_token_to_penpal() { (Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH }).into(); let weth_asset_id = weth_asset_location.into(); - let origin_location = - MultiLocation { parents: 2, interior: weth_asset_location.interior.split_last().0 }; + let origin_location = (Parent, Parent, EthereumNetwork::get()).into(); // Fund ethereum sovereign in asset hub let ethereum_sovereign: AccountId = - hex!("ce796ae65569a670d0c1cc1ac12515a3ce21b5fbf729d63d7b289baad070139d").into(); + GlobalConsensusEthereumConvertsFor::::convert_location(&origin_location) + .unwrap(); AssetHubRococo::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]); + // Create asset on assethub. AssetHubRococo::execute_with(|| { assert_ok!(::ForeignAssets::create( @@ -334,14 +319,8 @@ fn send_token_to_penpal() { } #[test] -fn send_token() { - BridgeHubRococo::fund_accounts(vec![( - BridgeHubRococo::sovereign_account_id_of(MultiLocation { - parents: 1, - interior: X1(Parachain(AssetHubRococo::para_id().into())), - }), - INITIAL_FUND, - )]); +fn send_token_from_ethereum_to_asset_hub() { + BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id().into(), INITIAL_FUND); // Fund ethereum sovereign in asset hub AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); @@ -391,7 +370,7 @@ fn send_token() { } #[test] -fn reserve_transfer_token() { +fn send_weth_asset_from_asset_hub_to_ethereum() { use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee; let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation { parents: 1, @@ -520,7 +499,7 @@ fn reserve_transfer_token() { RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount }) if *who == assethub_sovereign && *amount == 2680000000000, )), - "Assethub sovereign takes remote fee." + "AssetHub sovereign takes remote fee." ); }); }