mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 20:21:06 +00:00
Use parameter_types instead of thread_local for test-setup (#12036)
* Edit to Assets. parameter_types * fixes * Test Fixes. WIP * Edits to pallet-aura * Camel Case Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Implementation of mutate fn * update to pallet-aura * Update to frame-system. Fixes * Update to frame-support-test. CamelCases * Updates to frame- contracts, offences, staking, bounties, child bounties * Edit to mutate fn. Changes to frame-contracts. CamelCase pallet-aura * Edits to frame-contracts & executive * cargo +nightly fmt * unused import removed * unused import removed * cargo +nightly fmt * minor adjustment * updates * updates * cargo +nightly fmt * cargo +nightly fmt * take fn implemented * update * update * Fixes to CallFilter * cargo +nightly fmt * final fixes * Default changed to $value * Update frame/support/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -19,14 +19,17 @@ use crate as pallet_mmr;
|
||||
use crate::*;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::traits::{ConstU32, ConstU64};
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
traits::{ConstU32, ConstU64},
|
||||
};
|
||||
use sp_core::H256;
|
||||
use sp_mmr_primitives::{Compact, LeafDataProvider};
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup, Keccak256},
|
||||
};
|
||||
use sp_std::{cell::RefCell, prelude::*};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
@@ -91,14 +94,14 @@ impl LeafData {
|
||||
}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
pub static LEAF_DATA: RefCell<LeafData> = RefCell::new(Default::default());
|
||||
parameter_types! {
|
||||
pub static LeafDataTestValue: LeafData = Default::default();
|
||||
}
|
||||
|
||||
impl LeafDataProvider for LeafData {
|
||||
type LeafData = Self;
|
||||
|
||||
fn leaf_data() -> Self::LeafData {
|
||||
LEAF_DATA.with(|r| r.borrow().clone())
|
||||
LeafDataTestValue::get().clone()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ fn register_offchain_ext(ext: &mut sp_io::TestExternalities) {
|
||||
fn new_block() -> Weight {
|
||||
let number = frame_system::Pallet::<Test>::block_number() + 1;
|
||||
let hash = H256::repeat_byte(number as u8);
|
||||
LEAF_DATA.with(|r| r.borrow_mut().a = number);
|
||||
LeafDataTestValue::mutate(|r| r.a = number);
|
||||
|
||||
frame_system::Pallet::<Test>::reset_events();
|
||||
frame_system::Pallet::<Test>::initialize(&number, &hash, &Default::default());
|
||||
|
||||
Reference in New Issue
Block a user