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:
Squirrel
2023-06-02 13:36:34 +01:00
committed by GitHub
parent 6007549589
commit 7f2c72395a
12 changed files with 533 additions and 8 deletions
@@ -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",
]
@@ -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
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::*;
@@ -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);