This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
2,962 additions
and
77 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,59 @@ | ||
[package] | ||
name = "integration-tests" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
parity-scale-codec = { workspace = true } | ||
thousands = "0.2.0" | ||
|
||
# Tracing | ||
tracing = { version = "0.1.37" } | ||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } | ||
|
||
# Substrate | ||
frame-system = { workspace = true } | ||
frame-support = { workspace = true } | ||
sp-core = { workspace = true } | ||
sp-runtime = { workspace = true } | ||
pallet-assets = { workspace = true } | ||
|
||
# Cumulus | ||
integration-tests-common = { workspace = true } | ||
xcm-emulator = { workspace = true } | ||
|
||
# Polkadot | ||
polkadot-parachain-primitives = { workspace = true } | ||
xcm = { workspace = true } | ||
xcm-executor = { workspace = true } | ||
pallet-xcm = { workspace = true } | ||
xcm-primitives = { workspace = true } | ||
|
||
# Runtimes | ||
polkadot-runtime-common = { workspace = true } | ||
parachains-common = { workspace = true } | ||
rococo-runtime = { workspace = true } | ||
asset-hub-kusama-runtime = { workspace = true } | ||
asset-hub-polkadot-runtime = { workspace = true } | ||
trappist-runtime = { path = "../../runtime/trappist" } | ||
stout-runtime = { path = "../../runtime/stout" } | ||
|
||
# Local | ||
pallet-asset-registry = { workspace = true } | ||
|
||
[features] | ||
runtime-benchmarks = [ | ||
"polkadot-runtime-common/runtime-benchmarks", | ||
"rococo-runtime/runtime-benchmarks", | ||
"asset-hub-kusama-runtime/runtime-benchmarks", | ||
"asset-hub-polkadot-runtime/runtime-benchmarks", | ||
"trappist-runtime/runtime-benchmarks", | ||
"stout-runtime/runtime-benchmarks", | ||
"polkadot-parachain-primitives/runtime-benchmarks", | ||
"pallet-xcm/runtime-benchmarks", | ||
"integration-tests-common/runtime-benchmarks", | ||
"frame-system/runtime-benchmarks", | ||
"frame-support/runtime-benchmarks", | ||
"sp-runtime/runtime-benchmarks", | ||
"pallet-assets/runtime-benchmarks", | ||
] |
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,216 @@ | ||
use parachains_common::Balance; | ||
use sp_core::{sr25519, storage::Storage}; | ||
use sp_runtime::BuildStorage; | ||
use xcm_emulator::{ | ||
decl_test_networks, decl_test_parachains, decl_test_relay_chains, | ||
helpers::get_account_id_from_seed, DefaultMessageProcessor, Hooks, ParaId, | ||
}; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
decl_test_relay_chains! { | ||
// Rococo | ||
#[api_version(5)] | ||
pub struct Rococo { | ||
genesis = integration_tests_common::constants::rococo::genesis(), | ||
on_init = (), | ||
runtime = rococo_runtime, | ||
core = { | ||
MessageProcessor: DefaultMessageProcessor<Rococo>, | ||
SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, | ||
}, | ||
pallets = { | ||
XcmPallet: rococo_runtime::XcmPallet, | ||
Sudo: rococo_runtime::Sudo, | ||
Balances: rococo_runtime::Balances, | ||
} | ||
} | ||
} | ||
|
||
// Declare Parachains | ||
decl_test_parachains! { | ||
// Parachain A | ||
pub struct Trappist { | ||
genesis = para_a_genesis(), | ||
on_init = {trappist_runtime::AuraExt::on_initialize(1);} | ||
, | ||
runtime = trappist_runtime, | ||
core = { | ||
XcmpMessageHandler: trappist_runtime::XcmpQueue, | ||
DmpMessageHandler: trappist_runtime::DmpQueue, | ||
LocationToAccountId: trappist_runtime::xcm_config::LocationToAccountId, | ||
ParachainInfo: trappist_runtime::ParachainInfo, | ||
}, | ||
pallets= { | ||
XcmPallet: trappist_runtime::PolkadotXcm, | ||
Assets: trappist_runtime::Assets, | ||
Sudo: trappist_runtime::Sudo, | ||
AssetRegistry: trappist_runtime::AssetRegistry, | ||
Balances: trappist_runtime::Balances, | ||
} | ||
}, | ||
// Parachain B | ||
pub struct Stout { | ||
genesis = para_b_genesis(), | ||
on_init = {stout_runtime::AuraExt::on_initialize(1);}, | ||
runtime = stout_runtime, | ||
core = { | ||
XcmpMessageHandler: stout_runtime::XcmpQueue, | ||
DmpMessageHandler: stout_runtime::DmpQueue, | ||
LocationToAccountId: stout_runtime::xcm_config::LocationToAccountId, | ||
ParachainInfo: stout_runtime::ParachainInfo, | ||
}, | ||
pallets= { | ||
XcmPallet: stout_runtime::PolkadotXcm, | ||
Assets: stout_runtime::Assets, | ||
Sudo: stout_runtime::Sudo, | ||
AssetRegistry: stout_runtime::AssetRegistry, | ||
Balances: stout_runtime::Balances, | ||
} | ||
}, | ||
|
||
// AssetHub | ||
pub struct AssetHubRococo { | ||
genesis = integration_tests_common::constants::asset_hub_kusama::genesis(), | ||
on_init = { | ||
asset_hub_polkadot_runtime::AuraExt::on_initialize(1); | ||
}, | ||
runtime = asset_hub_kusama_runtime, | ||
core = { | ||
XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue, | ||
DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue, | ||
LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId, | ||
ParachainInfo: asset_hub_kusama_runtime::ParachainInfo, | ||
}, | ||
pallets = { | ||
PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm, | ||
Assets: asset_hub_kusama_runtime::Assets, | ||
Balances: asset_hub_kusama_runtime::Balances, | ||
} | ||
}, | ||
} | ||
|
||
//Define network(s) | ||
decl_test_networks! { | ||
// Rococo | ||
pub struct RococoMockNet { | ||
relay_chain = Rococo, | ||
parachains = vec![Trappist, Stout, AssetHubRococo,], | ||
bridge = () | ||
} | ||
} | ||
|
||
fn para_a_genesis() -> Storage { | ||
const PARA_ID: ParaId = ParaId::new(1836); | ||
const ED: Balance = trappist_runtime::constants::currency::EXISTENTIAL_DEPOSIT; | ||
|
||
let genesis_config = trappist_runtime::RuntimeGenesisConfig { | ||
system: trappist_runtime::SystemConfig { | ||
code: trappist_runtime::WASM_BINARY | ||
.expect("WASM binary was not build, please build it!") | ||
.to_vec(), | ||
..Default::default() | ||
}, | ||
balances: trappist_runtime::BalancesConfig { | ||
balances: integration_tests_common::constants::accounts::init_balances() | ||
.iter() | ||
.cloned() | ||
.map(|k| (k, ED * 1_000_000_000)) | ||
.collect(), | ||
}, | ||
parachain_info: trappist_runtime::ParachainInfoConfig { | ||
parachain_id: PARA_ID, | ||
..Default::default() | ||
}, | ||
collator_selection: trappist_runtime::CollatorSelectionConfig { | ||
invulnerables: | ||
integration_tests_common::constants::collators::invulnerables_asset_hub_polkadot() | ||
.iter() | ||
.cloned() | ||
.map(|(acc, _)| acc) | ||
.collect(), | ||
candidacy_bond: ED * 16, | ||
..Default::default() | ||
}, | ||
session: trappist_runtime::SessionConfig { | ||
keys: integration_tests_common::constants::collators::invulnerables() | ||
.into_iter() | ||
.map(|(acc, aura)| { | ||
( | ||
acc.clone(), // account id | ||
acc, // validator id | ||
trappist_runtime::SessionKeys { aura }, // session keys | ||
) | ||
}) | ||
.collect(), | ||
}, | ||
sudo: trappist_runtime::SudoConfig { | ||
key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")), | ||
}, | ||
polkadot_xcm: trappist_runtime::PolkadotXcmConfig { | ||
safe_xcm_version: Some(xcm::prelude::XCM_VERSION), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}; | ||
|
||
genesis_config.build_storage().unwrap() | ||
} | ||
|
||
fn para_b_genesis() -> Storage { | ||
const PARA_ID: ParaId = ParaId::new(3000); | ||
const ED: Balance = stout_runtime::constants::currency::EXISTENTIAL_DEPOSIT; | ||
|
||
let genesis_config = stout_runtime::RuntimeGenesisConfig { | ||
system: stout_runtime::SystemConfig { | ||
code: stout_runtime::WASM_BINARY | ||
.expect("WASM binary was not build, please build it!") | ||
.to_vec(), | ||
..Default::default() | ||
}, | ||
balances: stout_runtime::BalancesConfig { | ||
balances: integration_tests_common::constants::accounts::init_balances() | ||
.iter() | ||
.cloned() | ||
.map(|k| (k, ED * 1_000_000_000)) | ||
.collect(), | ||
}, | ||
parachain_info: stout_runtime::ParachainInfoConfig { | ||
parachain_id: PARA_ID, | ||
..Default::default() | ||
}, | ||
collator_selection: stout_runtime::CollatorSelectionConfig { | ||
invulnerables: | ||
integration_tests_common::constants::collators::invulnerables_asset_hub_polkadot() | ||
.iter() | ||
.cloned() | ||
.map(|(acc, _)| acc) | ||
.collect(), | ||
candidacy_bond: ED * 16, | ||
..Default::default() | ||
}, | ||
session: stout_runtime::SessionConfig { | ||
keys: integration_tests_common::constants::collators::invulnerables() | ||
.into_iter() | ||
.map(|(acc, aura)| { | ||
( | ||
acc.clone(), // account id | ||
acc, // validator id | ||
stout_runtime::SessionKeys { aura }, // session keys | ||
) | ||
}) | ||
.collect(), | ||
}, | ||
sudo: stout_runtime::SudoConfig { | ||
key: Some(get_account_id_from_seed::<sr25519::Public>("Alice")), | ||
}, | ||
polkadot_xcm: stout_runtime::PolkadotXcmConfig { | ||
safe_xcm_version: Some(xcm::prelude::XCM_VERSION), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}; | ||
|
||
genesis_config.build_storage().unwrap() | ||
} |
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,30 @@ | ||
use crate::tests::*; | ||
|
||
#[test] | ||
fn event_collection_works() { | ||
//init_tracing(); | ||
|
||
const AMOUNT: u128 = 1_000_000_000 * 10; | ||
const MAX_WEIGHT: u128 = 1_000_000_000; | ||
let alice_account: sp_runtime::AccountId32 = get_account_id_from_seed::<sr25519::Public>(ALICE); | ||
|
||
Trappist::execute_with(|| { | ||
assert_ok!(<Trappist as TrappistPallet>::XcmPallet::execute( | ||
<Trappist as Chain>::RuntimeOrigin::signed(alice_account.clone()), | ||
Box::new(VersionedXcm::from(Xcm(vec![WithdrawAsset((Here, AMOUNT).into())]))), | ||
(MAX_WEIGHT as u64).into() | ||
)); | ||
output_events::<<Trappist as Chain>::Runtime>(); | ||
assert_eq!(3, <Trappist as Chain>::System::events().len()); | ||
}); | ||
|
||
Stout::execute_with(|| { | ||
assert_ok!(<Stout as StoutPallet>::XcmPallet::execute( | ||
<Stout as Chain>::RuntimeOrigin::signed(alice_account), | ||
Box::new(VersionedXcm::from(Xcm(vec![WithdrawAsset((Here, AMOUNT).into())]))), | ||
(MAX_WEIGHT as u64).into() | ||
)); | ||
output_events::<<Stout as Chain>::Runtime>(); | ||
assert_eq!(1, <Stout as Chain>::System::events().len()); | ||
}); | ||
} |
Oops, something went wrong.