mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
Support westend integration tests (#2649)
* mostly there with westend * add network * initial way to set host api version * 3 tests all passing * Remove duplication * fix runtime-benchmarks * Fix typo --------- Co-authored-by: joepetrowski <joe@parity.io>
This commit is contained in:
Generated
+30
@@ -555,6 +555,33 @@ dependencies = [
|
|||||||
"xcm-executor",
|
"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]]
|
[[package]]
|
||||||
name = "asset-hub-westend-runtime"
|
name = "asset-hub-westend-runtime"
|
||||||
version = "0.9.420"
|
version = "0.9.420"
|
||||||
@@ -5143,6 +5170,7 @@ version = "1.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"asset-hub-kusama-runtime",
|
"asset-hub-kusama-runtime",
|
||||||
"asset-hub-polkadot-runtime",
|
"asset-hub-polkadot-runtime",
|
||||||
|
"asset-hub-westend-runtime",
|
||||||
"bridge-hub-kusama-runtime",
|
"bridge-hub-kusama-runtime",
|
||||||
"bridge-hub-polkadot-runtime",
|
"bridge-hub-polkadot-runtime",
|
||||||
"collectives-polkadot-runtime",
|
"collectives-polkadot-runtime",
|
||||||
@@ -5173,6 +5201,8 @@ dependencies = [
|
|||||||
"sp-core",
|
"sp-core",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
"sp-weights",
|
"sp-weights",
|
||||||
|
"westend-runtime",
|
||||||
|
"westend-runtime-constants",
|
||||||
"xcm",
|
"xcm",
|
||||||
"xcm-emulator",
|
"xcm-emulator",
|
||||||
"xcm-executor",
|
"xcm-executor",
|
||||||
|
|||||||
+1
-1
@@ -55,6 +55,7 @@ members = [
|
|||||||
"parachains/integration-tests/emulated/common",
|
"parachains/integration-tests/emulated/common",
|
||||||
"parachains/integration-tests/emulated/assets/asset-hub-kusama",
|
"parachains/integration-tests/emulated/assets/asset-hub-kusama",
|
||||||
"parachains/integration-tests/emulated/assets/asset-hub-polkadot",
|
"parachains/integration-tests/emulated/assets/asset-hub-polkadot",
|
||||||
|
"parachains/integration-tests/emulated/assets/asset-hub-westend",
|
||||||
"test/client",
|
"test/client",
|
||||||
"test/relay-sproof-builder",
|
"test/relay-sproof-builder",
|
||||||
"test/relay-validation-worker-provider",
|
"test/relay-validation-worker-provider",
|
||||||
@@ -71,4 +72,3 @@ opt-level = 3
|
|||||||
inherits = "release"
|
inherits = "release"
|
||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
[package]
|
||||||
|
name = "asset-hub-westend-integration-tests"
|
||||||
|
version = "1.0.0"
|
||||||
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
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" }
|
||||||
@@ -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;
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
mod reserve_transfer;
|
||||||
|
mod teleport;
|
||||||
|
mod transact;
|
||||||
+65
@@ -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 = <Westend as Relay>::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!(<Westend as WestendPallet>::XcmPallet::limited_reserve_transfer_assets(
|
||||||
|
origin,
|
||||||
|
bx!(assets_para_destination),
|
||||||
|
bx!(beneficiary),
|
||||||
|
bx!(native_assets),
|
||||||
|
fee_asset_item,
|
||||||
|
weight_limit,
|
||||||
|
));
|
||||||
|
|
||||||
|
type RuntimeEvent = <Westend as Relay>::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 = <AssetHubWestend as Para>::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);
|
||||||
|
}
|
||||||
+62
@@ -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 = <Westend as Relay>::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!(<Westend as WestendPallet>::XcmPallet::limited_teleport_assets(
|
||||||
|
origin,
|
||||||
|
bx!(assets_para_destination),
|
||||||
|
bx!(beneficiary),
|
||||||
|
bx!(native_assets),
|
||||||
|
fee_asset_item,
|
||||||
|
weight_limit,
|
||||||
|
));
|
||||||
|
|
||||||
|
type RuntimeEvent = <Westend as Relay>::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 = <AssetHubWestend as Para>::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);
|
||||||
|
}
|
||||||
+58
@@ -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 = <AssetHubWestend as Para>::RuntimeCall::Assets(pallet_assets::Call::<
|
||||||
|
<AssetHubWestend as Para>::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 = <Westend as Relay>::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!(<Westend as WestendPallet>::XcmPallet::send(
|
||||||
|
sudo_origin,
|
||||||
|
bx!(assets_para_destination),
|
||||||
|
bx!(xcm),
|
||||||
|
));
|
||||||
|
|
||||||
|
type RuntimeEvent = <Westend as Relay>::RuntimeEvent;
|
||||||
|
|
||||||
|
assert_expected_events!(
|
||||||
|
Westend,
|
||||||
|
vec![
|
||||||
|
RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {},
|
||||||
|
]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Receive XCM message in Assets Parachain
|
||||||
|
AssetHubWestend::execute_with(|| {
|
||||||
|
assert!(<AssetHubWestend as AssetHubWestendPallet>::Assets::asset_exists(ASSET_ID));
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -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" }
|
polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||||
kusama-runtime = { 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" }
|
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 = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||||
xcm-executor = { 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" }
|
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" }
|
penpal-runtime = { path = "../../../runtimes/testing/penpal" }
|
||||||
asset-hub-polkadot-runtime = { path = "../../../runtimes/assets/asset-hub-polkadot" }
|
asset-hub-polkadot-runtime = { path = "../../../runtimes/assets/asset-hub-polkadot" }
|
||||||
asset-hub-kusama-runtime = { path = "../../../runtimes/assets/asset-hub-kusama" }
|
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" }
|
collectives-polkadot-runtime = { path = "../../../runtimes/collectives/collectives-polkadot" }
|
||||||
bridge-hub-kusama-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-kusama" }
|
bridge-hub-kusama-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-kusama" }
|
||||||
bridge-hub-polkadot-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-polkadot" }
|
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]
|
[features]
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"kusama-runtime/runtime-benchmarks",
|
"kusama-runtime/runtime-benchmarks",
|
||||||
|
"polkadot-runtime/runtime-benchmarks",
|
||||||
|
"westend-runtime/runtime-benchmarks",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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<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,
|
||||||
|
..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::<Vec<_>>(),
|
||||||
|
},
|
||||||
|
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
|
// Kusama
|
||||||
pub mod kusama {
|
pub mod kusama {
|
||||||
use super::*;
|
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
|
// Asset Hub Kusama
|
||||||
pub mod asset_hub_kusama {
|
pub mod asset_hub_kusama {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ pub mod constants;
|
|||||||
|
|
||||||
pub use constants::{
|
pub use constants::{
|
||||||
accounts::{ALICE, BOB},
|
accounts::{ALICE, BOB},
|
||||||
asset_hub_kusama, asset_hub_polkadot, bridge_hub_kusama, bridge_hub_polkadot, collectives,
|
asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama,
|
||||||
kusama, penpal, polkadot,
|
bridge_hub_polkadot, collectives, kusama, penpal, polkadot, westend,
|
||||||
};
|
};
|
||||||
use frame_support::{parameter_types, sp_io, sp_tracing};
|
use frame_support::{parameter_types, sp_io, sp_tracing};
|
||||||
pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber};
|
pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber};
|
||||||
@@ -16,6 +16,27 @@ use xcm_emulator::{
|
|||||||
use xcm_executor::traits::Convert;
|
use xcm_executor::traits::Convert;
|
||||||
|
|
||||||
decl_test_relay_chains! {
|
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 {
|
pub struct Polkadot {
|
||||||
genesis = polkadot::genesis(),
|
genesis = polkadot::genesis(),
|
||||||
on_init = (),
|
on_init = (),
|
||||||
@@ -34,6 +55,7 @@ decl_test_relay_chains! {
|
|||||||
XcmPallet: polkadot_runtime::XcmPallet,
|
XcmPallet: polkadot_runtime::XcmPallet,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
#[api_version(4)]
|
||||||
pub struct Kusama {
|
pub struct Kusama {
|
||||||
genesis = kusama::genesis(),
|
genesis = kusama::genesis(),
|
||||||
on_init = (),
|
on_init = (),
|
||||||
@@ -55,6 +77,29 @@ decl_test_relay_chains! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_test_parachains! {
|
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
|
// Polkadot
|
||||||
pub struct AssetHubPolkadot {
|
pub struct AssetHubPolkadot {
|
||||||
genesis = asset_hub_polkadot::genesis(),
|
genesis = asset_hub_polkadot::genesis(),
|
||||||
@@ -98,6 +143,28 @@ decl_test_parachains! {
|
|||||||
Assets: penpal_runtime::Assets,
|
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
|
// Kusama
|
||||||
pub struct AssetHubKusama {
|
pub struct AssetHubKusama {
|
||||||
genesis = asset_hub_kusama::genesis(),
|
genesis = asset_hub_kusama::genesis(),
|
||||||
@@ -221,6 +288,13 @@ decl_test_networks! {
|
|||||||
PenpalKusama,
|
PenpalKusama,
|
||||||
BHKusama,
|
BHKusama,
|
||||||
],
|
],
|
||||||
|
},
|
||||||
|
pub struct WestendMockNet {
|
||||||
|
relay_chain = Westend,
|
||||||
|
parachains = vec![
|
||||||
|
AssetHubWestend,
|
||||||
|
PenpalWestend,
|
||||||
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +305,12 @@ parameter_types! {
|
|||||||
// Kusama
|
// Kusama
|
||||||
pub KusamaSender: AccountId = Kusama::account_id_of(ALICE);
|
pub KusamaSender: AccountId = Kusama::account_id_of(ALICE);
|
||||||
pub KusamaReceiver: AccountId = Kusama::account_id_of(BOB);
|
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
|
// Asset Hub Polkadot
|
||||||
pub AssetHubPolkadotSender: AccountId = AssetHubPolkadot::account_id_of(ALICE);
|
pub AssetHubPolkadotSender: AccountId = AssetHubPolkadot::account_id_of(ALICE);
|
||||||
pub AssetHubPolkadotReceiver: AccountId = AssetHubPolkadot::account_id_of(BOB);
|
pub AssetHubPolkadotReceiver: AccountId = AssetHubPolkadot::account_id_of(BOB);
|
||||||
@@ -243,6 +323,9 @@ parameter_types! {
|
|||||||
// Penpal Kusama
|
// Penpal Kusama
|
||||||
pub PenpalKusamaSender: AccountId = PenpalKusama::account_id_of(ALICE);
|
pub PenpalKusamaSender: AccountId = PenpalKusama::account_id_of(ALICE);
|
||||||
pub PenpalKusamaReceiver: AccountId = PenpalKusama::account_id_of(BOB);
|
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
|
// Collectives
|
||||||
pub CollectivesSender: AccountId = Collectives::account_id_of(ALICE);
|
pub CollectivesSender: AccountId = Collectives::account_id_of(ALICE);
|
||||||
pub CollectivesReceiver: AccountId = Collectives::account_id_of(BOB);
|
pub CollectivesReceiver: AccountId = Collectives::account_id_of(BOB);
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ pub trait Parachain: XcmpMessageHandler + DmpMessageHandler {
|
|||||||
macro_rules! decl_test_relay_chains {
|
macro_rules! decl_test_relay_chains {
|
||||||
(
|
(
|
||||||
$(
|
$(
|
||||||
|
#[api_version($api_version:tt)]
|
||||||
pub struct $name:ident {
|
pub struct $name:ident {
|
||||||
genesis = $genesis:expr,
|
genesis = $genesis:expr,
|
||||||
on_init = $on_init: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_export]
|
||||||
macro_rules! __impl_test_ext_for_relay_chain {
|
macro_rules! __impl_test_ext_for_relay_chain {
|
||||||
// entry point: generate ext name
|
// 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::paste::paste! {
|
||||||
$crate::__impl_test_ext_for_relay_chain!(@impl $name, $genesis, $on_init, [<EXT_ $name:upper>]);
|
$crate::__impl_test_ext_for_relay_chain!(@impl $name, $genesis, $on_init, [<ParachainHostV $api_version>], [<EXT_ $name:upper>]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// impl
|
// 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! {
|
thread_local! {
|
||||||
pub static $ext_name: $crate::RefCell<$crate::sp_io::TestExternalities>
|
pub static $ext_name: $crate::RefCell<$crate::sp_io::TestExternalities>
|
||||||
= $crate::RefCell::new(<$name>::build_new_ext($genesis));
|
= $crate::RefCell::new(<$name>::build_new_ext($genesis));
|
||||||
@@ -330,7 +331,7 @@ macro_rules! __impl_test_ext_for_relay_chain {
|
|||||||
// send messages if needed
|
// send messages if needed
|
||||||
$ext_name.with(|v| {
|
$ext_name.with(|v| {
|
||||||
v.borrow_mut().execute_with(|| {
|
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
|
//TODO: mark sent count & filter out sent msg
|
||||||
for para_id in <$name>::para_ids() {
|
for para_id in <$name>::para_ids() {
|
||||||
|
|||||||
Reference in New Issue
Block a user