Skip to content

Commit

Permalink
add test for pallet indices
Browse files Browse the repository at this point in the history
  • Loading branch information
joepetrowski committed Dec 8, 2023
1 parent c205369 commit 90f334b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use crate::{
use cumulus_primitives_core::Junction::GeneralIndex;
use frame_support::{
parameter_types,
traits::{EitherOf, EitherOfDiverse, MapSuccess, OriginTrait, TryWithMorphedArg},
traits::{
EitherOf, EitherOfDiverse, MapSuccess, OriginTrait, PalletInfoAccess, TryWithMorphedArg,
},
PalletId,
};
use frame_system::{EnsureRoot, EnsureRootWithSuccess};
Expand Down Expand Up @@ -261,7 +263,8 @@ parameter_types! {
pub const MaxBalance: Balance = Balance::max_value();
// The asset's interior location for the paying account. This is the Fellowship Treasury
// pallet instance (which sits at index 65).
pub FellowshipTreasuryInteriorLocation: InteriorMultiLocation = PalletInstance(65).into();
pub FellowshipTreasuryInteriorLocation: InteriorMultiLocation =
PalletInstance(<crate::FellowshipTreasury as PalletInfoAccess>::index() as u8).into();
}

/// [`PayOverXcm`] setup to pay the Fellowship Treasury.
Expand Down
18 changes: 18 additions & 0 deletions system-parachains/collectives/collectives-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,3 +1014,21 @@ cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
}

// TODO: Move these pallet index declarations to some `system-parachains/common` so that other
// runtimes can import them without depending on the entire remote runtime.
// Part of https://github.com/polkadot-fellows/runtimes/issues/59

#[test]
fn fellowship_salary_pallet_index() {
use frame_support::pallet_prelude::PalletInfoAccess;
// Remote accounts with funds depend on this pallet staying in the same index.
assert_eq!(<FellowshipSalary as PalletInfoAccess>::index() as u8, 64u8);
}

#[test]
fn fellowship_treasury_pallet_index() {
use frame_support::pallet_prelude::PalletInfoAccess;
// Remote accounts with funds depend on this pallet staying in the same index.
assert_eq!(<FellowshipTreasury as PalletInfoAccess>::index() as u8, 65u8);
}

0 comments on commit 90f334b

Please sign in to comment.