mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 04:37:57 +00:00
Thread-local parameter_types for testing. (#7542)
* Thread-local parameter_types for testing. * Better docs. * Some minors * Merge'em * Update frame/support/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Align more to basti's trick * Update frame/support/src/lib.rs * Update frame/support/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
//! The crate's tests.
|
||||
|
||||
use super::*;
|
||||
use std::cell::RefCell;
|
||||
use codec::Encode;
|
||||
use frame_support::{
|
||||
impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types,
|
||||
@@ -154,6 +153,8 @@ parameter_types! {
|
||||
pub const CooloffPeriod: u64 = 2;
|
||||
pub const MaxVotes: u32 = 100;
|
||||
pub const MaxProposals: u32 = MAX_PROPOSALS;
|
||||
pub static PreimageByteDeposit: u64 = 0;
|
||||
pub static InstantAllowed: bool = false;
|
||||
}
|
||||
ord_parameter_types! {
|
||||
pub const One: u64 = 1;
|
||||
@@ -171,18 +172,7 @@ impl Contains<u64> for OneToFive {
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn add(_m: &u64) {}
|
||||
}
|
||||
thread_local! {
|
||||
static PREIMAGE_BYTE_DEPOSIT: RefCell<u64> = RefCell::new(0);
|
||||
static INSTANT_ALLOWED: RefCell<bool> = RefCell::new(false);
|
||||
}
|
||||
pub struct PreimageByteDeposit;
|
||||
impl Get<u64> for PreimageByteDeposit {
|
||||
fn get() -> u64 { PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow()) }
|
||||
}
|
||||
pub struct InstantAllowed;
|
||||
impl Get<bool> for InstantAllowed {
|
||||
fn get() -> bool { INSTANT_ALLOWED.with(|v| *v.borrow()) }
|
||||
}
|
||||
|
||||
impl super::Trait for Test {
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
|
||||
Reference in New Issue
Block a user