Skip to content

Commit

Permalink
refactor: migrate integration tests to paseo (r0gue-io#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilrobot-01 authored and chungquantin committed Aug 12, 2024
1 parent 9f5fb0f commit 8395045
Show file tree
Hide file tree
Showing 15 changed files with 1,120 additions and 1,238 deletions.
1,674 changes: 769 additions & 905 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ substrate-wasm-builder = "19.0.0"
substrate-build-script-utils = "11.0.0"

# Local
pop-runtime-devnet = { path = "runtime/devnet", default-features = true } # default-features=true required for `-p pop-node` builds
pop-runtime-testnet = { path = "runtime/testnet", default-features = true } # default-features=true required for `-p pop-node` builds
pop-runtime-devnet = { path = "runtime/devnet", default-features = true, features = [
"experimental",
] } # default-features=true required for `-p pop-node` builds
pop-runtime-testnet = { path = "runtime/testnet", default-features = true, features = [
"experimental",
] } # default-features=true required for `-p pop-node` builds
pop-runtime-common = { path = "runtime/common", default-features = false }
pop-primitives = { path = "./primitives", default-features = false }

Expand Down Expand Up @@ -163,3 +167,9 @@ cumulus-client-consensus-aura = "0.9.0"
cumulus-client-consensus-common = "0.9.0"
cumulus-client-consensus-proposer = "0.9.0"
cumulus-client-service = "0.9.0"


# Paseo
asset-hub-paseo-runtime = { git = "https://github.com/paseo-network/runtimes/", tag = "v1.2.5-system-chains", default-features = false }
paseo-runtime = { git = "https://github.com/paseo-network/runtimes/", tag = "v1.2.5-system-chains", default-features = false }
paseo-runtime-constants = { git = "https://github.com/paseo-network/runtimes/", tag = "v1.2.5-system-chains", default-features = false }
24 changes: 14 additions & 10 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,50 @@ pallet-balances.workspace = true
pallet-message-queue.workspace = true
sp-core.workspace = true
sp-authority-discovery.workspace = true
sp-consensus-aura.workspace = true
sp-consensus-babe.workspace = true
sp-consensus-beefy.workspace = true
sp-consensus-grandpa.workspace = true
sp-runtime.workspace = true

# Polkadot
polkadot-primitives.workspace = true
rococo-runtime-constants.workspace = true
rococo-runtime.workspace = true
xcm.workspace = true
xcm-executor.workspace = true
polkadot-runtime-parachains.workspace = true
pallet-xcm.workspace = true

# Cumulus
asset-hub-rococo-runtime.workspace = true
asset-test-utils.workspace = true
cumulus-primitives-core.workspace = true
emulated-integration-tests-common.workspace = true

# Paseo
asset-hub-paseo-runtime.workspace = true
paseo-runtime.workspace = true
paseo-runtime-constants.workspace = true

# Local
pop-runtime-devnet.workspace = true
pop-runtime-common.workspace = true

[features]
default = ["std"]
std = [
"asset-hub-rococo-runtime/std",
"asset-hub-paseo-runtime/std",
"cumulus-primitives-core/std",
"frame-support/std",
"pallet-assets/std",
"pallet-balances/std",
"pallet-message-queue/std",
"pallet-xcm/std",
"paseo-runtime/std",
"paseo-runtime-constants/std",
"polkadot-primitives/std",
"polkadot-runtime-parachains/std",
"pop-runtime-devnet/std",
"rococo-runtime-constants/std",
"rococo-runtime/std",
"sp-authority-discovery/std",
"sp-consensus-aura/std",
"sp-consensus-babe/std",
"sp-consensus-beefy/std",
"sp-consensus-grandpa/std",
Expand All @@ -67,26 +71,26 @@ std = [
]

runtime-benchmarks = [
"asset-hub-rococo-runtime/runtime-benchmarks",
"asset-hub-paseo-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"paseo-runtime/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"pop-runtime-devnet/runtime-benchmarks",
"rococo-runtime/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
]

try-runtime = [
"asset-hub-rococo-runtime/try-runtime",
"asset-hub-paseo-runtime/try-runtime",
"frame-support/try-runtime",
"pallet-assets/try-runtime",
"pallet-balances/std",
"pallet-message-queue/try-runtime",
"paseo-runtime/try-runtime",
"pop-runtime-devnet/try-runtime",
"rococo-runtime/try-runtime",
"sp-runtime/try-runtime",
]
60 changes: 60 additions & 0 deletions integration-tests/src/chains/asset_hub_paseo/genesis.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use emulated_integration_tests_common::{
accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, SAFE_XCM_VERSION,
};
use polkadot_primitives::{AccountId, Balance};
use sp_core::{sr25519, storage::Storage};

pub(crate) const PARA_ID: u32 = 1000;
pub(crate) const ED: Balance = paseo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10;

pub(crate) fn genesis() -> Storage {
let genesis_config = asset_hub_paseo_runtime::RuntimeGenesisConfig {
system: asset_hub_paseo_runtime::SystemConfig::default(),
balances: asset_hub_paseo_runtime::BalancesConfig {
balances: accounts::init_balances()
.iter()
.cloned()
.map(|k| (k, ED * 4096 * 4096))
.collect(),
},
parachain_info: asset_hub_paseo_runtime::ParachainInfoConfig {
parachain_id: PARA_ID.into(),
..Default::default()
},
collator_selection: asset_hub_paseo_runtime::CollatorSelectionConfig {
invulnerables: invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: ED * 16,
..Default::default()
},
session: asset_hub_paseo_runtime::SessionConfig {
keys: invulnerables()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
asset_hub_paseo_runtime::SessionKeys { aura }, // session keys
)
})
.collect(),
},
polkadot_xcm: asset_hub_paseo_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
..Default::default()
};

build_genesis_storage(
&genesis_config,
asset_hub_paseo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
)
}

type AuraId = sp_consensus_aura::ed25519::AuthorityId;
pub fn invulnerables() -> Vec<(AccountId, AuraId)> {
vec![
(get_account_id_from_seed::<sr25519::Public>("Alice"), get_from_seed::<AuraId>("Alice")),
(get_account_id_from_seed::<sr25519::Public>("Bob"), get_from_seed::<AuraId>("Bob")),
]
}
39 changes: 39 additions & 0 deletions integration-tests/src/chains/asset_hub_paseo/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pub(crate) mod genesis;

use crate::chains::paseo::Paseo;
use emulated_integration_tests_common::{
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain,
impl_assets_helpers_for_parachain, impl_foreign_assets_helpers_for_parachain,
impl_xcm_helpers_for_parachain, impls::Parachain, xcm_emulator::decl_test_parachains,
};
use frame_support::traits::OnInitialize;

// AssetHubPaseo Parachain declaration
decl_test_parachains! {
pub struct AssetHubPaseo {
genesis = genesis::genesis(),
on_init = {
asset_hub_paseo_runtime::AuraExt::on_initialize(1);
},
runtime = asset_hub_paseo_runtime,
core = {
XcmpMessageHandler: asset_hub_paseo_runtime::XcmpQueue,
LocationToAccountId: asset_hub_paseo_runtime::xcm_config::LocationToAccountId,
ParachainInfo: asset_hub_paseo_runtime::ParachainInfo,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: asset_hub_paseo_runtime::PolkadotXcm,
Assets: asset_hub_paseo_runtime::Assets,
ForeignAssets: asset_hub_paseo_runtime::ForeignAssets,
Balances: asset_hub_paseo_runtime::Balances,
}
},
}

// AssetHubPaseo implementation
impl_accounts_helpers_for_parachain!(AssetHubPaseo);
impl_assert_events_helpers_for_parachain!(AssetHubPaseo);
impl_assets_helpers_for_parachain!(AssetHubPaseo, Paseo);
impl_foreign_assets_helpers_for_parachain!(AssetHubPaseo, Paseo);
impl_xcm_helpers_for_parachain!(AssetHubPaseo);
52 changes: 0 additions & 52 deletions integration-tests/src/chains/asset_hub_rococo/genesis.rs

This file was deleted.

39 changes: 0 additions & 39 deletions integration-tests/src/chains/asset_hub_rococo/mod.rs

This file was deleted.

4 changes: 2 additions & 2 deletions integration-tests/src/chains/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub(crate) mod asset_hub_rococo;
pub(crate) mod asset_hub_paseo;
pub(crate) mod paseo;
pub(crate) mod pop_network;
pub(crate) mod rococo;
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ use emulated_integration_tests_common::{
accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, get_host_config,
validators,
};
use paseo_runtime_constants::currency::UNITS as PAS;
use polkadot_primitives::{AssignmentId, Balance, ValidatorId};
use rococo_runtime_constants::currency::UNITS as ROC;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{sr25519, storage::Storage};

pub(crate) const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT;
const ENDOWMENT: u128 = 1_000_000 * ROC;
pub(crate) const ED: Balance = paseo_runtime_constants::currency::EXISTENTIAL_DEPOSIT;
const ENDOWMENT: u128 = 1_000_000 * PAS;

fn session_keys(
babe: BabeId,
Expand All @@ -20,8 +20,8 @@ fn session_keys(
para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId,
beefy: BeefyId,
) -> rococo_runtime::SessionKeys {
rococo_runtime::SessionKeys {
) -> paseo_runtime::SessionKeys {
paseo_runtime::SessionKeys {
babe,
grandpa,
para_validator,
Expand All @@ -32,12 +32,12 @@ fn session_keys(
}

pub(crate) fn genesis() -> Storage {
let genesis_config = rococo_runtime::RuntimeGenesisConfig {
system: rococo_runtime::SystemConfig::default(),
balances: rococo_runtime::BalancesConfig {
let genesis_config = paseo_runtime::RuntimeGenesisConfig {
system: paseo_runtime::SystemConfig::default(),
balances: paseo_runtime::BalancesConfig {
balances: accounts::init_balances().iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
},
session: rococo_runtime::SessionConfig {
session: paseo_runtime::SessionConfig {
keys: validators::initial_authorities()
.iter()
.map(|x| {
Expand All @@ -56,21 +56,21 @@ pub(crate) fn genesis() -> Storage {
})
.collect::<Vec<_>>(),
},
babe: rococo_runtime::BabeConfig {
babe: paseo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG),
epoch_config: Some(paseo_runtime::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
sudo: rococo_runtime::SudoConfig {
sudo: paseo_runtime::SudoConfig {
key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
},
configuration: rococo_runtime::ConfigurationConfig { config: get_host_config() },
registrar: rococo_runtime::RegistrarConfig {
configuration: paseo_runtime::ConfigurationConfig { config: get_host_config() },
registrar: paseo_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
..Default::default()
},
..Default::default()
};

build_genesis_storage(&genesis_config, rococo_runtime::WASM_BINARY.unwrap())
build_genesis_storage(&genesis_config, paseo_runtime::WASM_BINARY.unwrap())
}
Loading

0 comments on commit 8395045

Please sign in to comment.