-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(xcm): reserver transfer + xcm emulator (#18)
* feat: XCM emulator * fmt * Removed unnecessary dependency * fmt * refactor: moved rococo_network.rs to lib.rs + cleaning up * chore: update toml and comment * chore: update .toml * style: cargo fmt * style: remove trailing space * fix: add deps std feature * chore: update .toml to use default-features = false * chore: use std features * chore: add try-runtime and runtime-benchmark features * fix(deps): fix features * refactor(deps): copy constants to tests to avoid unnecessary compilation * fix(integration-test): move para_id out of reserved range * test: remove irrelevant tests * test(xcm): reserve transfer to relay * feat(xcm): reserve transfers to relay/asset hub * refactor(integration-tests): simplify crate name * fix: update pop para id * fix: reduce visibility, address clippy warning * refactor: uplift network declaration --------- Co-authored-by: Peter White <[email protected]> Co-authored-by: Frank Bell <[email protected]>
- Loading branch information
1 parent
56288e9
commit b2dec1e
Showing
15 changed files
with
2,002 additions
and
164 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
[package] | ||
name = "integration-tests" | ||
authors.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
codec.workspace = true | ||
|
||
# Substrate | ||
frame-support.workspace = true | ||
pallet-assets.workspace = true | ||
pallet-balances.workspace = true | ||
pallet-message-queue.workspace = true | ||
sp-core.workspace = true | ||
sp-authority-discovery.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 | ||
|
||
# Cumulus | ||
asset-hub-rococo-runtime.workspace = true | ||
asset-test-utils.workspace = true | ||
cumulus-primitives-core.workspace = true | ||
emulated-integration-tests-common.workspace = true | ||
|
||
# Local | ||
pop-runtime.workspace = true | ||
|
||
[dev-dependencies] | ||
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt", "std", "tracing-log"] } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"asset-hub-rococo-runtime/std", | ||
"cumulus-primitives-core/std", | ||
"frame-support/std", | ||
"pallet-assets/std", | ||
"pallet-balances/std", | ||
"pallet-message-queue/std", | ||
"polkadot-primitives/std", | ||
"pop-runtime/std", | ||
"rococo-runtime-constants/std", | ||
"rococo-runtime/std", | ||
"sp-authority-discovery/std", | ||
"sp-consensus-babe/std", | ||
"sp-consensus-beefy/std", | ||
"sp-consensus-grandpa/std", | ||
"sp-core/std", | ||
"sp-runtime/std", | ||
"xcm-executor/std", | ||
"xcm/std", | ||
] | ||
|
||
runtime-benchmarks = [ | ||
"asset-hub-rococo-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", | ||
"polkadot-primitives/runtime-benchmarks", | ||
"pop-runtime/runtime-benchmarks", | ||
"rococo-runtime/runtime-benchmarks", | ||
"sp-runtime/runtime-benchmarks", | ||
"xcm-executor/runtime-benchmarks", | ||
] | ||
|
||
try-runtime = [ | ||
"asset-hub-rococo-runtime/try-runtime", | ||
"frame-support/try-runtime", | ||
"pallet-assets/try-runtime", | ||
"pallet-balances/std", | ||
"pallet-message-queue/try-runtime", | ||
"pop-runtime/try-runtime", | ||
"rococo-runtime/try-runtime", | ||
"sp-runtime/try-runtime", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use emulated_integration_tests_common::{ | ||
accounts, build_genesis_storage, collators, SAFE_XCM_VERSION, | ||
}; | ||
use pop_runtime::Balance; | ||
use sp_core::storage::Storage; | ||
|
||
pub(crate) const PARA_ID: u32 = 1000; | ||
pub(crate) const ED: Balance = rococo_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; | ||
|
||
pub(crate) fn genesis() -> Storage { | ||
let genesis_config = asset_hub_rococo_runtime::RuntimeGenesisConfig { | ||
system: asset_hub_rococo_runtime::SystemConfig::default(), | ||
balances: asset_hub_rococo_runtime::BalancesConfig { | ||
balances: accounts::init_balances() | ||
.iter() | ||
.cloned() | ||
.map(|k| (k, ED * 4096 * 4096)) | ||
.collect(), | ||
}, | ||
parachain_info: asset_hub_rococo_runtime::ParachainInfoConfig { | ||
parachain_id: PARA_ID.into(), | ||
..Default::default() | ||
}, | ||
collator_selection: asset_hub_rococo_runtime::CollatorSelectionConfig { | ||
invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), | ||
candidacy_bond: ED * 16, | ||
..Default::default() | ||
}, | ||
session: asset_hub_rococo_runtime::SessionConfig { | ||
keys: collators::invulnerables() | ||
.into_iter() | ||
.map(|(acc, aura)| { | ||
( | ||
acc.clone(), // account id | ||
acc, // validator id | ||
asset_hub_rococo_runtime::SessionKeys { aura }, // session keys | ||
) | ||
}) | ||
.collect(), | ||
}, | ||
polkadot_xcm: asset_hub_rococo_runtime::PolkadotXcmConfig { | ||
safe_xcm_version: Some(SAFE_XCM_VERSION), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}; | ||
|
||
build_genesis_storage( | ||
&genesis_config, | ||
asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
pub(crate) mod genesis; | ||
|
||
use crate::chains::rococo::Rococo; | ||
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; | ||
|
||
// AssetHubRococo Parachain declaration | ||
decl_test_parachains! { | ||
pub struct AssetHubRococo { | ||
genesis = genesis::genesis(), | ||
on_init = { | ||
asset_hub_rococo_runtime::AuraExt::on_initialize(1); | ||
}, | ||
runtime = asset_hub_rococo_runtime, | ||
core = { | ||
XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue, | ||
LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId, | ||
ParachainInfo: asset_hub_rococo_runtime::ParachainInfo, | ||
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, | ||
}, | ||
pallets = { | ||
PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm, | ||
Assets: asset_hub_rococo_runtime::Assets, | ||
ForeignAssets: asset_hub_rococo_runtime::ForeignAssets, | ||
Balances: asset_hub_rococo_runtime::Balances, | ||
} | ||
}, | ||
} | ||
|
||
// AssetHubRococo implementation | ||
impl_accounts_helpers_for_parachain!(AssetHubRococo); | ||
impl_assert_events_helpers_for_parachain!(AssetHubRococo); | ||
impl_assets_helpers_for_parachain!(AssetHubRococo, Rococo); | ||
impl_foreign_assets_helpers_for_parachain!(AssetHubRococo, Rococo); | ||
impl_xcm_helpers_for_parachain!(AssetHubRococo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub(crate) mod asset_hub_rococo; | ||
pub(crate) mod pop_network; | ||
pub(crate) mod rococo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use emulated_integration_tests_common::{accounts, build_genesis_storage, collators}; | ||
use pop_runtime::Balance; | ||
use sp_core::storage::Storage; | ||
|
||
pub(crate) const ED: Balance = pop_runtime::EXISTENTIAL_DEPOSIT; | ||
const PARA_ID: u32 = 9090; | ||
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; | ||
|
||
pub(crate) fn genesis() -> Storage { | ||
let genesis_config = pop_runtime::RuntimeGenesisConfig { | ||
system: pop_runtime::SystemConfig::default(), | ||
balances: pop_runtime::BalancesConfig { | ||
balances: accounts::init_balances() | ||
.iter() | ||
.cloned() | ||
.map(|k| (k, ED * 4096 * 4096)) | ||
.collect(), | ||
}, | ||
parachain_info: pop_runtime::ParachainInfoConfig { | ||
parachain_id: PARA_ID.into(), | ||
..Default::default() | ||
}, | ||
collator_selection: pop_runtime::CollatorSelectionConfig { | ||
invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), | ||
candidacy_bond: ED * 16, | ||
..Default::default() | ||
}, | ||
session: pop_runtime::SessionConfig { | ||
keys: collators::invulnerables() | ||
.into_iter() | ||
.map(|(acc, aura)| { | ||
( | ||
acc.clone(), // account id | ||
acc, // validator id | ||
pop_runtime::SessionKeys { aura }, // session keys | ||
) | ||
}) | ||
.collect(), | ||
}, | ||
polkadot_xcm: pop_runtime::PolkadotXcmConfig { | ||
safe_xcm_version: Some(SAFE_XCM_VERSION), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}; | ||
|
||
build_genesis_storage( | ||
&genesis_config, | ||
pop_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
pub(crate) mod genesis; | ||
|
||
use crate::chains::rococo::Rococo; | ||
use emulated_integration_tests_common::{ | ||
impl_accounts_helpers_for_parachain, impl_assert_events_helpers_for_parachain, | ||
impl_assets_helpers_for_parachain, impl_xcm_helpers_for_parachain, impls::Parachain, | ||
xcm_emulator::decl_test_parachains, | ||
}; | ||
use frame_support::traits::OnInitialize; | ||
|
||
// PopNetwork Parachain declaration | ||
decl_test_parachains! { | ||
pub struct PopNetwork { | ||
genesis = genesis::genesis(), | ||
on_init = { | ||
pop_runtime::AuraExt::on_initialize(1); | ||
}, | ||
runtime = pop_runtime, | ||
core = { | ||
XcmpMessageHandler: pop_runtime::XcmpQueue, | ||
LocationToAccountId: pop_runtime::xcm_config::LocationToAccountId, | ||
ParachainInfo: pop_runtime::ParachainInfo, | ||
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, | ||
}, | ||
pallets = { | ||
PolkadotXcm: pop_runtime::PolkadotXcm, | ||
Assets: pop_runtime::Assets, | ||
Balances: pop_runtime::Balances, | ||
} | ||
}, | ||
} | ||
|
||
// PopNetwork implementation | ||
impl_accounts_helpers_for_parachain!(PopNetwork); | ||
impl_assert_events_helpers_for_parachain!(PopNetwork); | ||
impl_assets_helpers_for_parachain!(PopNetwork, Rococo); | ||
impl_xcm_helpers_for_parachain!(PopNetwork); |
Oops, something went wrong.