Replicate e2e integration test as emulated (#2958)

* Allow functions to work over both parachains and relay chains

* additional references

* import

* backup

* refactoring para and relay traits

* use runtime crates to build types

* decouple ProcessMessage

* decouple ProcessMessage 2

* dmp and xcmp handlers decouple

* backup

* refactor done

* common int values working

* added global ext with mutex

* works for two mutex

* single mutex and remove condvar

* global test ext done

* failing moving test_ext because relay block num

* relay_block_number issue fixed

* backup

* Test working with assertions

* assertions get Test as arg

* DispatchArgs as generic

* clean up

* backup

* teleports for asset-hub-kusama done

* improve assert_expected_events macro

* rename Test generics

* check assertions for tuples

* test assertions redone

* reserve_transfer_assets done

* send transact done

* hrmp test for paras

* hrmp channels test done

* hrmp channels test done 2

* before modifying test dispatch

* reserve tests done & Test dispatch fixed

* reserve transfer local asset

* force_create_and_mint_asset

* force create and mint done

* tests done

* fix imports in common

* common events refactored

* add option to events attributes

* asset-hub-polkadot tests done

* asset-hub-westend half done

* relay chain events move to common

* remove failing send tests for asset-hub-westend

* added events to bridge-hub-rococo

* added events to collectives-polkadot

* cargo clean up

* fix asset-hub-westend tests

* ".git/.scripts/commands/fmt/fmt.sh"

* fix clippy

* ".git/.scripts/commands/fmt/fmt.sh"

* Removed unnecessary deps

* Extracted some commonality for Kusama/Polkadot (which will be reused also for BridgeHubs) (#2971)

* Extracted some commonality for Kusama/Polkadot (which will be reused also for BridgeHubs)

* AssetHubRococo should better use AssetHubKusama runtime

* add fund_account

---------

Co-authored-by: NachoPal <ignacio.palacios.santos@gmail.com>

* address comments

* rename event assertion helpers

* clean comments

* address comments 2

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Co-authored-by: Giles Cope <gilescope@gmail.com>
Co-authored-by: command-bot <>
Co-authored-by: Branislav Kontur <bkontur@gmail.com>
This commit is contained in:
Ignacio Palacios
2023-08-10 19:38:18 +02:00
committed by GitHub
parent e077bdd99f
commit eadfbca388
40 changed files with 5344 additions and 1300 deletions
@@ -7,6 +7,8 @@ description = "Common resources for integration testing with xcm-emulator"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false }
lazy_static = "1.4.0"
paste = "1.0.14"
# Substrate
grandpa = { package = "sc-consensus-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -20,6 +22,7 @@ sp-consensus-babe = { default-features = false, git = "https://github.com/parity
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-message-queue = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-im-online = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
beefy-primitives = { package = "sp-consensus-beefy", git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -54,6 +57,9 @@ bridge-hub-kusama-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-k
bridge-hub-polkadot-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-polkadot" }
bridge-hub-rococo-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-rococo" }
xcm-emulator = { default-features = false, path = "../../../../xcm/xcm-emulator" }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue" }
cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../pallets/xcmp-queue" }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system" }
bp-messages = { path = "../../../../bridges/primitives/messages"}
bp-runtime = { path = "../../../../bridges/primitives/runtime"}
pallet-bridge-messages = { path = "../../../../bridges/modules/messages" }
@@ -2,8 +2,12 @@ use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId;
use grandpa::AuthorityId as GrandpaId;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber};
use polkadot_parachain::primitives::{HeadData, ValidationCode};
use polkadot_primitives::{AssignmentId, ValidatorId};
use polkadot_runtime_parachains::configuration::HostConfiguration;
use polkadot_runtime_parachains::{
configuration::HostConfiguration,
paras::{ParaGenesisArgs, ParaKind},
};
use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
@@ -129,6 +133,13 @@ pub mod polkadot {
max_upward_message_size: 51200,
max_upward_message_num_per_candidate: 10,
max_downward_message_size: 51200,
hrmp_sender_deposit: 100_000_000_000,
hrmp_recipient_deposit: 100_000_000_000,
hrmp_channel_max_capacity: 1000,
hrmp_channel_max_message_size: 102400,
hrmp_channel_max_total_size: 102400,
hrmp_max_parachain_outbound_channels: 30,
hrmp_max_parachain_inbound_channels: 30,
..Default::default()
}
}
@@ -206,6 +217,41 @@ pub mod polkadot {
..Default::default()
},
configuration: polkadot_runtime::ConfigurationConfig { config: get_host_config() },
paras: polkadot_runtime::ParasConfig {
paras: vec![
(
asset_hub_polkadot::PARA_ID.into(),
ParaGenesisArgs {
genesis_head: HeadData::default(),
validation_code: ValidationCode(
asset_hub_polkadot_runtime::WASM_BINARY.unwrap().to_vec(),
),
para_kind: ParaKind::Parachain,
},
),
(
penpal::PARA_ID_A.into(),
ParaGenesisArgs {
genesis_head: HeadData::default(),
validation_code: ValidationCode(
penpal_runtime::WASM_BINARY.unwrap().to_vec(),
),
para_kind: ParaKind::Parachain,
},
),
(
penpal::PARA_ID_B.into(),
ParaGenesisArgs {
genesis_head: HeadData::default(),
validation_code: ValidationCode(
penpal_runtime::WASM_BINARY.unwrap().to_vec(),
),
para_kind: ParaKind::Parachain,
},
),
],
..Default::default()
},
..Default::default()
};
@@ -228,6 +274,13 @@ pub mod westend {
max_upward_message_size: 51200,
max_upward_message_num_per_candidate: 10,
max_downward_message_size: 51200,
hrmp_sender_deposit: 100_000_000_000,
hrmp_recipient_deposit: 100_000_000_000,
hrmp_channel_max_capacity: 1000,
hrmp_channel_max_message_size: 102400,
hrmp_channel_max_total_size: 102400,
hrmp_max_parachain_outbound_channels: 30,
hrmp_max_parachain_inbound_channels: 30,
..Default::default()
}
}
@@ -327,6 +380,13 @@ pub mod kusama {
max_upward_message_size: 51200,
max_upward_message_num_per_candidate: 10,
max_downward_message_size: 51200,
hrmp_sender_deposit: 5_000_000_000_000,
hrmp_recipient_deposit: 5_000_000_000_000,
hrmp_channel_max_capacity: 1000,
hrmp_channel_max_message_size: 102400,
hrmp_channel_max_total_size: 102400,
hrmp_max_parachain_outbound_channels: 30,
hrmp_max_parachain_inbound_channels: 30,
..Default::default()
}
}
@@ -403,6 +463,41 @@ pub mod kusama {
..Default::default()
},
configuration: kusama_runtime::ConfigurationConfig { config: get_host_config() },
paras: kusama_runtime::ParasConfig {
paras: vec![
(
asset_hub_kusama::PARA_ID.into(),
ParaGenesisArgs {
genesis_head: HeadData::default(),
validation_code: ValidationCode(
asset_hub_kusama_runtime::WASM_BINARY.unwrap().to_vec(),
),
para_kind: ParaKind::Parachain,
},
),
(
penpal::PARA_ID_A.into(),
ParaGenesisArgs {
genesis_head: HeadData::default(),
validation_code: ValidationCode(
penpal_runtime::WASM_BINARY.unwrap().to_vec(),
),
para_kind: ParaKind::Parachain,
},
),
(
penpal::PARA_ID_B.into(),
ParaGenesisArgs {
genesis_head: HeadData::default(),
validation_code: ValidationCode(
penpal_runtime::WASM_BINARY.unwrap().to_vec(),
),
para_kind: ParaKind::Parachain,
},
),
],
..Default::default()
},
..Default::default()
};
@@ -419,10 +514,18 @@ pub mod rococo {
pub fn get_host_config() -> HostConfiguration<BlockNumber> {
HostConfiguration {
max_upward_queue_count: 10,
max_upward_queue_size: 51200,
max_upward_message_size: 51200,
max_upward_message_num_per_candidate: 10,
max_downward_message_size: 51200,
hrmp_sender_deposit: 0,
hrmp_recipient_deposit: 0,
hrmp_channel_max_capacity: 1000,
hrmp_channel_max_message_size: 102400,
hrmp_channel_max_total_size: 102400,
hrmp_max_parachain_outbound_channels: 30,
hrmp_max_parachain_inbound_channels: 30,
..Default::default()
}
}
@@ -674,7 +777,8 @@ pub mod asset_hub_kusama {
// Penpal
pub mod penpal {
use super::*;
pub const PARA_ID: u32 = 2000;
pub const PARA_ID_A: u32 = 2000;
pub const PARA_ID_B: u32 = 2001;
pub const ED: Balance = penpal_runtime::EXISTENTIAL_DEPOSIT;
pub fn genesis(para_id: u32) -> Storage {
@@ -1,4 +1,5 @@
use super::{BridgeHubRococo, BridgeHubWococo};
// pub use paste;
use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
LaneId, MessageKey, OutboundLaneData,
@@ -8,7 +9,7 @@ use codec::Decode;
pub use cumulus_primitives_core::{DmpMessageHandler, XcmpMessageHandler};
use pallet_bridge_messages::{Config, Instance1, Instance2, OutboundLanes, Pallet};
use sp_core::Get;
use xcm_emulator::{BridgeMessage, BridgeMessageDispatchError, BridgeMessageHandler, Parachain};
use xcm_emulator::{BridgeMessage, BridgeMessageDispatchError, BridgeMessageHandler, Chain};
pub struct BridgeHubMessageHandler<S, T, I> {
_marker: std::marker::PhantomData<(S, T, I)>,
@@ -28,12 +29,12 @@ impl From<u32> for LaneIdWrapper {
}
}
type BridgeHubRococoRuntime = <BridgeHubRococo as Parachain>::Runtime;
type BridgeHubWococoRuntime = <BridgeHubWococo as Parachain>::Runtime;
type BridgeHubRococoRuntime = <BridgeHubRococo as Chain>::Runtime;
type BridgeHubWococoRuntime = <BridgeHubWococo as Chain>::Runtime;
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
// type BridgeHubPolkadotRuntime = <BridgeHubPolkadot as Parachain>::Runtime;
// type BridgeHubKusamaRuntime = <BridgeHubKusama as Parachain>::Runtime;
// type BridgeHubPolkadotRuntime = <BridgeHubPolkadot as Chain>::Runtime;
// type BridgeHubKusamaRuntime = <BridgeHubKusama as Chain>::Runtime;
pub type RococoWococoMessageHandler =
BridgeHubMessageHandler<BridgeHubRococoRuntime, BridgeHubWococoRuntime, Instance2>;
@@ -124,3 +125,473 @@ where
OutboundLanes::<S, Instance1>::insert(LaneIdWrapper::from(lane_id).0, new_data);
}
}
#[macro_export]
macro_rules! impl_accounts_helpers_for_relay_chain {
( $chain:ident ) => {
$crate::paste::paste! {
impl $chain {
/// Fund a set of accounts with a balance
pub fn fund_accounts(accounts: Vec<(AccountId, Balance)>) {
Self::execute_with(|| {
for account in accounts {
assert_ok!(<Self as [<$chain Pallet>]>::Balances::force_set_balance(
<Self as Chain>::RuntimeOrigin::root(),
account.0.into(),
account.1,
));
}
});
}
/// Fund a sovereign account based on its Parachain Id
pub fn fund_para_sovereign(amount: Balance, para_id: ParaId) -> sp_runtime::AccountId32 {
let sovereign_account = Self::sovereign_account_id_of_child_para(para_id);
Self::fund_accounts(vec![(sovereign_account.clone(), amount)]);
sovereign_account
}
}
}
};
}
#[macro_export]
macro_rules! impl_assert_events_helpers_for_relay_chain {
( $chain:ident ) => {
$crate::paste::paste! {
type [<$chain RuntimeEvent>] = <$chain as Chain>::RuntimeEvent;
impl $chain {
/// Asserts a dispatchable is completely executed and XCM sent
pub fn assert_xcm_pallet_attempted_complete(expected_weight: Option<Weight>) {
assert_expected_events!(
Self,
vec![
[<$chain RuntimeEvent>]::XcmPallet(
pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) }
) => {
weight: weight_within_threshold(
(REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight),
*weight
),
},
]
);
}
/// Asserts a dispatchable is incompletely executed and XCM sent
pub fn assert_xcm_pallet_attempted_incomplete(
expected_weight: Option<Weight>,
expected_error: Option<Error>,
) {
assert_expected_events!(
Self,
vec![
// Dispatchable is properly executed and XCM message sent
[<$chain RuntimeEvent>]::XcmPallet(
pallet_xcm::Event::Attempted { outcome: Outcome::Incomplete(weight, error) }
) => {
weight: weight_within_threshold(
(REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight),
*weight
),
error: *error == expected_error.unwrap_or(*error),
},
]
);
}
/// Asserts a XCM message is sent
pub fn assert_xcm_pallet_sent() {
assert_expected_events!(
Self,
vec![
[<$chain RuntimeEvent>]::XcmPallet(pallet_xcm::Event::Sent { .. }) => {},
]
);
}
/// Asserts a XCM from System Parachain is succesfully received and proccessed
pub fn assert_ump_queue_processed(
expected_success: bool,
expected_id: Option<ParaId>,
expected_weight: Option<Weight>,
) {
assert_expected_events!(
Self,
vec![
// XCM is succesfully received and proccessed
[<$chain RuntimeEvent>]::MessageQueue(pallet_message_queue::Event::Processed {
origin: AggregateMessageOrigin::Ump(UmpQueueId::Para(id)),
weight_used,
success,
..
}) => {
id: *id == expected_id.unwrap_or(*id),
weight_used: weight_within_threshold(
(REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight_used),
*weight_used
),
success: *success == expected_success,
},
]
);
}
}
}
};
}
#[macro_export]
macro_rules! impl_hrmp_channels_helpers_for_relay_chain {
( $chain:ident ) => {
$crate::paste::paste! {
impl $chain {
/// Init open channel request with another Parachain
pub fn init_open_channel_call(
recipient_para_id: ParaId,
max_capacity: u32,
max_message_size: u32,
) -> DoubleEncoded<()> {
<Self as Chain>::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::<
<Self as Chain>::Runtime,
>::hrmp_init_open_channel {
recipient: recipient_para_id,
proposed_max_capacity: max_capacity,
proposed_max_message_size: max_message_size,
})
.encode()
.into()
}
/// Recipient Parachain accept the open request from another Parachain
pub fn accept_open_channel_call(sender_para_id: ParaId) -> DoubleEncoded<()> {
<Self as Chain>::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::<
<Self as Chain>::Runtime,
>::hrmp_accept_open_channel {
sender: sender_para_id,
})
.encode()
.into()
}
/// A root origin force to open a channel between two Parachains
pub fn force_process_hrmp_open(sender: ParaId, recipient: ParaId) {
Self::execute_with(|| {
let relay_root_origin = <Self as Chain>::RuntimeOrigin::root();
// Force process HRMP open channel requests without waiting for the next session
assert_ok!(<Self as [<$chain Pallet>]>::Hrmp::force_process_hrmp_open(
relay_root_origin,
0
));
let channel_id = HrmpChannelId { sender, recipient };
let hrmp_channel_exist = polkadot_runtime_parachains::hrmp::HrmpChannels::<
<Self as Chain>::Runtime,
>::contains_key(&channel_id);
// Check the HRMP channel has been successfully registrered
assert!(hrmp_channel_exist)
});
}
}
}
};
}
#[macro_export]
macro_rules! impl_accounts_helpers_for_parachain {
( $chain:ident ) => {
$crate::paste::paste! {
impl $chain {
/// Fund a set of accounts with a balance
pub fn fund_accounts(accounts: Vec<(AccountId, Balance)>) {
Self::execute_with(|| {
for account in accounts {
assert_ok!(<Self as [<$chain Pallet>]>::Balances::force_set_balance(
<Self as Chain>::RuntimeOrigin::root(),
account.0.into(),
account.1,
));
}
});
}
}
}
};
}
#[macro_export]
macro_rules! impl_assert_events_helpers_for_parachain {
( $chain:ident ) => {
$crate::paste::paste! {
type [<$chain RuntimeEvent>] = <$chain as Chain>::RuntimeEvent;
impl $chain {
/// Asserts a dispatchable is completely executed and XCM sent
pub fn assert_xcm_pallet_attempted_complete(expected_weight: Option<Weight>) {
assert_expected_events!(
Self,
vec![
[<$chain RuntimeEvent>]::PolkadotXcm(
pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) }
) => {
weight: weight_within_threshold(
(REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight),
*weight
),
},
]
);
}
/// Asserts a dispatchable is incompletely executed and XCM sent
pub fn assert_xcm_pallet_attempted_incomplete(
expected_weight: Option<Weight>,
expected_error: Option<Error>,
) {
assert_expected_events!(
Self,
vec![
// Dispatchable is properly executed and XCM message sent
[<$chain RuntimeEvent>]::PolkadotXcm(
pallet_xcm::Event::Attempted { outcome: Outcome::Incomplete(weight, error) }
) => {
weight: weight_within_threshold(
(REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight),
*weight
),
error: *error == expected_error.unwrap_or(*error),
},
]
);
}
/// Asserts a dispatchable throws and error when trying to be sent
pub fn assert_xcm_pallet_attempted_error(expected_error: Option<Error>) {
assert_expected_events!(
Self,
vec![
// Execution fails in the origin with `Barrier`
[<$chain RuntimeEvent>]::PolkadotXcm(
pallet_xcm::Event::Attempted { outcome: Outcome::Error(error) }
) => {
error: *error == expected_error.unwrap_or(*error),
},
]
);
}
/// Asserts a XCM message is sent
pub fn assert_xcm_pallet_sent() {
assert_expected_events!(
Self,
vec![
[<$chain RuntimeEvent>]::PolkadotXcm(pallet_xcm::Event::Sent { .. }) => {},
]
);
}
/// Asserts a XCM message is sent to Relay Chain
pub fn assert_parachain_system_ump_sent() {
assert_expected_events!(
Self,
vec![
[<$chain RuntimeEvent>]::ParachainSystem(
cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. }
) => {},
]
);
}
/// Asserts a XCM from Relay Chain is completely executed
pub fn assert_dmp_queue_complete(expected_weight: Option<Weight>) {
assert_expected_events!(
Self,
vec![
[<$chain RuntimeEvent>]::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward {
outcome: Outcome::Complete(weight), ..
}) => {
weight: weight_within_threshold(
(REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight),
*weight
),
},
]
);
}
/// Asserts a XCM from Relay Chain is incompletely executed
pub fn assert_dmp_queue_incomplete(
expected_weight: Option<Weight>,
expected_error: Option<Error>,
) {
assert_expected_events!(
Self,
vec![
[<$chain RuntimeEvent>]::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward {
outcome: Outcome::Incomplete(weight, error), ..
}) => {
weight: weight_within_threshold(
(REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight),
*weight
),
error: *error == expected_error.unwrap_or(*error),
},
]
);
}
/// Asserts a XCM from another Parachain is completely executed
pub fn assert_xcmp_queue_success(expected_weight: Option<Weight>) {
assert_expected_events!(
Self,
vec![
[<$chain RuntimeEvent>]::XcmpQueue(
cumulus_pallet_xcmp_queue::Event::Success { weight, .. }
) => {
weight: weight_within_threshold(
(REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD),
expected_weight.unwrap_or(*weight),
*weight
),
},
]
);
}
}
}
};
}
#[macro_export]
macro_rules! impl_assets_helpers_for_parachain {
( $chain:ident, $relay_chain:ident ) => {
$crate::paste::paste! {
impl $chain {
/// Returns the encoded call for `force_create` from the assets pallet
pub fn force_create_asset_call(
asset_id: u32,
owner: AccountId,
is_sufficient: bool,
min_balance: Balance,
) -> DoubleEncoded<()> {
<Self as Chain>::RuntimeCall::Assets(pallet_assets::Call::<
<Self as Chain>::Runtime,
Instance1,
>::force_create {
id: asset_id.into(),
owner: owner.into(),
is_sufficient,
min_balance,
})
.encode()
.into()
}
/// Returns a `VersionedXcm` for `force_create` from the assets pallet
pub fn force_create_asset_xcm(
origin_kind: OriginKind,
asset_id: u32,
owner: AccountId,
is_sufficient: bool,
min_balance: Balance,
) -> VersionedXcm<()> {
let call = Self::force_create_asset_call(asset_id, owner, is_sufficient, min_balance);
xcm_transact_unpaid_execution(call, origin_kind)
}
/// Mint assets making use of the assets pallet
pub fn mint_asset(
signed_origin: <Self as Chain>::RuntimeOrigin,
id: u32,
beneficiary: AccountId,
amount_to_mint: u128,
) {
Self::execute_with(|| {
assert_ok!(<Self as [<$chain Pallet>]>::Assets::mint(
signed_origin,
id.into(),
beneficiary.clone().into(),
amount_to_mint
));
type RuntimeEvent = <$chain as Chain>::RuntimeEvent;
assert_expected_events!(
Self,
vec![
RuntimeEvent::Assets(pallet_assets::Event::Issued { asset_id, owner, amount }) => {
asset_id: *asset_id == id,
owner: *owner == beneficiary.clone().into(),
amount: *amount == amount_to_mint,
},
]
);
});
}
/// Force create and mint assets making use of the assets pallet
pub fn force_create_and_mint_asset(
id: u32,
min_balance: u128,
is_sufficient: bool,
asset_owner: AccountId,
amount_to_mint: u128,
) {
// Init values for Relay Chain
let root_origin = <$relay_chain as Chain>::RuntimeOrigin::root();
let destination = <$relay_chain>::child_location_of(<$chain>::para_id());
let xcm = Self::force_create_asset_xcm(
OriginKind::Superuser,
id,
asset_owner.clone(),
is_sufficient,
min_balance,
);
<$relay_chain>::execute_with(|| {
assert_ok!(<$relay_chain as [<$relay_chain Pallet>]>::XcmPallet::send(
root_origin,
bx!(destination.into()),
bx!(xcm),
));
<$relay_chain>::assert_xcm_pallet_sent();
});
Self::execute_with(|| {
Self::assert_dmp_queue_complete(Some(Weight::from_parts(1_019_445_000, 200_000)));
type RuntimeEvent = <$chain as Chain>::RuntimeEvent;
assert_expected_events!(
Self,
vec![
// Asset has been created
RuntimeEvent::Assets(pallet_assets::Event::ForceCreated { asset_id, owner }) => {
asset_id: *asset_id == id,
owner: *owner == asset_owner.clone(),
},
]
);
assert!(<Self as [<$chain Pallet>]>::Assets::asset_exists(id.into()));
});
let signed_origin = <Self as Chain>::RuntimeOrigin::signed(asset_owner.clone());
// Mint asset for System Parachain's sender
Self::mint_asset(signed_origin, id, asset_owner, amount_to_mint);
}
}
}
};
}
@@ -1,121 +1,114 @@
pub use lazy_static;
pub mod constants;
pub mod impls;
pub use codec::Encode;
pub use constants::{
accounts::{ALICE, BOB},
asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama,
bridge_hub_polkadot, bridge_hub_rococo, collectives, kusama, penpal, polkadot, rococo, westend,
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD,
};
use frame_support::{
assert_ok, instances::Instance1, parameter_types, sp_tracing, traits::fungibles::Inspect,
};
pub use impls::{RococoWococoMessageHandler, WococoRococoMessageHandler};
use frame_support::{parameter_types, sp_io, sp_tracing};
pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber};
pub use parachains_common::{AccountId, Balance};
pub use paste;
use polkadot_parachain::primitives::HrmpChannelId;
pub use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId};
pub use sp_core::{sr25519, storage::Storage, Get};
use xcm::prelude::*;
use xcm_emulator::{
decl_test_bridges, decl_test_networks, decl_test_parachains, decl_test_relay_chains,
decl_test_sender_receiver_accounts_parameter_types, BridgeMessageHandler, Parachain,
RelayChain, TestExt,
assert_expected_events, bx, decl_test_bridges, decl_test_networks, decl_test_parachains,
decl_test_relay_chains, decl_test_sender_receiver_accounts_parameter_types,
helpers::weight_within_threshold, BridgeMessageHandler, Chain, DefaultMessageProcessor, ParaId,
Parachain, RelayChain, TestExt,
};
pub use xcm::{
prelude::{
AccountId32, All, BuyExecution, DepositAsset, MultiAsset, MultiAssets, MultiLocation,
OriginKind, Outcome, RefundSurplus, Transact, UnpaidExecution, VersionedXcm, Weight,
WeightLimit, WithdrawAsset, Xcm, X1,
},
v3::Error,
DoubleEncoded,
};
use xcm_executor::traits::ConvertLocation;
decl_test_relay_chains! {
#[api_version(5)]
pub struct Polkadot {
genesis = polkadot::genesis(),
on_init = (),
runtime = {
Runtime: polkadot_runtime::Runtime,
RuntimeOrigin: polkadot_runtime::RuntimeOrigin,
RuntimeCall: polkadot_runtime::RuntimeCall,
RuntimeEvent: polkadot_runtime::RuntimeEvent,
MessageQueue: polkadot_runtime::MessageQueue,
XcmConfig: polkadot_runtime::xcm_config::XcmConfig,
runtime = polkadot_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Polkadot>,
SovereignAccountOf: polkadot_runtime::xcm_config::SovereignAccountOf,
System: polkadot_runtime::System,
Balances: polkadot_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: polkadot_runtime::XcmPallet,
Balances: polkadot_runtime::Balances,
Hrmp: polkadot_runtime::Hrmp,
}
},
#[api_version(5)]
pub struct Kusama {
genesis = kusama::genesis(),
on_init = (),
runtime = {
Runtime: kusama_runtime::Runtime,
RuntimeOrigin: kusama_runtime::RuntimeOrigin,
RuntimeCall: kusama_runtime::RuntimeCall,
RuntimeEvent: kusama_runtime::RuntimeEvent,
MessageQueue: kusama_runtime::MessageQueue,
XcmConfig: kusama_runtime::xcm_config::XcmConfig,
runtime = kusama_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Kusama>,
SovereignAccountOf: kusama_runtime::xcm_config::SovereignAccountOf,
System: kusama_runtime::System,
Balances: kusama_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: kusama_runtime::XcmPallet,
Balances: kusama_runtime::Balances,
Hrmp: kusama_runtime::Hrmp,
}
},
#[api_version(5)]
pub struct Westend {
genesis = westend::genesis(),
on_init = (),
runtime = {
Runtime: westend_runtime::Runtime,
RuntimeOrigin: westend_runtime::RuntimeOrigin,
RuntimeCall: westend_runtime::RuntimeCall,
RuntimeEvent: westend_runtime::RuntimeEvent,
MessageQueue: westend_runtime::MessageQueue,
XcmConfig: westend_runtime::xcm_config::XcmConfig,
runtime = westend_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Westend>,
SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
System: westend_runtime::System,
Balances: westend_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: westend_runtime::XcmPallet,
Sudo: westend_runtime::Sudo,
Balances: westend_runtime::Balances,
}
},
#[api_version(5)]
pub struct Rococo {
genesis = rococo::genesis(),
on_init = (),
runtime = {
Runtime: rococo_runtime::Runtime,
RuntimeOrigin: rococo_runtime::RuntimeOrigin,
RuntimeCall: rococo_runtime::RuntimeCall,
RuntimeEvent: rococo_runtime::RuntimeEvent,
MessageQueue: rococo_runtime::MessageQueue,
XcmConfig: rococo_runtime::xcm_config::XcmConfig,
runtime = rococo_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Rococo>,
SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
System: rococo_runtime::System,
Balances: rococo_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: rococo_runtime::XcmPallet,
Sudo: rococo_runtime::Sudo,
Balances: rococo_runtime::Balances,
}
},
#[api_version(5)]
pub struct Wococo {
genesis = rococo::genesis(),
on_init = (),
runtime = {
Runtime: rococo_runtime::Runtime,
RuntimeOrigin: rococo_runtime::RuntimeOrigin,
RuntimeCall: rococo_runtime::RuntimeCall,
RuntimeEvent: rococo_runtime::RuntimeEvent,
MessageQueue: rococo_runtime::MessageQueue,
XcmConfig: rococo_runtime::xcm_config::XcmConfig,
runtime = rococo_runtime,
core = {
MessageProcessor: DefaultMessageProcessor<Wococo>,
SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
System: rococo_runtime::System,
Balances: rococo_runtime::Balances,
},
pallets_extra = {
pallets = {
XcmPallet: rococo_runtime::XcmPallet,
Sudo: rococo_runtime::Sudo,
Balances: rococo_runtime::Balances,
}
}
}
@@ -125,81 +118,74 @@ decl_test_parachains! {
pub struct AssetHubPolkadot {
genesis = asset_hub_polkadot::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_polkadot_runtime::Runtime,
RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall,
RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent,
runtime = asset_hub_polkadot_runtime,
core = {
XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue,
LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId,
System: asset_hub_polkadot_runtime::System,
Balances: asset_hub_polkadot_runtime::Balances,
ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem,
ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm,
Assets: asset_hub_polkadot_runtime::Assets,
Balances: asset_hub_polkadot_runtime::Balances,
}
},
pub struct Collectives {
genesis = collectives::genesis(),
on_init = (),
runtime = {
Runtime: collectives_polkadot_runtime::Runtime,
RuntimeOrigin: collectives_polkadot_runtime::RuntimeOrigin,
RuntimeCall: collectives_polkadot_runtime::RuntimeCall,
RuntimeEvent: collectives_polkadot_runtime::RuntimeEvent,
runtime = collectives_polkadot_runtime,
core = {
XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue,
DmpMessageHandler: collectives_polkadot_runtime::DmpQueue,
LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId,
System: collectives_polkadot_runtime::System,
Balances: collectives_polkadot_runtime::Balances,
ParachainSystem: collectives_polkadot_runtime::ParachainSystem,
ParachainInfo: collectives_polkadot_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm,
Balances: collectives_polkadot_runtime::Balances,
}
},
pub struct BridgeHubPolkadot {
genesis = bridge_hub_polkadot::genesis(),
on_init = (),
runtime = {
Runtime: bridge_hub_polkadot_runtime::Runtime,
RuntimeOrigin: bridge_hub_polkadot_runtime::RuntimeOrigin,
RuntimeCall: bridge_hub_polkadot_runtime::RuntimeCall,
RuntimeEvent: bridge_hub_polkadot_runtime::RuntimeEvent,
runtime = bridge_hub_polkadot_runtime,
core = {
XcmpMessageHandler: bridge_hub_polkadot_runtime::XcmpQueue,
DmpMessageHandler: bridge_hub_polkadot_runtime::DmpQueue,
LocationToAccountId: bridge_hub_polkadot_runtime::xcm_config::LocationToAccountId,
System: bridge_hub_polkadot_runtime::System,
Balances: bridge_hub_polkadot_runtime::Balances,
ParachainSystem: bridge_hub_polkadot_runtime::ParachainSystem,
ParachainInfo: bridge_hub_polkadot_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: bridge_hub_polkadot_runtime::PolkadotXcm,
}
},
pub struct PenpalPolkadot {
genesis = penpal::genesis(penpal::PARA_ID),
pub struct PenpalPolkadotA {
genesis = penpal::genesis(penpal::PARA_ID_A),
on_init = (),
runtime = {
Runtime: penpal_runtime::Runtime,
RuntimeOrigin: penpal_runtime::RuntimeOrigin,
RuntimeCall: penpal_runtime::RuntimeCall,
RuntimeEvent: penpal_runtime::RuntimeEvent,
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
System: penpal_runtime::System,
Balances: penpal_runtime::Balances,
ParachainSystem: penpal_runtime::ParachainSystem,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
},
pub struct PenpalPolkadotB {
genesis = penpal::genesis(penpal::PARA_ID_B),
on_init = (),
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
@@ -208,62 +194,60 @@ decl_test_parachains! {
pub struct AssetHubKusama {
genesis = asset_hub_kusama::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_kusama_runtime::Runtime,
RuntimeOrigin: asset_hub_kusama_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_kusama_runtime::RuntimeCall,
RuntimeEvent: asset_hub_kusama_runtime::RuntimeEvent,
runtime = asset_hub_kusama_runtime,
core = {
XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue,
LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId,
System: asset_hub_kusama_runtime::System,
Balances: asset_hub_kusama_runtime::Balances,
ParachainSystem: asset_hub_kusama_runtime::ParachainSystem,
ParachainInfo: asset_hub_kusama_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm,
Assets: asset_hub_kusama_runtime::Assets,
ForeignAssets: asset_hub_kusama_runtime::Assets,
Balances: asset_hub_kusama_runtime::Balances,
}
},
pub struct BridgeHubKusama {
genesis = bridge_hub_kusama::genesis(),
on_init = (),
runtime = {
Runtime: bridge_hub_kusama_runtime::Runtime,
RuntimeOrigin: bridge_hub_kusama_runtime::RuntimeOrigin,
RuntimeCall: bridge_hub_kusama_runtime::RuntimeCall,
RuntimeEvent: bridge_hub_kusama_runtime::RuntimeEvent,
runtime = bridge_hub_kusama_runtime,
core = {
XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue,
DmpMessageHandler: bridge_hub_kusama_runtime::DmpQueue,
LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId,
System: bridge_hub_kusama_runtime::System,
Balances: bridge_hub_kusama_runtime::Balances,
ParachainSystem: bridge_hub_kusama_runtime::ParachainSystem,
ParachainInfo: bridge_hub_kusama_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm,
}
},
pub struct PenpalKusama {
genesis = penpal::genesis(penpal::PARA_ID),
pub struct PenpalKusamaA {
genesis = penpal::genesis(penpal::PARA_ID_A),
on_init = (),
runtime = {
Runtime: penpal_runtime::Runtime,
RuntimeOrigin: penpal_runtime::RuntimeOrigin,
RuntimeCall: penpal_runtime::RuntimeCall,
RuntimeEvent: penpal_runtime::RuntimeEvent,
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
System: penpal_runtime::System,
Balances: penpal_runtime::Balances,
ParachainSystem: penpal_runtime::ParachainSystem,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
},
pub struct PenpalKusamaB {
genesis = penpal::genesis(penpal::PARA_ID_B),
on_init = (),
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
@@ -272,44 +256,33 @@ decl_test_parachains! {
pub struct AssetHubWestend {
genesis = asset_hub_westend::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_westend_runtime::Runtime,
RuntimeOrigin: asset_hub_westend_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_westend_runtime::RuntimeCall,
RuntimeEvent: asset_hub_westend_runtime::RuntimeEvent,
runtime = asset_hub_westend_runtime,
core = {
XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_westend_runtime::DmpQueue,
LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId,
System: asset_hub_westend_runtime::System,
Balances: asset_hub_westend_runtime::Balances,
ParachainSystem: asset_hub_westend_runtime::ParachainSystem,
ParachainInfo: asset_hub_westend_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm,
Balances: asset_hub_westend_runtime::Balances,
Assets: asset_hub_westend_runtime::Assets,
ForeignAssets: asset_hub_westend_runtime::ForeignAssets,
PoolAssets: asset_hub_westend_runtime::PoolAssets,
AssetConversion: asset_hub_westend_runtime::AssetConversion,
}
},
pub struct PenpalWestend {
genesis = penpal::genesis(penpal::PARA_ID),
pub struct PenpalWestendA {
genesis = penpal::genesis(penpal::PARA_ID_A),
on_init = (),
runtime = {
Runtime: penpal_runtime::Runtime,
RuntimeOrigin: penpal_runtime::RuntimeOrigin,
RuntimeCall: penpal_runtime::RuntimeCall,
RuntimeEvent: penpal_runtime::RuntimeEvent,
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
System: penpal_runtime::System,
Balances: penpal_runtime::Balances,
ParachainSystem: penpal_runtime::ParachainSystem,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
@@ -318,85 +291,78 @@ decl_test_parachains! {
pub struct BridgeHubRococo {
genesis = bridge_hub_rococo::genesis(),
on_init = (),
runtime = {
Runtime: bridge_hub_rococo_runtime::Runtime,
RuntimeOrigin: bridge_hub_rococo_runtime::RuntimeOrigin,
RuntimeCall: bridge_hub_rococo_runtime::RuntimeCall,
RuntimeEvent: bridge_hub_rococo_runtime::RuntimeEvent,
runtime = bridge_hub_rococo_runtime,
core = {
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
DmpMessageHandler: bridge_hub_rococo_runtime::DmpQueue,
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
System: bridge_hub_rococo_runtime::System,
Balances: bridge_hub_rococo_runtime::Balances,
ParachainSystem: bridge_hub_rococo_runtime::ParachainSystem,
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
Balances: bridge_hub_rococo_runtime::Balances,
}
},
// AssetHubRococo (aka Rockmine/Rockmine2) mirrors AssetHubKusama
pub struct AssetHubRococo {
genesis = asset_hub_polkadot::genesis(),
genesis = asset_hub_kusama::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_polkadot_runtime::Runtime,
RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall,
RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent,
XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue,
LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId,
System: asset_hub_polkadot_runtime::System,
Balances: asset_hub_polkadot_runtime::Balances,
ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem,
ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo,
runtime = asset_hub_kusama_runtime,
core = {
XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue,
LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId,
ParachainInfo: asset_hub_kusama_runtime::ParachainInfo,
},
pallets_extra = {
PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm,
Assets: asset_hub_polkadot_runtime::Assets,
pallets = {
PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm,
Assets: asset_hub_kusama_runtime::Assets,
}
},
// Wococo Parachains
pub struct BridgeHubWococo {
genesis = bridge_hub_rococo::genesis(),
on_init = (),
runtime = {
Runtime: bridge_hub_rococo_runtime::Runtime,
RuntimeOrigin: bridge_hub_rococo_runtime::RuntimeOrigin,
RuntimeCall: bridge_hub_rococo_runtime::RuntimeCall,
RuntimeEvent: bridge_hub_rococo_runtime::RuntimeEvent,
runtime = bridge_hub_rococo_runtime,
core = {
XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue,
DmpMessageHandler: bridge_hub_rococo_runtime::DmpQueue,
LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId,
System: bridge_hub_rococo_runtime::System,
Balances: bridge_hub_rococo_runtime::Balances,
ParachainSystem: bridge_hub_rococo_runtime::ParachainSystem,
ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm,
}
},
pub struct AssetHubWococo {
genesis = asset_hub_polkadot::genesis(),
on_init = (),
runtime = {
Runtime: asset_hub_polkadot_runtime::Runtime,
RuntimeOrigin: asset_hub_polkadot_runtime::RuntimeOrigin,
RuntimeCall: asset_hub_polkadot_runtime::RuntimeCall,
RuntimeEvent: asset_hub_polkadot_runtime::RuntimeEvent,
runtime = asset_hub_polkadot_runtime,
core = {
XcmpMessageHandler: asset_hub_polkadot_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_polkadot_runtime::DmpQueue,
LocationToAccountId: asset_hub_polkadot_runtime::xcm_config::LocationToAccountId,
System: asset_hub_polkadot_runtime::System,
Balances: asset_hub_polkadot_runtime::Balances,
ParachainSystem: asset_hub_polkadot_runtime::ParachainSystem,
ParachainInfo: asset_hub_polkadot_runtime::ParachainInfo,
},
pallets_extra = {
pallets = {
PolkadotXcm: asset_hub_polkadot_runtime::PolkadotXcm,
Assets: asset_hub_polkadot_runtime::Assets,
}
},
pub struct PenpalRococoA {
genesis = penpal::genesis(penpal::PARA_ID_A),
on_init = (),
runtime = penpal_runtime,
core = {
XcmpMessageHandler: penpal_runtime::XcmpQueue,
DmpMessageHandler: penpal_runtime::DmpQueue,
LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId,
ParachainInfo: penpal_runtime::ParachainInfo,
},
pallets = {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
}
}
}
@@ -405,9 +371,10 @@ decl_test_networks! {
relay_chain = Polkadot,
parachains = vec![
AssetHubPolkadot,
PenpalPolkadot,
Collectives,
BridgeHubPolkadot,
PenpalPolkadotA,
PenpalPolkadotB,
],
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
// bridge = PolkadotKusamaMockBridge
@@ -417,8 +384,9 @@ decl_test_networks! {
relay_chain = Kusama,
parachains = vec![
AssetHubKusama,
PenpalKusama,
PenpalKusamaA,
BridgeHubKusama,
PenpalKusamaB,
],
// TODO: uncomment when https://github.com/paritytech/cumulus/pull/2528 is merged
// bridge = KusamaPolkadotMockBridge
@@ -428,7 +396,7 @@ decl_test_networks! {
relay_chain = Westend,
parachains = vec![
AssetHubWestend,
PenpalWestend,
PenpalWestendA,
],
bridge = ()
},
@@ -437,6 +405,7 @@ decl_test_networks! {
parachains = vec![
AssetHubRococo,
BridgeHubRococo,
PenpalRococoA,
],
bridge = RococoWococoMockBridge
},
@@ -474,6 +443,51 @@ decl_test_bridges! {
// }
}
// Polkadot implementation
impl_accounts_helpers_for_relay_chain!(Polkadot);
impl_assert_events_helpers_for_relay_chain!(Polkadot);
impl_hrmp_channels_helpers_for_relay_chain!(Polkadot);
// Kusama implementation
impl_accounts_helpers_for_relay_chain!(Kusama);
impl_assert_events_helpers_for_relay_chain!(Kusama);
impl_hrmp_channels_helpers_for_relay_chain!(Kusama);
// Westend implementation
impl_accounts_helpers_for_relay_chain!(Westend);
impl_assert_events_helpers_for_relay_chain!(Westend);
// Rococo implementation
impl_accounts_helpers_for_relay_chain!(Rococo);
impl_assert_events_helpers_for_relay_chain!(Rococo);
// Wococo implementation
impl_accounts_helpers_for_relay_chain!(Wococo);
impl_assert_events_helpers_for_relay_chain!(Wococo);
// AssetHubPolkadot implementation
impl_accounts_helpers_for_parachain!(AssetHubPolkadot);
impl_assets_helpers_for_parachain!(AssetHubPolkadot, Polkadot);
impl_assert_events_helpers_for_parachain!(AssetHubPolkadot);
// AssetHubKusama implementation
impl_accounts_helpers_for_parachain!(AssetHubKusama);
impl_assets_helpers_for_parachain!(AssetHubKusama, Kusama);
impl_assert_events_helpers_for_parachain!(AssetHubKusama);
// AssetHubWestend implementation
impl_accounts_helpers_for_parachain!(AssetHubWestend);
impl_assets_helpers_for_parachain!(AssetHubWestend, Westend);
impl_assert_events_helpers_for_parachain!(AssetHubWestend);
// Collectives implementation
impl_accounts_helpers_for_parachain!(Collectives);
impl_assert_events_helpers_for_parachain!(Collectives);
// BridgeHubRococo implementation
impl_accounts_helpers_for_parachain!(BridgeHubRococo);
impl_assert_events_helpers_for_parachain!(BridgeHubRococo);
decl_test_sender_receiver_accounts_parameter_types! {
// Relays
Polkadot { sender: ALICE, receiver: BOB },
@@ -495,7 +509,51 @@ decl_test_sender_receiver_accounts_parameter_types! {
BridgeHubRococo { sender: ALICE, receiver: BOB },
BridgeHubWococo { sender: ALICE, receiver: BOB },
// Penpals
PenpalPolkadot { sender: ALICE, receiver: BOB },
PenpalKusama { sender: ALICE, receiver: BOB },
PenpalWestend { sender: ALICE, receiver: BOB }
PenpalPolkadotA { sender: ALICE, receiver: BOB },
PenpalPolkadotB { sender: ALICE, receiver: BOB },
PenpalKusamaA { sender: ALICE, receiver: BOB },
PenpalKusamaB { sender: ALICE, receiver: BOB },
PenpalWestendA { sender: ALICE, receiver: BOB },
PenpalRococoA { sender: ALICE, receiver: BOB }
}
/// Helper method to build a XCM with a `Transact` instruction and paying for its execution
pub fn xcm_transact_paid_execution(
call: DoubleEncoded<()>,
origin_kind: OriginKind,
native_asset: MultiAsset,
beneficiary: AccountId,
) -> VersionedXcm<()> {
let weight_limit = WeightLimit::Unlimited;
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
let native_assets: MultiAssets = native_asset.clone().into();
VersionedXcm::from(Xcm(vec![
WithdrawAsset(native_assets),
BuyExecution { fees: native_asset, weight_limit },
Transact { require_weight_at_most, origin_kind, call },
RefundSurplus,
DepositAsset {
assets: All.into(),
beneficiary: MultiLocation {
parents: 0,
interior: X1(AccountId32 { network: None, id: beneficiary.into() }),
},
},
]))
}
/// Helper method to build a XCM with a `Transact` instruction without paying for its execution
pub fn xcm_transact_unpaid_execution(
call: DoubleEncoded<()>,
origin_kind: OriginKind,
) -> VersionedXcm<()> {
let weight_limit = WeightLimit::Unlimited;
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
let check_origin = None;
VersionedXcm::from(Xcm(vec![
UnpaidExecution { weight_limit, check_origin },
Transact { require_weight_at_most, origin_kind, call },
]))
}