mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +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:
@@ -40,13 +40,12 @@ use sp_staking::{
|
||||
offence::{self, DisableStrategy, Kind, OffenceDetails},
|
||||
SessionIndex,
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
|
||||
pub struct OnOffenceHandler;
|
||||
|
||||
thread_local! {
|
||||
pub static ON_OFFENCE_PERBILL: RefCell<Vec<Perbill>> = RefCell::new(Default::default());
|
||||
pub static OFFENCE_WEIGHT: RefCell<Weight> = RefCell::new(Default::default());
|
||||
parameter_types! {
|
||||
pub static OnOffencePerbill: Vec<Perbill> = Default::default();
|
||||
pub static OffenceWeight: Weight = Default::default();
|
||||
}
|
||||
|
||||
impl<Reporter, Offender> offence::OnOffenceHandler<Reporter, Offender, Weight>
|
||||
@@ -58,16 +57,16 @@ impl<Reporter, Offender> offence::OnOffenceHandler<Reporter, Offender, Weight>
|
||||
_offence_session: SessionIndex,
|
||||
_disable_strategy: DisableStrategy,
|
||||
) -> Weight {
|
||||
ON_OFFENCE_PERBILL.with(|f| {
|
||||
*f.borrow_mut() = slash_fraction.to_vec();
|
||||
OnOffencePerbill::mutate(|f| {
|
||||
*f = slash_fraction.to_vec();
|
||||
});
|
||||
|
||||
OFFENCE_WEIGHT.with(|w| *w.borrow())
|
||||
OffenceWeight::get()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_on_offence_fractions<R, F: FnOnce(&mut Vec<Perbill>) -> R>(f: F) -> R {
|
||||
ON_OFFENCE_PERBILL.with(|fractions| f(&mut fractions.borrow_mut()))
|
||||
OnOffencePerbill::mutate(|fractions| f(fractions))
|
||||
}
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
|
||||
|
||||
Reference in New Issue
Block a user