diff --git a/cumulus/Cargo.lock b/cumulus/Cargo.lock index 59aa83e787..fa6a016eaa 100644 --- a/cumulus/Cargo.lock +++ b/cumulus/Cargo.lock @@ -555,6 +555,33 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "asset-hub-westend-integration-tests" +version = "1.0.0" +dependencies = [ + "asset-hub-westend-runtime", + "frame-support", + "frame-system", + "integration-tests-common", + "pallet-assets", + "pallet-balances", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime", + "polkadot-runtime-parachains", + "sp-core", + "sp-runtime", + "sp-weights", + "westend-runtime", + "xcm", + "xcm-emulator", + "xcm-executor", +] + [[package]] name = "asset-hub-westend-runtime" version = "0.9.420" @@ -5143,6 +5170,7 @@ version = "1.0.0" dependencies = [ "asset-hub-kusama-runtime", "asset-hub-polkadot-runtime", + "asset-hub-westend-runtime", "bridge-hub-kusama-runtime", "bridge-hub-polkadot-runtime", "collectives-polkadot-runtime", @@ -5173,6 +5201,8 @@ dependencies = [ "sp-core", "sp-runtime", "sp-weights", + "westend-runtime", + "westend-runtime-constants", "xcm", "xcm-emulator", "xcm-executor", diff --git a/cumulus/Cargo.toml b/cumulus/Cargo.toml index d03e720da6..31cfd84550 100644 --- a/cumulus/Cargo.toml +++ b/cumulus/Cargo.toml @@ -55,6 +55,7 @@ members = [ "parachains/integration-tests/emulated/common", "parachains/integration-tests/emulated/assets/asset-hub-kusama", "parachains/integration-tests/emulated/assets/asset-hub-polkadot", + "parachains/integration-tests/emulated/assets/asset-hub-westend", "test/client", "test/relay-sproof-builder", "test/relay-validation-worker-provider", @@ -71,4 +72,3 @@ opt-level = 3 inherits = "release" lto = true codegen-units = 1 - diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml new file mode 100644 index 0000000000..c216a84191 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "asset-hub-westend-integration-tests" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Asset Hub Westend runtime integration tests with xcm-emulator" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +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" } + +# Polkadot +polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +westend-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } + +# Cumulus +parachains-common = { path = "../../../../common" } +penpal-runtime = { path = "../../../../runtimes/testing/penpal" } +asset-hub-westend-runtime = { path = "../../../../runtimes/assets/asset-hub-westend" } + +# Local +xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" } +integration-tests-common = { default-features = false, path = "../../common" } diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs new file mode 100644 index 0000000000..d68aa99c70 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -0,0 +1,29 @@ +pub use codec::Encode; +pub use frame_support::{ + assert_ok, instances::Instance1, pallet_prelude::Weight, traits::fungibles::Inspect, +}; +pub use integration_tests_common::{ + constants::{ + accounts::{ALICE, BOB}, + polkadot::ED as POLKADOT_ED, + PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + }, + AccountId, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, + AssetHubWestendSender, Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, + PenpalWestend, Westend, WestendPallet, WestendReceiver, WestendSender, +}; +pub use polkadot_core_primitives::InboundDownwardMessage; +pub use xcm::{ + prelude::*, + v3::{ + Error, + NetworkId::{Kusama as KusamaId, Polkadot as PolkadotId}, + }, +}; +pub use xcm_emulator::{ + assert_expected_events, bx, cumulus_pallet_dmp_queue, helpers::weight_within_threshold, + Parachain as Para, RelayChain as Relay, TestExt, +}; + +#[cfg(test)] +mod tests; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs new file mode 100644 index 0000000000..996f9fd0aa --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs @@ -0,0 +1,3 @@ +mod reserve_transfer; +mod teleport; +mod transact; diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs new file mode 100644 index 0000000000..b54f654702 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs @@ -0,0 +1,65 @@ +use crate::*; + +#[test] +fn reserve_transfer_native_asset_from_relay_to_assets() { + // Init tests variables + let amount = POLKADOT_ED * 1000; + let relay_sender_balance_before = Westend::account_data_of(WestendSender::get()).free; + let para_receiver_balance_before = + AssetHubWestend::account_data_of(AssetHubWestendReceiver::get()).free; + + let origin = ::RuntimeOrigin::signed(WestendSender::get()); + let assets_para_destination: VersionedMultiLocation = + Westend::child_location_of(AssetHubWestend::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: AssetHubWestendReceiver::get().into() }.into(); + let native_assets: VersionedMultiAssets = (Here, amount).into(); + let fee_asset_item = 0; + let weight_limit = WeightLimit::Unlimited; + + // Send XCM message from Relay Chain + Westend::execute_with(|| { + assert_ok!(::XcmPallet::limited_reserve_transfer_assets( + origin, + bx!(assets_para_destination), + bx!(beneficiary), + bx!(native_assets), + fee_asset_item, + weight_limit, + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) }) => { + weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(731_495_000, 0), *weight), + }, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { + outcome: Outcome::Incomplete(_, Error::UntrustedReserveLocation), + .. + }) => {}, + ] + ); + }); + + // Check if balances are updated accordingly in Relay Chain and Assets Parachain + let relay_sender_balance_after = Westend::account_data_of(WestendSender::get()).free; + let para_sender_balance_after = + AssetHubWestend::account_data_of(AssetHubWestendReceiver::get()).free; + + assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); + assert_eq!(para_sender_balance_after, para_receiver_balance_before); +} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs new file mode 100644 index 0000000000..f17ea75578 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -0,0 +1,62 @@ +use crate::*; + +#[test] +fn teleport_native_assets_from_relay_to_assets_para() { + // Init tests variables + let amount = POLKADOT_ED * 1000; + let relay_sender_balance_before = Westend::account_data_of(WestendSender::get()).free; + let para_receiver_balance_before = + AssetHubWestend::account_data_of(AssetHubWestendReceiver::get()).free; + + let origin = ::RuntimeOrigin::signed(WestendSender::get()); + let assets_para_destination: VersionedMultiLocation = + Westend::child_location_of(AssetHubWestend::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: AssetHubWestendReceiver::get().into() }.into(); + let native_assets: VersionedMultiAssets = (Here, amount).into(); + let fee_asset_item = 0; + let weight_limit = WeightLimit::Unlimited; + + // Send XCM message from Relay Chain + Westend::execute_with(|| { + assert_ok!(::XcmPallet::limited_teleport_assets( + origin, + bx!(assets_para_destination), + bx!(beneficiary), + bx!(native_assets), + fee_asset_item, + weight_limit, + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } }) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == AssetHubWestendReceiver::get().into(), + }, + ] + ); + }); + + // Check if balances are updated accordingly in Relay Chain and Assets Parachain + let relay_sender_balance_after = Westend::account_data_of(WestendSender::get()).free; + let para_sender_balance_after = + AssetHubWestend::account_data_of(AssetHubWestendReceiver::get()).free; + + assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); + assert!(para_sender_balance_after > para_receiver_balance_before); +} diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/transact.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/transact.rs new file mode 100644 index 0000000000..3453ea6991 --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/transact.rs @@ -0,0 +1,58 @@ +use crate::*; + +#[test] +fn transact_sudo_from_relay_to_assets_para() { + // Init tests variables + // Call to be executed in Assets Parachain + const ASSET_ID: u32 = 1; + + let call = ::RuntimeCall::Assets(pallet_assets::Call::< + ::Runtime, + Instance1, + >::force_create { + id: ASSET_ID.into(), + is_sufficient: true, + min_balance: 1000, + owner: AssetHubWestendSender::get().into(), + }) + .encode() + .into(); + + // XcmPallet send arguments + let sudo_origin = ::RuntimeOrigin::root(); + let assets_para_destination: VersionedMultiLocation = + Westend::child_location_of(AssetHubWestend::para_id()).into(); + + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1000000000, 200000); + let origin_kind = OriginKind::Superuser; + let check_origin = None; + + let xcm = VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit, check_origin }, + Transact { require_weight_at_most, origin_kind, call }, + ])); + + // Send XCM message from Relay Chain + Westend::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin, + bx!(assets_para_destination), + bx!(xcm), + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubWestend::execute_with(|| { + assert!(::Assets::asset_exists(ASSET_ID)); + }); +} diff --git a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml index a05dd22979..340ca87499 100644 --- a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml @@ -32,6 +32,8 @@ polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "m polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" } kusama-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" } +westend-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +westend-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" } xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } @@ -43,6 +45,7 @@ cumulus-primitives-core = { path = "../../../../primitives/core" } penpal-runtime = { path = "../../../runtimes/testing/penpal" } asset-hub-polkadot-runtime = { path = "../../../runtimes/assets/asset-hub-polkadot" } asset-hub-kusama-runtime = { path = "../../../runtimes/assets/asset-hub-kusama" } +asset-hub-westend-runtime = { path = "../../../runtimes/assets/asset-hub-westend" } collectives-polkadot-runtime = { path = "../../../runtimes/collectives/collectives-polkadot" } bridge-hub-kusama-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-kusama" } bridge-hub-polkadot-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-polkadot" } @@ -51,4 +54,6 @@ xcm-emulator = { default-features = false, path = "../../../../xcm/xcm-emulator" [features] runtime-benchmarks = [ "kusama-runtime/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", + "westend-runtime/runtime-benchmarks", ] diff --git a/cumulus/parachains/integration-tests/emulated/common/src/constants.rs b/cumulus/parachains/integration-tests/emulated/common/src/constants.rs index a4b3942c52..cd4d321457 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/constants.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/constants.rs @@ -209,6 +209,102 @@ pub mod polkadot { } } +pub mod westend { + use super::*; + use westend_runtime_constants::currency::UNITS as WND; + pub const ED: Balance = westend_runtime_constants::currency::EXISTENTIAL_DEPOSIT; + const ENDOWMENT: u128 = 1_000_000 * WND; + const STASH: u128 = 100 * WND; + + pub fn get_host_config() -> HostConfiguration { + 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, + ..Default::default() + } + } + + fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + im_online: ImOnlineId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + ) -> westend_runtime::SessionKeys { + westend_runtime::SessionKeys { + babe, + grandpa, + im_online, + para_validator, + para_assignment, + authority_discovery, + } + } + + pub fn genesis() -> Storage { + let genesis_config = westend_runtime::GenesisConfig { + system: westend_runtime::SystemConfig { + code: westend_runtime::WASM_BINARY.unwrap().to_vec(), + }, + balances: westend_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ENDOWMENT)) + .collect(), + }, + session: westend_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + westend::session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + x.7.clone(), + ), + ) + }) + .collect::>(), + }, + staking: westend_runtime::StakingConfig { + validator_count: validators::initial_authorities().len() as u32, + minimum_validator_count: 1, + stakers: validators::initial_authorities() + .iter() + .map(|x| { + (x.0.clone(), x.1.clone(), STASH, westend_runtime::StakerStatus::Validator) + }) + .collect(), + invulnerables: validators::initial_authorities() + .iter() + .map(|x| x.0.clone()) + .collect(), + force_era: pallet_staking::Forcing::ForceNone, + slash_reward_fraction: Perbill::from_percent(10), + ..Default::default() + }, + babe: westend_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(westend_runtime::BABE_GENESIS_EPOCH_CONFIG), + }, + configuration: westend_runtime::ConfigurationConfig { config: get_host_config() }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} + // Kusama pub mod kusama { use super::*; @@ -361,6 +457,62 @@ pub mod asset_hub_polkadot { } } +// Asset Hub Westend +pub mod asset_hub_westend { + use super::*; + pub const PARA_ID: u32 = 1000; + pub const ED: Balance = asset_hub_westend_runtime::constants::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = asset_hub_westend_runtime::GenesisConfig { + system: asset_hub_westend_runtime::SystemConfig { + code: asset_hub_westend_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: asset_hub_westend_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: asset_hub_westend_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + }, + collator_selection: asset_hub_westend_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_westend_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + asset_hub_westend_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: asset_hub_westend_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + }; + + genesis_config.build_storage().unwrap() + } +} + // Asset Hub Kusama pub mod asset_hub_kusama { use super::*; diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index 82ab42359e..39e4fbb453 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -2,8 +2,8 @@ pub mod constants; pub use constants::{ accounts::{ALICE, BOB}, - asset_hub_kusama, asset_hub_polkadot, bridge_hub_kusama, bridge_hub_polkadot, collectives, - kusama, penpal, polkadot, + asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama, + bridge_hub_polkadot, collectives, kusama, penpal, polkadot, westend, }; use frame_support::{parameter_types, sp_io, sp_tracing}; pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber}; @@ -16,6 +16,27 @@ use xcm_emulator::{ use xcm_executor::traits::Convert; decl_test_relay_chains! { + #[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, + SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf, + System: westend_runtime::System, + Balances: westend_runtime::Balances, + }, + pallets_extra = { + XcmPallet: westend_runtime::XcmPallet, + Sudo: westend_runtime::Sudo, + } + }, + #[api_version(4)] pub struct Polkadot { genesis = polkadot::genesis(), on_init = (), @@ -34,6 +55,7 @@ decl_test_relay_chains! { XcmPallet: polkadot_runtime::XcmPallet, } }, + #[api_version(4)] pub struct Kusama { genesis = kusama::genesis(), on_init = (), @@ -55,6 +77,29 @@ decl_test_relay_chains! { } decl_test_parachains! { + // Westend + 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, + 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 = { + PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm, + Assets: asset_hub_westend_runtime::Assets, + ForeignAssets: asset_hub_westend_runtime::ForeignAssets, + } + }, // Polkadot pub struct AssetHubPolkadot { genesis = asset_hub_polkadot::genesis(), @@ -98,6 +143,28 @@ decl_test_parachains! { Assets: penpal_runtime::Assets, } }, + pub struct PenpalWestend { + genesis = penpal::genesis(penpal::PARA_ID), + on_init = (), + runtime = { + Runtime: penpal_runtime::Runtime, + RuntimeOrigin: penpal_runtime::RuntimeOrigin, + RuntimeCall: penpal_runtime::RuntimeCall, + RuntimeEvent: penpal_runtime::RuntimeEvent, + 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 = { + PolkadotXcm: penpal_runtime::PolkadotXcm, + Assets: penpal_runtime::Assets, + } + }, + // Kusama pub struct AssetHubKusama { genesis = asset_hub_kusama::genesis(), @@ -221,6 +288,13 @@ decl_test_networks! { PenpalKusama, BHKusama, ], + }, + pub struct WestendMockNet { + relay_chain = Westend, + parachains = vec![ + AssetHubWestend, + PenpalWestend, + ], } } @@ -231,6 +305,12 @@ parameter_types! { // Kusama pub KusamaSender: AccountId = Kusama::account_id_of(ALICE); pub KusamaReceiver: AccountId = Kusama::account_id_of(BOB); + // Westend + pub WestendSender: AccountId = Westend::account_id_of(ALICE); + pub WestendReceiver: AccountId = Westend::account_id_of(BOB); + // Asset Hub Westend + pub AssetHubWestendSender: AccountId = AssetHubWestend::account_id_of(ALICE); + pub AssetHubWestendReceiver: AccountId = AssetHubWestend::account_id_of(BOB); // Asset Hub Polkadot pub AssetHubPolkadotSender: AccountId = AssetHubPolkadot::account_id_of(ALICE); pub AssetHubPolkadotReceiver: AccountId = AssetHubPolkadot::account_id_of(BOB); @@ -243,6 +323,9 @@ parameter_types! { // Penpal Kusama pub PenpalKusamaSender: AccountId = PenpalKusama::account_id_of(ALICE); pub PenpalKusamaReceiver: AccountId = PenpalKusama::account_id_of(BOB); + // Penpal Westend + pub PenpalWestendSender: AccountId = PenpalWestend::account_id_of(ALICE); + pub PenpalWestendReceiver: AccountId = PenpalWestend::account_id_of(BOB); // Collectives pub CollectivesSender: AccountId = Collectives::account_id_of(ALICE); pub CollectivesReceiver: AccountId = Collectives::account_id_of(BOB); diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index a31d7c5b7e..03838d2909 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -195,6 +195,7 @@ pub trait Parachain: XcmpMessageHandler + DmpMessageHandler { macro_rules! decl_test_relay_chains { ( $( + #[api_version($api_version:tt)] pub struct $name:ident { genesis = $genesis:expr, on_init = $on_init:expr, @@ -280,7 +281,7 @@ macro_rules! decl_test_relay_chains { } } - $crate::__impl_test_ext_for_relay_chain!($name, $genesis, $on_init); + $crate::__impl_test_ext_for_relay_chain!($name, $genesis, $on_init, $api_version); )+ }; } @@ -288,13 +289,13 @@ macro_rules! decl_test_relay_chains { #[macro_export] macro_rules! __impl_test_ext_for_relay_chain { // entry point: generate ext name - ($name:ident, $genesis:expr, $on_init:expr) => { + ($name:ident, $genesis:expr, $on_init:expr, $api_version:tt) => { $crate::paste::paste! { - $crate::__impl_test_ext_for_relay_chain!(@impl $name, $genesis, $on_init, []); + $crate::__impl_test_ext_for_relay_chain!(@impl $name, $genesis, $on_init, [], []); } }; // impl - (@impl $name:ident, $genesis:expr, $on_init:expr, $ext_name:ident) => { + (@impl $name:ident, $genesis:expr, $on_init:expr, $api_version:ident, $ext_name:ident) => { thread_local! { pub static $ext_name: $crate::RefCell<$crate::sp_io::TestExternalities> = $crate::RefCell::new(<$name>::build_new_ext($genesis)); @@ -330,7 +331,7 @@ macro_rules! __impl_test_ext_for_relay_chain { // send messages if needed $ext_name.with(|v| { v.borrow_mut().execute_with(|| { - use $crate::polkadot_primitives::runtime_api::runtime_decl_for_parachain_host::ParachainHostV4; + use $crate::polkadot_primitives::runtime_api::runtime_decl_for_parachain_host::$api_version; //TODO: mark sent count & filter out sent msg for para_id in <$name>::para_ids() {