Skip to content

Commit

Permalink
Update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raynaudoe committed Sep 11, 2024
1 parent fde1e6d commit 41766ba
Show file tree
Hide file tree
Showing 29 changed files with 1,483 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ rls*.log
runtime/wasm/target/
substrate.code-workspace
target/
**/tmp_runtime
**/.tmp_runtime
**/tmp_hub
*.log
*.patch
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ paseo-system-emulated-network = { path = "integration-tests/emulated/networks/pa
asset-hub-paseo-emulated-chain = { path = "integration-tests/emulated/chains/parachains/assets/asset-hub-paseo"}
bridge-hub-paseo-emulated-chain = { path = "integration-tests/emulated/chains/parachains/bridges/bridge-hub-paseo"}
penpal-emulated-chain = { path = "integration-tests/emulated/chains/parachains/testing/penpal"}
people-paseo-emulated-chain = { path = "integration-tests/emulated/chains/parachains/people/people-paseo"}
paseo-emulated-chain = { path = "integration-tests/emulated/chains/relays/paseo"}
assert_matches = { version = "1.5.0" }
asset-test-utils = { version = "15.0.0" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ frame-support = { workspace = true, default-features = true }
parachains-common = { workspace = true, default-features = true }
cumulus-primitives-core = { workspace = true, default-features = true }
emulated-integration-tests-common = { workspace = true }
xcm = { workspace = true, default-features = true }
polkadot-parachain-primitives = { workspace = true }

# Runtimes
asset-hub-paseo-runtime = { workspace = true, default-features = true }
paseo-emulated-chain = { workspace = true, default-features = true }
penpal-emulated-chain = {workspace = true, default-features = true}
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,61 @@ use sp_core::storage::Storage;

// Cumulus
use emulated_integration_tests_common::{
accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, SAFE_XCM_VERSION,
accounts, build_genesis_storage, get_account_id_from_seed, get_from_seed, RESERVABLE_ASSET_ID,
SAFE_XCM_VERSION,
};
use frame_support::sp_runtime::traits::AccountIdConversion;
use parachains_common::{AccountId, AuraId, Balance};
use polkadot_parachain_primitives::primitives::Sibling;
use sp_core::sr25519;
use xcm::prelude::*;

pub const PARA_ID: u32 = 1000;
pub const ED: Balance = asset_hub_paseo_runtime::ExistentialDeposit::get();
pub const USDT_ID: u32 = 1984;

frame_support::parameter_types! {
pub AssetHubPaseoAssetOwner: AccountId = get_account_id_from_seed::<sr25519::Public>("Alice");
pub PenpalATeleportableAssetLocation: Location
= Location::new(1, [
Junction::Parachain(penpal_emulated_chain::PARA_ID_A),
Junction::PalletInstance(penpal_emulated_chain::ASSETS_PALLET_ID),
Junction::GeneralIndex(penpal_emulated_chain::TELEPORTABLE_ASSET_ID.into()),
]
);
pub PenpalBTeleportableAssetLocation: Location
= Location::new(1, [
Junction::Parachain(penpal_emulated_chain::PARA_ID_B),
Junction::PalletInstance(penpal_emulated_chain::ASSETS_PALLET_ID),
Junction::GeneralIndex(penpal_emulated_chain::TELEPORTABLE_ASSET_ID.into()),
]
);
pub PenpalASiblingSovereignAccount: AccountId = Sibling::from(penpal_emulated_chain::PARA_ID_A).into_account_truncating();
pub PenpalBSiblingSovereignAccount: AccountId = Sibling::from(penpal_emulated_chain::PARA_ID_B).into_account_truncating();
}

fn invulnerables_asset_hub_paseo() -> 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")),
(
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"),
),
]
}

pub 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)).collect(),
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(),
Expand All @@ -57,8 +92,8 @@ pub fn genesis() -> Storage {
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
acc.clone(), // account id
acc, // validator id
asset_hub_paseo_runtime::SessionKeys { aura }, // session keys
)
})
Expand All @@ -68,11 +103,37 @@ pub fn genesis() -> Storage {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
assets: asset_hub_paseo_runtime::AssetsConfig {
assets: vec![
(RESERVABLE_ASSET_ID, AssetHubPaseoAssetOwner::get(), false, ED),
(USDT_ID, AssetHubPaseoAssetOwner::get(), true, ED),
],
..Default::default()
},
foreign_assets: asset_hub_paseo_runtime::ForeignAssetsConfig {
assets: vec![
// Penpal's teleportable asset representation
(
PenpalATeleportableAssetLocation::get().try_into().unwrap(),
PenpalASiblingSovereignAccount::get(),
false,
ED,
),
(
PenpalBTeleportableAssetLocation::get().try_into().unwrap(),
PenpalBSiblingSovereignAccount::get(),
false,
ED,
),
],
..Default::default()
},
..Default::default()
};

build_genesis_storage(
&genesis_config,
asset_hub_paseo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
asset_hub_paseo_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ use frame_support::traits::OnInitialize;
// Cumulus
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,
impl_assets_helpers_for_parachain, impl_assets_helpers_for_system_parachain,
impl_foreign_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain,
xcm_emulator::decl_test_parachains,
};
use paseo_emulated_chain::Paseo;

Expand Down Expand Up @@ -54,6 +55,7 @@ decl_test_parachains! {
// 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_assets_helpers_for_system_parachain!(AssetHubPaseo, Paseo);
impl_assets_helpers_for_parachain!(AssetHubPaseo);
impl_foreign_assets_helpers_for_parachain!(AssetHubPaseo, xcm::v3::Location);
impl_xcm_helpers_for_parachain!(AssetHubPaseo);
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
// limitations under the License.

// Substrate
use sp_core::storage::Storage;
use sp_core::{sr25519, storage::Storage};

// Cumulus
use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, SAFE_XCM_VERSION,
accounts, build_genesis_storage, collators, get_account_id_from_seed, SAFE_XCM_VERSION,
};
use parachains_common::Balance;

Expand Down Expand Up @@ -46,8 +46,8 @@ pub fn genesis() -> Storage {
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
acc.clone(), // account id
acc, // validator id
bridge_hub_paseo_runtime::SessionKeys { aura }, // session keys
)
})
Expand All @@ -57,6 +57,14 @@ pub fn genesis() -> Storage {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
bridge_kusama_grandpa: bridge_hub_paseo_runtime::BridgeKusamaGrandpaConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>(accounts::BOB)),
..Default::default()
},
bridge_kusama_messages: bridge_hub_paseo_runtime::BridgeKusamaMessagesConfig {
owner: Some(get_account_id_from_seed::<sr25519::Public>(accounts::BOB)),
..Default::default()
},
ethereum_system: bridge_hub_paseo_runtime::EthereumSystemConfig {
para_id: PARA_ID.into(),
asset_hub_para_id: ASSET_HUB_PARA_ID.into(),
Expand All @@ -67,6 +75,7 @@ pub fn genesis() -> Storage {

build_genesis_storage(
&genesis_config,
bridge_hub_paseo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
bridge_hub_paseo_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ cumulus-primitives-core = { workspace = true, default-features = true }
emulated-integration-tests-common = { workspace = true }

# Runtimes
coretime-paseo-runtime = { workspace = true }
coretime-paseo-runtime = { workspace = true, default-features = true }
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use emulated_integration_tests_common::{

// CollectivesPolkadot Parachain declaration
decl_test_parachains! {
pub struct CoretimePolkadot {
pub struct CoretimePaseo {
genesis = genesis::genesis(),
on_init = {
coretime_paseo_runtime::AuraExt::on_initialize(1);
Expand All @@ -47,6 +47,6 @@ decl_test_parachains! {
},
}

// CoretimePolkadot implementation
impl_accounts_helpers_for_parachain!(CoretimePolkadot);
impl_assert_events_helpers_for_parachain!(CoretimePolkadot);
// CoretimePaseo implementation
impl_accounts_helpers_for_parachain!(CoretimePaseo);
impl_assert_events_helpers_for_parachain!(CoretimePaseo);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "people-paseo-emulated-chain"
authors.workspace = true
edition.workspace = true
version.workspace = true
license = "Apache-2.0"
description = "People Paseo emulated chain used for integration tests"
publish = false

[dependencies]

# Substrate
sp-core = { workspace = true, default-features = true }
frame-support = { workspace = true, default-features = true }

# Cumulus
parachains-common = { workspace = true, default-features = true }
cumulus-primitives-core = { workspace = true, default-features = true }
emulated-integration-tests-common = { workspace = true }

# Local
people-paseo-runtime = { workspace = true, default-features = true }
paseo-emulated-chain = { workspace = true, default-features = true }
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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 sp_core::storage::Storage;

// Cumulus
use cumulus_primitives_core::ParaId;
use emulated_integration_tests_common::{build_genesis_storage, collators, SAFE_XCM_VERSION};
use parachains_common::Balance;

pub const PARA_ID: u32 = 1004;
pub const ED: Balance = people_paseo_runtime::ExistentialDeposit::get();

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

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

0 comments on commit 41766ba

Please sign in to comment.