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 5fdd7db17e69..21e63e81eb8b 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 @@ -31,6 +31,21 @@ const TREASURY_ACCOUNT: [u8; 32] = const WETH: [u8; 20] = hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d"); const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EBD0D8D2333700e"); +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +pub enum ControlCall { + #[codec(index = 2)] + CreateAgent, + #[codec(index = 3)] + CreateChannel { mode: OperatingMode, outbound_fee: u128 }, +} + +#[allow(clippy::large_enum_variant)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +pub enum SnowbridgeControl { + #[codec(index = 83)] + Control(ControlCall), +} + #[test] fn create_agent() { let origin_para: u32 = 1001; @@ -46,13 +61,15 @@ fn create_agent() { let sudo_origin = ::RuntimeOrigin::root(); let destination = Rococo::child_location_of(BridgeHubRococo::para_id()).into(); + let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {}); + let remote_xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, DescendOrigin(X1(Parachain(origin_para))), Transact { require_weight_at_most: 3000000000.into(), origin_kind: OriginKind::Xcm, - call: vec![63, 2].into(), + call: create_agent_call.encode().into(), }, ])); @@ -89,19 +106,6 @@ fn create_agent() { }); } -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub enum CreateChannelCall { - #[codec(index = 3)] - CreateChannel { mode: OperatingMode, outbound_fee: u128 }, -} - -#[allow(clippy::large_enum_variant)] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub enum SnowbridgeControl { - #[codec(index = 63)] - Control(CreateChannelCall), -} - #[test] fn create_channel() { let origin_para: u32 = 1001; @@ -117,17 +121,19 @@ fn create_channel() { let destination: VersionedMultiLocation = Rococo::child_location_of(BridgeHubRococo::para_id()).into(); + let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {}); + let create_agent_xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, DescendOrigin(X1(Parachain(origin_para))), Transact { require_weight_at_most: 3000000000.into(), origin_kind: OriginKind::Xcm, - call: vec![63, 2].into(), + call: create_agent_call.encode().into(), }, ])); - let create_channel_call = SnowbridgeControl::Control(CreateChannelCall::CreateChannel { + let create_channel_call = SnowbridgeControl::Control(ControlCall::CreateChannel { mode: OperatingMode::Normal, outbound_fee: 1, }); @@ -226,33 +232,23 @@ fn register_token() { #[test] fn send_token_to_penpal() { - let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of( - MultiLocation { - parents: 1, - interior: X1(Parachain(ASSETHUB_PARA_ID)), - } - ); - BridgeHubRococo::fund_accounts(vec![( - asset_hub_sovereign.clone(), - INITIAL_FUND, - )]); + let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation { + parents: 1, + interior: X1(Parachain(ASSETHUB_PARA_ID)), + }); + BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]); // Fund ethereum sovereign in asset hub - AssetHubRococo::fund_accounts(vec![ - (AssetHubRococoReceiver::get(), INITIAL_FUND), - ]); + AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); PenpalA::fund_accounts(vec![ (PenpalAReceiver::get(), INITIAL_FUND), (PenpalASender::get(), INITIAL_FUND), ]); - let weth_asset_id: MultiLocation = ( - Parent, - Parent, - Ethereum { chain_id: 15 }, - AccountKey20 { network: None, key: WETH } - ).into(); + let weth_asset_id: MultiLocation = + (Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH }) + .into(); // Create asset on penpal. PenpalA::execute_with(|| { @@ -282,7 +278,10 @@ fn send_token_to_penpal() { chain_id: CHAIN_ID, command: Command::SendToken { token: WETH.into(), - destination: Destination::ForeignAccountId32 { para_id: 2000, id: PenpalAReceiver::get().into() }, + destination: Destination::ForeignAccountId32 { + para_id: 2000, + id: PenpalAReceiver::get().into(), + }, amount: 1_000_000_000, }, }); @@ -332,9 +331,7 @@ fn send_token() { )]); // Fund ethereum sovereign in asset hub - AssetHubRococo::fund_accounts(vec![ - (AssetHubRococoReceiver::get(), INITIAL_FUND), - ]); + AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); let message_id_: H256 = [1; 32].into(); @@ -381,20 +378,14 @@ fn send_token() { #[test] fn reserve_transfer_token() { - let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of( - MultiLocation { - parents: 1, - interior: X1(Parachain(ASSETHUB_PARA_ID)), - } - ); + let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation { + parents: 1, + interior: X1(Parachain(ASSETHUB_PARA_ID)), + }); - BridgeHubRococo::fund_accounts(vec![ - (assethub_sovereign.clone(), INITIAL_FUND) - ]); + BridgeHubRococo::fund_accounts(vec![(assethub_sovereign.clone(), INITIAL_FUND)]); - AssetHubRococo::fund_accounts(vec![ - (AssetHubRococoReceiver::get(), INITIAL_FUND), - ]); + AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); const WETH_AMOUNT: u128 = 1_000_000_000; let message_id_: H256 = [1; 32].into();