Skip to content

Commit

Permalink
decouple PARA_ID and SIBLING_ID from FudgeHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Jun 20, 2024
1 parent 91b79bb commit a95397c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 35 deletions.
10 changes: 5 additions & 5 deletions runtime/integration-tests/src/generic/cases/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use crate::{
generic::{
config::Runtime,
env::{Blocks, Env},
envs::fudge_env::{handle::FudgeHandle, FudgeEnv, FudgeSupport},
envs::fudge_env::{handle::SIBLING_ID, FudgeEnv, FudgeSupport},
utils::{genesis, genesis::Genesis, xcm::enable_para_to_sibling_communication},
},
utils::{accounts::Keyring, orml_asset_registry},
Expand Down Expand Up @@ -105,7 +105,7 @@ mod utils {
location: Some(VersionedLocation::V4(Location::new(
1,
[
Parachain(T::FudgeHandle::SIBLING_ID),
Parachain(SIBLING_ID),
general_key(parachains::kusama::karura::AUSD_KEY),
],
))),
Expand Down Expand Up @@ -209,7 +209,7 @@ mod utils {
existential_deposit: GLMR_ED,
location: Some(VersionedLocation::V4(Location::new(
1,
[Parachain(T::FudgeHandle::SIBLING_ID), general_key(&[0, 1])],
[Parachain(SIBLING_ID), general_key(&[0, 1])],
))),
additional: CustomMetadata {
transferability: CrossChainTransferability::Xcm(Default::default()),
Expand Down Expand Up @@ -345,7 +345,7 @@ mod utils {

set_test_domain_router::<T>(
MOONBEAM_EVM_CHAIN_ID,
Location::new(1, Junction::Parachain(T::FudgeHandle::SIBLING_ID)).into(),
Location::new(1, Junction::Parachain(SIBLING_ID)).into(),
GLMR_CURRENCY_ID,
);
});
Expand Down Expand Up @@ -3946,7 +3946,7 @@ mod routers {

env.parachain_state_mut(|| {
let domain_router = router_creation_fn(
Location::new(1, Parachain(T::FudgeHandle::SIBLING_ID)).into(),
Location::new(1, Parachain(SIBLING_ID)).into(),
GLMR_CURRENCY_ID,
);

Expand Down
19 changes: 11 additions & 8 deletions runtime/integration-tests/src/generic/cases/xcm_transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use crate::{
generic::{
config::Runtime,
env::{Blocks, Env},
envs::fudge_env::{handle::FudgeHandle, FudgeEnv, FudgeSupport, RelayRuntime},
envs::fudge_env::{
handle::{PARA_ID, SIBLING_ID},
FudgeEnv, FudgeSupport, RelayRuntime,
},
utils::{
currency::{cfg, CurrencyInfo, CustomCurrency},
genesis,
Expand Down Expand Up @@ -37,7 +40,7 @@ fn create_transfeable_currency(decimals: u32, para_id: Option<u32>) -> CustomCur

#[test_runtimes(all)]
fn para_to_sibling_with_foreign_to_foreign_tokens<T: Runtime + FudgeSupport>() {
let curr = create_transfeable_currency(6, Some(T::FudgeHandle::PARA_ID));
let curr = create_transfeable_currency(6, Some(PARA_ID));

let mut env = FudgeEnv::<T>::from_storage(
Default::default(),
Expand All @@ -57,7 +60,7 @@ fn para_to_sibling_with_foreign_to_foreign_tokens<T: Runtime + FudgeSupport>() {
RawOrigin::Signed(Keyring::Alice.id()).into(),
curr.id(),
curr.val(TRANSFER),
account_location(1, Some(T::FudgeHandle::SIBLING_ID), Keyring::Bob.id()),
account_location(1, Some(SIBLING_ID), Keyring::Bob.id()),
WeightLimit::Unlimited,
));

Expand All @@ -79,7 +82,7 @@ fn para_to_sibling_with_foreign_to_foreign_tokens<T: Runtime + FudgeSupport>() {

#[test_runtimes(all)]
fn para_to_sibling_with_native_to_foreign_tokens<T: Runtime + FudgeSupport>() {
let curr = create_transfeable_currency(18, Some(T::FudgeHandle::PARA_ID));
let curr = create_transfeable_currency(18, Some(PARA_ID));

let mut env = FudgeEnv::<T>::from_storage(
Default::default(),
Expand All @@ -99,7 +102,7 @@ fn para_to_sibling_with_native_to_foreign_tokens<T: Runtime + FudgeSupport>() {
RawOrigin::Signed(Keyring::Alice.id()).into(),
Native,
cfg(TRANSFER),
account_location(1, Some(T::FudgeHandle::SIBLING_ID), Keyring::Bob.id()),
account_location(1, Some(SIBLING_ID), Keyring::Bob.id()),
WeightLimit::Unlimited,
));

Expand All @@ -121,7 +124,7 @@ fn para_to_sibling_with_native_to_foreign_tokens<T: Runtime + FudgeSupport>() {

#[test_runtimes(all)]
fn para_to_sibling_with_foreign_to_native_tokens<T: Runtime + FudgeSupport>() {
let curr = create_transfeable_currency(18, Some(T::FudgeHandle::PARA_ID));
let curr = create_transfeable_currency(18, Some(PARA_ID));

let mut env = FudgeEnv::<T>::from_storage(
Default::default(),
Expand All @@ -141,7 +144,7 @@ fn para_to_sibling_with_foreign_to_native_tokens<T: Runtime + FudgeSupport>() {
RawOrigin::Signed(Keyring::Alice.id()).into(),
curr.id(),
curr.val(TRANSFER),
account_location(1, Some(T::FudgeHandle::SIBLING_ID), Keyring::Bob.id()),
account_location(1, Some(SIBLING_ID), Keyring::Bob.id()),
WeightLimit::Unlimited,
));

Expand Down Expand Up @@ -182,7 +185,7 @@ fn para_from_to_relay_using_relay_native_tokens<T: Runtime + FudgeSupport>() {
assert_ok!(
pallet_xcm::Pallet::<RelayRuntime<T>>::reserve_transfer_assets(
RawOrigin::Signed(Keyring::Alice.id()).into(),
Box::new(Parachain(T::FudgeHandle::PARA_ID).into()),
Box::new(Parachain(PARA_ID).into()),
account_location(0, None, Keyring::Bob.id()),
Box::new((Here, curr.val(TRANSFER)).into()),
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ use crate::generic::config::Runtime;
/// Start date used for timestamps in test-enviornments
/// Sat Jan 01 2022 00:00:00 GMT+0000
pub const START_DATE: u64 = 1640995200u64;
pub const PARA_ID: u32 = 1001;
pub const SIBLING_ID: u32 = 1002;

type InherentCreator<Block, InherentParachain, InherentDataProvider> = Box<
dyn CreateInherentDataProviders<
Expand Down Expand Up @@ -118,9 +120,6 @@ pub trait FudgeHandle<T: Runtime> {
const RELAY_CODE: Option<&'static [u8]>;
const PARACHAIN_CODE: Option<&'static [u8]>;

const PARA_ID: u32;
const SIBLING_ID: u32;

fn relay(&self) -> &RelaychainBuilder<Self::RelayConstructApi, Self::RelayRuntime>;
fn relay_mut(&mut self) -> &mut RelaychainBuilder<Self::RelayConstructApi, Self::RelayRuntime>;

Expand Down
19 changes: 5 additions & 14 deletions runtime/integration-tests/src/generic/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ macro_rules! impl_fudge_support {
$relay_path:ident,
$relay_session_keys:expr,
$parachain_path:ident,
$parachain_id:literal,
$sibling_id:literal
) => {
const _: () = {
use fudge::primitives::{Chain, ParaId};
Expand All @@ -58,6 +56,7 @@ macro_rules! impl_fudge_support {
use crate::generic::envs::fudge_env::{
handle::{
FudgeHandle, ParachainBuilder, ParachainClient, RelayClient, RelaychainBuilder,
PARA_ID, SIBLING_ID,
},
FudgeSupport,
};
Expand All @@ -67,11 +66,11 @@ macro_rules! impl_fudge_support {
#[fudge::relaychain]
pub relay: RelaychainBuilder<$relay_path::RuntimeApi, $relay_path::Runtime>,

#[fudge::parachain($parachain_id)]
#[fudge::parachain(PARA_ID)]
pub parachain:
ParachainBuilder<$parachain_path::Block, $parachain_path::RuntimeApi>,

#[fudge::parachain($sibling_id)]
#[fudge::parachain(SIBLING_ID)]
pub sibling: ParachainBuilder<$parachain_path::Block, $parachain_path::RuntimeApi>,
}

Expand All @@ -91,9 +90,7 @@ macro_rules! impl_fudge_support {
type RelayRuntime = $relay_path::Runtime;

const PARACHAIN_CODE: Option<&'static [u8]> = $parachain_path::WASM_BINARY;
const PARA_ID: u32 = $parachain_id;
const RELAY_CODE: Option<&'static [u8]> = $relay_path::WASM_BINARY;
const SIBLING_ID: u32 = $sibling_id;

fn new(
relay_storage: Storage,
Expand All @@ -102,12 +99,12 @@ macro_rules! impl_fudge_support {
) -> Self {
let relay = Self::new_relay_builder(relay_storage, $relay_session_keys);
let parachain = Self::new_parachain_builder(
ParaId::from(Self::PARA_ID),
ParaId::from(PARA_ID),
&relay,
parachain_storage,
);
let sibling = Self::new_parachain_builder(
ParaId::from(Self::SIBLING_ID),
ParaId::from(SIBLING_ID),
&relay,
sibling_storage,
);
Expand Down Expand Up @@ -183,26 +180,20 @@ impl_fudge_support!(
rococo_runtime,
default_rococo_session_keys(),
development_runtime,
2000,
2001
);

impl_fudge_support!(
FudgeAltair,
rococo_runtime,
default_rococo_session_keys(),
altair_runtime,
2088,
2089
);

impl_fudge_support!(
FudgeCentrifuge,
rococo_runtime,
default_rococo_session_keys(),
centrifuge_runtime,
2031,
2032
);

pub fn default_rococo_session_keys() -> rococo_runtime::SessionKeys {
Expand Down
13 changes: 8 additions & 5 deletions runtime/integration-tests/src/generic/utils/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ use staging_xcm::{
use crate::generic::{
config::Runtime,
env::{Blocks, Env},
envs::fudge_env::{handle::FudgeHandle, FudgeEnv, FudgeSupport, RelayRuntime},
envs::fudge_env::{
handle::{PARA_ID, SIBLING_ID},
FudgeEnv, FudgeSupport, RelayRuntime,
},
};

pub fn enable_relay_to_para_communication<T: Runtime + FudgeSupport>(env: &mut FudgeEnv<T>) {
env.relay_state_mut(|| {
assert_ok!(pallet_xcm::Pallet::<RelayRuntime<T>>::force_xcm_version(
RawOrigin::Root.into(),
Box::new(Location::new(0, Parachain(T::FudgeHandle::PARA_ID))),
Box::new(Location::new(0, Parachain(PARA_ID))),
XCM_VERSION,
));
});
Expand All @@ -40,7 +43,7 @@ pub fn enable_para_to_sibling_communication<T: Runtime + FudgeSupport>(env: &mut
env.parachain_state_mut(|| {
assert_ok!(pallet_xcm::Pallet::<T>::force_xcm_version(
RawOrigin::Root.into(),
Box::new(Location::new(1, Parachain(T::FudgeHandle::SIBLING_ID))),
Box::new(Location::new(1, Parachain(SIBLING_ID))),
XCM_VERSION,
));
});
Expand All @@ -50,8 +53,8 @@ pub fn enable_para_to_sibling_communication<T: Runtime + FudgeSupport>(env: &mut
assert_ok!(
polkadot_runtime_parachains::hrmp::Pallet::<RelayRuntime<T>>::force_open_hrmp_channel(
RawOrigin::Root.into(),
Id::from(T::FudgeHandle::PARA_ID),
Id::from(T::FudgeHandle::SIBLING_ID),
Id::from(PARA_ID),
Id::from(SIBLING_ID),
10,
1024,
)
Expand Down

0 comments on commit a95397c

Please sign in to comment.