mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01:02 +00:00
[xcm-emulator] Chains generic over Network & Integration tests restructure (#2092)
Closes: - #1383 - Declared chains can be now be imported and reused in a different crate. - Chain declaration are now generic over a generic type `N` (the Network) - #1389 - Solved #1383, chains and networks declarations can be restructure to avoid having to compile all chains when running integrations tests where are not needed. - Chains are now declared on its own crate (removed from `integration-tests-common`) - Networks are now declared on its own crate (removed from `integration-tests-common`) - Integration tests will import only the relevant Network crate - `integration-tests-common` is renamed to `emulated-integration-tests-common` All this is necessary to be able to implement what is described here: https://github.com/paritytech/roadmap/issues/56#issuecomment-1777010553 --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
[package]
|
||||
name = "rococo-emulated-chain"
|
||||
version = "0.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
description = "Rococo emulated chain"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0.104"
|
||||
|
||||
# Substrate
|
||||
sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false }
|
||||
sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false }
|
||||
sp-authority-discovery = { path = "../../../../../../../substrate/primitives/authority-discovery", default-features = false }
|
||||
sp-consensus-babe = { path = "../../../../../../../substrate/primitives/consensus/babe", default-features = false }
|
||||
beefy-primitives = { package = "sp-consensus-beefy", path = "../../../../../../../substrate/primitives/consensus/beefy" }
|
||||
grandpa = { package = "sc-consensus-grandpa", path = "../../../../../../../substrate/client/consensus/grandpa", default-features = false }
|
||||
pallet-im-online = { path = "../../../../../../../substrate/frame/im-online", default-features = false }
|
||||
|
||||
# Polkadot
|
||||
polkadot-primitives = { path = "../../../../../../../polkadot/primitives", default-features = false }
|
||||
rococo-runtime-constants = { path = "../../../../../../../polkadot/runtime/rococo/constants", default-features = false }
|
||||
rococo-runtime = { path = "../../../../../../../polkadot/runtime/rococo" }
|
||||
|
||||
# Cumulus
|
||||
parachains-common = { path = "../../../../../../parachains/common" }
|
||||
emulated-integration-tests-common = { path = "../../../common", default-features = false }
|
||||
@@ -0,0 +1,101 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Substrate
|
||||
use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId;
|
||||
use grandpa::AuthorityId as GrandpaId;
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_consensus_babe::AuthorityId as BabeId;
|
||||
use sp_core::{sr25519, storage::Storage};
|
||||
|
||||
// Polkadot
|
||||
use polkadot_primitives::{AssignmentId, ValidatorId};
|
||||
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
accounts, build_genesis_storage_legacy, get_account_id_from_seed, get_from_seed,
|
||||
get_host_config, validators,
|
||||
};
|
||||
use parachains_common::Balance;
|
||||
use rococo_runtime_constants::currency::UNITS as ROC;
|
||||
|
||||
pub const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT;
|
||||
const ENDOWMENT: u128 = 1_000_000 * ROC;
|
||||
|
||||
fn session_keys(
|
||||
babe: BabeId,
|
||||
grandpa: GrandpaId,
|
||||
im_online: ImOnlineId,
|
||||
para_validator: ValidatorId,
|
||||
para_assignment: AssignmentId,
|
||||
authority_discovery: AuthorityDiscoveryId,
|
||||
beefy: BeefyId,
|
||||
) -> rococo_runtime::SessionKeys {
|
||||
rococo_runtime::SessionKeys {
|
||||
babe,
|
||||
grandpa,
|
||||
im_online,
|
||||
para_validator,
|
||||
para_assignment,
|
||||
authority_discovery,
|
||||
beefy,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn genesis() -> Storage {
|
||||
let genesis_config = rococo_runtime::RuntimeGenesisConfig {
|
||||
system: rococo_runtime::SystemConfig::default(),
|
||||
balances: rococo_runtime::BalancesConfig {
|
||||
balances: accounts::init_balances().iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
|
||||
},
|
||||
session: rococo_runtime::SessionConfig {
|
||||
keys: validators::initial_authorities()
|
||||
.iter()
|
||||
.map(|x| {
|
||||
(
|
||||
x.0.clone(),
|
||||
x.0.clone(),
|
||||
session_keys(
|
||||
x.2.clone(),
|
||||
x.3.clone(),
|
||||
x.4.clone(),
|
||||
x.5.clone(),
|
||||
x.6.clone(),
|
||||
x.7.clone(),
|
||||
get_from_seed::<BeefyId>("Alice"),
|
||||
),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
},
|
||||
babe: rococo_runtime::BabeConfig {
|
||||
authorities: Default::default(),
|
||||
epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG),
|
||||
..Default::default()
|
||||
},
|
||||
sudo: rococo_runtime::SudoConfig {
|
||||
key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
||||
},
|
||||
configuration: rococo_runtime::ConfigurationConfig { config: get_host_config() },
|
||||
registrar: rococo_runtime::RegistrarConfig {
|
||||
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
build_genesis_storage_legacy(&genesis_config, rococo_runtime::WASM_BINARY.unwrap())
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub mod genesis;
|
||||
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain,
|
||||
impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain,
|
||||
xcm_emulator::decl_test_relay_chains,
|
||||
};
|
||||
|
||||
// Rococo declaration
|
||||
decl_test_relay_chains! {
|
||||
#[api_version(8)]
|
||||
pub struct Rococo {
|
||||
genesis = genesis::genesis(),
|
||||
on_init = (),
|
||||
runtime = rococo_runtime,
|
||||
core = {
|
||||
SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter,
|
||||
},
|
||||
pallets = {
|
||||
XcmPallet: rococo_runtime::XcmPallet,
|
||||
Sudo: rococo_runtime::Sudo,
|
||||
Balances: rococo_runtime::Balances,
|
||||
Hrmp: rococo_runtime::Hrmp,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// Rococo implementation
|
||||
impl_accounts_helpers_for_relay_chain!(Rococo);
|
||||
impl_assert_events_helpers_for_relay_chain!(Rococo);
|
||||
impl_hrmp_channels_helpers_for_relay_chain!(Rococo);
|
||||
impl_send_transact_helpers_for_relay_chain!(Rococo);
|
||||
@@ -0,0 +1,30 @@
|
||||
[package]
|
||||
name = "westend-emulated-chain"
|
||||
version = "0.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
description = "Westend emulated chain"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0.104"
|
||||
|
||||
# Substrate
|
||||
sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false }
|
||||
sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false }
|
||||
sp-authority-discovery = { path = "../../../../../../../substrate/primitives/authority-discovery", default-features = false }
|
||||
sp-consensus-babe = { path = "../../../../../../../substrate/primitives/consensus/babe", default-features = false }
|
||||
beefy-primitives = { package = "sp-consensus-beefy", path = "../../../../../../../substrate/primitives/consensus/beefy" }
|
||||
grandpa = { package = "sc-consensus-grandpa", path = "../../../../../../../substrate/client/consensus/grandpa", default-features = false }
|
||||
pallet-im-online = { path = "../../../../../../../substrate/frame/im-online", default-features = false }
|
||||
pallet-staking = { path = "../../../../../../../substrate/frame/staking", default-features = false }
|
||||
|
||||
# Polkadot
|
||||
polkadot-primitives = { path = "../../../../../../../polkadot/primitives", default-features = false }
|
||||
westend-runtime-constants = { path = "../../../../../../../polkadot/runtime/westend/constants", default-features = false }
|
||||
westend-runtime = { path = "../../../../../../../polkadot/runtime/westend" }
|
||||
|
||||
# Cumulus
|
||||
parachains-common = { path = "../../../../../../parachains/common" }
|
||||
emulated-integration-tests-common = { path = "../../../common", default-features = false }
|
||||
@@ -0,0 +1,109 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Substrate
|
||||
use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId;
|
||||
use grandpa::AuthorityId as GrandpaId;
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_consensus_babe::AuthorityId as BabeId;
|
||||
use sp_core::storage::Storage;
|
||||
use sp_runtime::Perbill;
|
||||
|
||||
// Polkadot
|
||||
use polkadot_primitives::{AssignmentId, ValidatorId};
|
||||
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
accounts, build_genesis_storage_legacy, get_from_seed, get_host_config, validators,
|
||||
};
|
||||
use parachains_common::Balance;
|
||||
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;
|
||||
|
||||
fn session_keys(
|
||||
babe: BabeId,
|
||||
grandpa: GrandpaId,
|
||||
im_online: ImOnlineId,
|
||||
para_validator: ValidatorId,
|
||||
para_assignment: AssignmentId,
|
||||
authority_discovery: AuthorityDiscoveryId,
|
||||
beefy: BeefyId,
|
||||
) -> westend_runtime::SessionKeys {
|
||||
westend_runtime::SessionKeys {
|
||||
babe,
|
||||
grandpa,
|
||||
im_online,
|
||||
para_validator,
|
||||
para_assignment,
|
||||
authority_discovery,
|
||||
beefy,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn genesis() -> Storage {
|
||||
let genesis_config = westend_runtime::RuntimeGenesisConfig {
|
||||
system: westend_runtime::SystemConfig::default(),
|
||||
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(),
|
||||
session_keys(
|
||||
x.2.clone(),
|
||||
x.3.clone(),
|
||||
x.4.clone(),
|
||||
x.5.clone(),
|
||||
x.6.clone(),
|
||||
x.7.clone(),
|
||||
get_from_seed::<BeefyId>("Alice"),
|
||||
),
|
||||
)
|
||||
})
|
||||
.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),
|
||||
..Default::default()
|
||||
},
|
||||
configuration: westend_runtime::ConfigurationConfig { config: get_host_config() },
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
build_genesis_storage_legacy(&genesis_config, westend_runtime::WASM_BINARY.unwrap())
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub mod genesis;
|
||||
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain,
|
||||
impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain,
|
||||
xcm_emulator::decl_test_relay_chains,
|
||||
};
|
||||
|
||||
// Westend declaration
|
||||
decl_test_relay_chains! {
|
||||
#[api_version(8)]
|
||||
pub struct Westend {
|
||||
genesis = genesis::genesis(),
|
||||
on_init = (),
|
||||
runtime = westend_runtime,
|
||||
core = {
|
||||
SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf,
|
||||
},
|
||||
pallets = {
|
||||
XcmPallet: westend_runtime::XcmPallet,
|
||||
Sudo: westend_runtime::Sudo,
|
||||
Balances: westend_runtime::Balances,
|
||||
Treasury: westend_runtime::Treasury,
|
||||
AssetRate: westend_runtime::AssetRate,
|
||||
Hrmp: westend_runtime::Hrmp,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// Westend implementation
|
||||
impl_accounts_helpers_for_relay_chain!(Westend);
|
||||
impl_assert_events_helpers_for_relay_chain!(Westend);
|
||||
impl_hrmp_channels_helpers_for_relay_chain!(Westend);
|
||||
impl_send_transact_helpers_for_relay_chain!(Westend);
|
||||
@@ -0,0 +1,30 @@
|
||||
[package]
|
||||
name = "wococo-emulated-chain"
|
||||
version = "0.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
description = "Wococo emulated chain"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0.104"
|
||||
|
||||
# Substrate
|
||||
sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false }
|
||||
sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false }
|
||||
sp-authority-discovery = { path = "../../../../../../../substrate/primitives/authority-discovery", default-features = false }
|
||||
sp-consensus-babe = { path = "../../../../../../../substrate/primitives/consensus/babe", default-features = false }
|
||||
beefy-primitives = { package = "sp-consensus-beefy", path = "../../../../../../../substrate/primitives/consensus/beefy" }
|
||||
grandpa = { package = "sc-consensus-grandpa", path = "../../../../../../../substrate/client/consensus/grandpa", default-features = false }
|
||||
pallet-im-online = { path = "../../../../../../../substrate/frame/im-online", default-features = false }
|
||||
|
||||
# Polkadot
|
||||
polkadot-primitives = { path = "../../../../../../../polkadot/primitives", default-features = false }
|
||||
rococo-runtime-constants = { path = "../../../../../../../polkadot/runtime/rococo/constants", default-features = false }
|
||||
rococo-runtime = { path = "../../../../../../../polkadot/runtime/rococo" }
|
||||
|
||||
# Cumulus
|
||||
parachains-common = { path = "../../../../../../parachains/common" }
|
||||
emulated-integration-tests-common = { path = "../../../common", default-features = false }
|
||||
rococo-emulated-chain = { path = "../rococo" }
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Cumulus
|
||||
use emulated_integration_tests_common::{
|
||||
impl_accounts_helpers_for_relay_chain, impl_assert_events_helpers_for_relay_chain,
|
||||
impl_hrmp_channels_helpers_for_relay_chain, impl_send_transact_helpers_for_relay_chain,
|
||||
xcm_emulator::decl_test_relay_chains,
|
||||
};
|
||||
|
||||
// Wococo declaration
|
||||
decl_test_relay_chains! {
|
||||
#[api_version(8)]
|
||||
pub struct Wococo {
|
||||
genesis = rococo_emulated_chain::genesis::genesis(),
|
||||
on_init = (),
|
||||
runtime = rococo_runtime,
|
||||
core = {
|
||||
SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter,
|
||||
},
|
||||
pallets = {
|
||||
XcmPallet: rococo_runtime::XcmPallet,
|
||||
Sudo: rococo_runtime::Sudo,
|
||||
Balances: rococo_runtime::Balances,
|
||||
Hrmp: rococo_runtime::Hrmp,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// Wococo implementation
|
||||
impl_accounts_helpers_for_relay_chain!(Wococo);
|
||||
impl_assert_events_helpers_for_relay_chain!(Wococo);
|
||||
impl_hrmp_channels_helpers_for_relay_chain!(Wococo);
|
||||
impl_send_transact_helpers_for_relay_chain!(Wococo);
|
||||
Reference in New Issue
Block a user