Skip to content

Commit

Permalink
Fix sibling runtime, integration tests and update xcm configs for all…
Browse files Browse the repository at this point in the history
… runtimes with the correct multilocations
  • Loading branch information
bogdanS98 committed Nov 3, 2023
1 parent e961df0 commit ccd187e
Show file tree
Hide file tree
Showing 7 changed files with 522 additions and 449 deletions.
9 changes: 9 additions & 0 deletions runtime/integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ version = "0.1.0"
codec = { package = "parity-scale-codec", version = "3.0.0" }
scale-info = { version = "2.1.2", features = ["derive"] }
serde = { version = "1.0.144", features = ["derive"] }
log = { version = "0.4.17", default-features = false }
smallvec = "1.9.0"

# Spacewalk libraries
spacewalk-primitives = { git = "https://github.com/pendulum-chain/spacewalk", default-features = false, rev = "58983d2695c309665c9c017a022436aaee088f3d"}

frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" }
Expand Down Expand Up @@ -39,6 +44,7 @@ cumulus-pallet-dmp-queue = {git = "https://github.com/paritytech/cumulus", branc
cumulus-pallet-xcmp-queue = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40"}
cumulus-pallet-xcm = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40"}
cumulus-primitives-core = {git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40"}
cumulus-primitives-utility = {git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.40"}
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" }

statemint-runtime = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" }
Expand All @@ -50,6 +56,9 @@ orml-traits = {git = "https://github.com/open-web3-stack/open-runtime-module-lib
orml-tokens = {git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.40" }
orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.40" }

# Local
runtime-common = {path = "../common", default-features = false}

pendulum-runtime = { path = "../pendulum" }
amplitude-runtime = {path = "../amplitude" }

Expand Down
29 changes: 27 additions & 2 deletions runtime/integration-tests/src/amplitude_tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::{
mock::{kusama_relay_ext, para_ext, ParachainType, USDT_ASSET_ID},
sibling,
test_macros::{
parachain1_transfer_asset_to_parachain2, parachain1_transfer_asset_to_parachain2_and_back,
parachain1_transfer_incorrect_asset_to_parachain2_should_fail,
transfer_10_relay_token_from_parachain_to_relay_chain,
transfer_20_relay_token_from_relay_chain_to_parachain,
transfer_native_token_from_parachain1_to_parachain2,
transfer_native_token_from_parachain1_to_parachain2_and_back,
},
AMPLITUDE_ID, KUSAMA_ASSETHUB_ID,
AMPLITUDE_ID, KUSAMA_ASSETHUB_ID, SIBLING_ID,
};

use frame_support::assert_ok;
Expand Down Expand Up @@ -35,6 +36,16 @@ decl_test_parachain! {
}
}

decl_test_parachain! {
pub struct SiblingParachain {
Runtime = sibling::Runtime,
RuntimeOrigin = sibling::RuntimeOrigin,
XcmpMessageHandler = sibling::XcmpQueue,
DmpMessageHandler = sibling::DmpQueue,
new_ext = para_ext(ParachainType::Sibling),
}
}

decl_test_parachain! {
pub struct AssetHubParachain {
Runtime = kusama_asset_hub_runtime::Runtime,
Expand All @@ -51,6 +62,7 @@ decl_test_network! {
parachains = vec![
(1000, AssetHubParachain),
(2124, AmplitudeParachain),
(9999, SiblingParachain),
],
}
}
Expand Down Expand Up @@ -117,3 +129,16 @@ fn assethub_transfer_asset_to_amplitude_and_back() {
network_id
);
}

#[test]
fn transfer_native_token_to_sibling_parachain_and_back() {
transfer_native_token_from_parachain1_to_parachain2_and_back!(
KusamaMockNet,
amplitude_runtime,
AmplitudeParachain,
sibling,
SiblingParachain,
AMPLITUDE_ID,
SIBLING_ID
);
}
2 changes: 2 additions & 0 deletions runtime/integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ pub const POLKADOT_ASSETHUB_ID: u32 = 1000;

pub const AMPLITUDE_ID: u32 = 2124;
pub const KUSAMA_ASSETHUB_ID: u32 = 1000;

pub const SIBLING_ID: u32 = 9999;
10 changes: 7 additions & 3 deletions runtime/integration-tests/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::{AMPLITUDE_ID, KUSAMA_ASSETHUB_ID, PENDULUM_ID, POLKADOT_ASSETHUB_ID};
use crate::{
sibling, AMPLITUDE_ID, KUSAMA_ASSETHUB_ID, PENDULUM_ID, POLKADOT_ASSETHUB_ID, SIBLING_ID,
};
use frame_support::traits::GenesisBuild;
use pendulum_runtime::CurrencyId;
use polkadot_core_primitives::{AccountId, Balance, BlockNumber};
Expand Down Expand Up @@ -74,6 +76,8 @@ macro_rules! build_parachain_with_orml {
orml_tokens::GenesisConfig::<$runtime> {
balances: vec![
(AccountId::from(BOB), CurrencyId::XCM(0), units($orml_balance)),
(AccountId::from(ALICE), CurrencyId::XCM(0), units($orml_balance)),
(AccountId::from(BOB), CurrencyId::Native, units($orml_balance)),
(AccountId::from(ALICE), CurrencyId::Native, units($orml_balance)),
],
}
Expand Down Expand Up @@ -199,7 +203,7 @@ impl<Currency> ExtBuilderParachain<Currency> {
ParachainType::PolkadotAssetHub => POLKADOT_ASSETHUB_ID,
ParachainType::KusamaAssetHub => KUSAMA_ASSETHUB_ID,
ParachainType::Pendulum => PENDULUM_ID,
ParachainType::Sibling => PENDULUM_ID + 1,
ParachainType::Sibling => SIBLING_ID,
ParachainType::Amplitude => AMPLITUDE_ID,
}
}
Expand Down Expand Up @@ -249,7 +253,7 @@ impl Builder<CurrencyId> for ExtBuilderParachain<CurrencyId> {
)
},
ParachainType::Sibling => {
use pendulum_runtime::{Runtime, System};
use sibling::{Runtime, System};
build_parachain_with_orml!(
self,
Runtime,
Expand Down
24 changes: 11 additions & 13 deletions runtime/integration-tests/src/pendulum_tests.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::{
mock::{para_ext, polkadot_relay_ext, ParachainType, USDT_ASSET_ID},
sibling,
test_macros::{
parachain1_transfer_asset_to_parachain2, parachain1_transfer_asset_to_parachain2_and_back,
parachain1_transfer_incorrect_asset_to_parachain2_should_fail,
transfer_10_relay_token_from_parachain_to_relay_chain,
transfer_20_relay_token_from_relay_chain_to_parachain,
transfer_native_token_from_parachain1_to_parachain2,
transfer_native_token_from_parachain1_to_parachain2_and_back,
},
PENDULUM_ID, POLKADOT_ASSETHUB_ID,
PENDULUM_ID, POLKADOT_ASSETHUB_ID, SIBLING_ID,
};

use frame_support::assert_ok;
Expand Down Expand Up @@ -37,10 +38,10 @@ decl_test_parachain! {

decl_test_parachain! {
pub struct SiblingParachain {
Runtime = pendulum_runtime::Runtime,
RuntimeOrigin = pendulum_runtime::RuntimeOrigin,
XcmpMessageHandler = pendulum_runtime::XcmpQueue,
DmpMessageHandler = pendulum_runtime::DmpQueue,
Runtime = sibling::Runtime,
RuntimeOrigin = sibling::RuntimeOrigin,
XcmpMessageHandler = sibling::XcmpQueue,
DmpMessageHandler = sibling::DmpQueue,
new_ext = para_ext(ParachainType::Sibling),
}
}
Expand All @@ -61,7 +62,7 @@ decl_test_network! {
parachains = vec![
(1000, AssetHubParachain),
(2094, PendulumParachain),
(2095, SiblingParachain),
(9999, SiblingParachain),
],
}
}
Expand Down Expand Up @@ -130,15 +131,12 @@ fn assethub_transfer_asset_to_pendulum_and_back() {
}

#[test]
fn transfer_pendulum_native_token_to_pendulum() {
// ID for Pendulum's second instance
pub const SIBLING_ID: u32 = PENDULUM_ID + 1;

transfer_native_token_from_parachain1_to_parachain2!(
fn transfer_native_token_to_sibling_parachain_and_back() {
transfer_native_token_from_parachain1_to_parachain2_and_back!(
PolkadotMockNet,
pendulum_runtime,
PendulumParachain,
pendulum_runtime,
sibling,
SiblingParachain,
PENDULUM_ID,
SIBLING_ID
Expand Down
Loading

0 comments on commit ccd187e

Please sign in to comment.