mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 11:31:05 +00:00
Migrate some more pallets to construct_runtime (#7975)
* WIP converting balances tests to construct_runtime * Converting balances tests_local to construct_runtime * Fix up system and balances Events * Use static Call instance in tests * Migrate indices to construct_runtime * Migrate babe test to construct_runtime * Update frame/indices/src/mock.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/babe/src/mock.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update frame/babe/src/mock.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Remove redundant import Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -25,31 +25,29 @@ use sp_runtime::{
|
||||
};
|
||||
use sp_core::H256;
|
||||
use sp_io;
|
||||
use frame_support::{impl_outer_origin, impl_outer_event, parameter_types};
|
||||
use frame_support::parameter_types;
|
||||
use frame_support::traits::StorageMapShim;
|
||||
use frame_support::weights::{Weight, DispatchInfo, IdentityFee};
|
||||
use crate::{GenesisConfig, Module, Config, decl_tests, tests::CallWithDispatchInfo};
|
||||
use crate::{
|
||||
self as pallet_balances,
|
||||
Module, Config, decl_tests,
|
||||
};
|
||||
use pallet_transaction_payment::CurrencyAdapter;
|
||||
|
||||
use frame_system as system;
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Test {}
|
||||
}
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
|
||||
mod balances {
|
||||
pub use crate::Event;
|
||||
}
|
||||
|
||||
impl_outer_event! {
|
||||
pub enum Event for Test {
|
||||
system<T>,
|
||||
balances<T>,
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
{
|
||||
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Test;
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
pub BlockWeights: frame_system::limits::BlockWeights =
|
||||
@@ -64,7 +62,7 @@ impl frame_system::Config for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Call = CallWithDispatchInfo;
|
||||
type Call = Call;
|
||||
type Hash = H256;
|
||||
type Hashing = ::sp_runtime::traits::BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
@@ -73,7 +71,7 @@ impl frame_system::Config for Test {
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = ();
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
@@ -137,7 +135,7 @@ impl ExtBuilder {
|
||||
pub fn build(self) -> sp_io::TestExternalities {
|
||||
self.set_associated_consts();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
GenesisConfig::<Test> {
|
||||
pallet_balances::GenesisConfig::<Test> {
|
||||
balances: if self.monied {
|
||||
vec![
|
||||
(1, 10 * self.existential_deposit),
|
||||
@@ -170,9 +168,9 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() {
|
||||
assert_eq!(
|
||||
events(),
|
||||
[
|
||||
Event::system(system::Event::NewAccount(1)),
|
||||
Event::balances(RawEvent::Endowed(1, 100)),
|
||||
Event::balances(RawEvent::BalanceSet(1, 100, 0)),
|
||||
Event::frame_system(frame_system::Event::NewAccount(1)),
|
||||
Event::pallet_balances(RawEvent::Endowed(1, 100)),
|
||||
Event::pallet_balances(RawEvent::BalanceSet(1, 100, 0)),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -186,8 +184,8 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() {
|
||||
assert_eq!(
|
||||
events(),
|
||||
[
|
||||
Event::balances(RawEvent::DustLost(1, 1)),
|
||||
Event::system(system::Event::KilledAccount(1))
|
||||
Event::pallet_balances(RawEvent::DustLost(1, 1)),
|
||||
Event::frame_system(frame_system::Event::KilledAccount(1))
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user