2025-11-30 21:27:04 -05:00
|
|
|
//! Test environment for the Coins pallet.
|
2024-10-30 23:05:56 +03:00
|
|
|
|
2025-09-19 22:12:45 -04:00
|
|
|
use borsh::BorshDeserialize;
|
2024-10-30 23:05:56 +03:00
|
|
|
|
2025-09-19 22:12:45 -04:00
|
|
|
use frame_support::{sp_runtime::BuildStorage, derive_impl, construct_runtime};
|
2024-10-30 23:05:56 +03:00
|
|
|
|
2025-03-06 05:53:18 -05:00
|
|
|
use crate::{self as coins, CoinsInstance};
|
2024-10-30 23:05:56 +03:00
|
|
|
|
|
|
|
|
construct_runtime!(
|
|
|
|
|
pub enum Test
|
|
|
|
|
{
|
|
|
|
|
System: frame_system,
|
2025-11-14 09:57:18 -05:00
|
|
|
Timestamp: pallet_timestamp,
|
2025-09-19 22:12:45 -04:00
|
|
|
Core: serai_core_pallet,
|
2025-03-06 05:53:18 -05:00
|
|
|
Coins: coins::<CoinsInstance>,
|
2024-10-30 23:05:56 +03:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2025-03-06 05:53:18 -05:00
|
|
|
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
|
2024-10-30 23:05:56 +03:00
|
|
|
impl frame_system::Config for Test {
|
2025-03-06 05:53:18 -05:00
|
|
|
type AccountId = sp_core::sr25519::Public;
|
2025-09-19 22:12:45 -04:00
|
|
|
type Lookup = frame_support::sp_runtime::traits::IdentityLookup<Self::AccountId>;
|
2025-03-06 05:53:18 -05:00
|
|
|
type Block = frame_system::mocking::MockBlock<Test>;
|
2025-12-02 21:04:47 -05:00
|
|
|
type BlockLength = serai_core_pallet::Limits;
|
|
|
|
|
type BlockWeights = serai_core_pallet::Limits;
|
2024-10-30 23:05:56 +03:00
|
|
|
}
|
|
|
|
|
|
2025-11-14 09:57:18 -05:00
|
|
|
#[derive_impl(pallet_timestamp::config_preludes::TestDefaultConfig)]
|
|
|
|
|
impl pallet_timestamp::Config for Test {}
|
|
|
|
|
|
2025-09-19 22:12:45 -04:00
|
|
|
impl serai_core_pallet::Config for Test {}
|
|
|
|
|
|
2025-03-06 05:53:18 -05:00
|
|
|
impl crate::Config<CoinsInstance> for Test {
|
|
|
|
|
type AllowMint = crate::AlwaysAllowMint;
|
2024-10-30 23:05:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn new_test_ext() -> sp_io::TestExternalities {
|
2025-03-06 05:53:18 -05:00
|
|
|
let mut storage = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
2024-10-30 23:05:56 +03:00
|
|
|
|
2025-03-06 05:53:18 -05:00
|
|
|
crate::GenesisConfig::<Test, CoinsInstance> { accounts: vec![], _instance: Default::default() }
|
|
|
|
|
.assimilate_storage(&mut storage)
|
2024-10-30 23:05:56 +03:00
|
|
|
.unwrap();
|
|
|
|
|
|
2025-03-06 05:53:18 -05:00
|
|
|
storage.into()
|
2024-10-30 23:05:56 +03:00
|
|
|
}
|