Have the coins pallet emit events via serai_core_pallet

`serai_core_pallet` solely defines an accumulator for the events. We use the
traditional `frame_system::Events` to store them for now and enable retrieval.
This commit is contained in:
Luke Parker
2025-09-19 22:12:45 -04:00
parent 3f5150b3fa
commit 3cb9432daa
12 changed files with 188 additions and 129 deletions

View File

@@ -1,8 +1,8 @@
//! Test environment for Coins pallet.
use sp_runtime::BuildStorage;
use borsh::BorshDeserialize;
use frame_support::{derive_impl, construct_runtime};
use frame_support::{sp_runtime::BuildStorage, derive_impl, construct_runtime};
use crate::{self as coins, CoinsInstance};
@@ -10,6 +10,7 @@ construct_runtime!(
pub enum Test
{
System: frame_system,
Core: serai_core_pallet,
Coins: coins::<CoinsInstance>,
}
);
@@ -17,15 +18,28 @@ construct_runtime!(
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type AccountId = sp_core::sr25519::Public;
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Lookup = frame_support::sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Block = frame_system::mocking::MockBlock<Test>;
}
impl serai_core_pallet::Config for Test {}
impl crate::Config<CoinsInstance> for Test {
type RuntimeEvent = RuntimeEvent;
type AllowMint = crate::AlwaysAllowMint;
}
impl TryFrom<RuntimeEvent> for serai_abi::Event {
type Error = ();
fn try_from(event: RuntimeEvent) -> Result<serai_abi::Event, ()> {
match event {
RuntimeEvent::Core(serai_core_pallet::Event::Event(event)) => {
Ok(serai_abi::Event::deserialize_reader(&mut event.as_slice()).unwrap())
}
_ => Err(()),
}
}
}
pub(crate) fn new_test_ext() -> sp_io::TestExternalities {
let mut storage = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();