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:
Kian Paimani
2020-11-20 18:54:19 +01:00
committed by GitHub
parent 52d261e3c7
commit b64b17536a
12 changed files with 128 additions and 217 deletions
+2 -11
View File
@@ -30,11 +30,10 @@ use sp_runtime::{
use frame_support::{
assert_ok, assert_err_ignore_postinfo, impl_outer_dispatch, impl_outer_event,
impl_outer_origin, parameter_types, StorageMap, StorageValue,
traits::{Currency, Get, ReservableCurrency},
traits::{Currency, ReservableCurrency},
weights::{Weight, PostDispatchInfo},
dispatch::DispatchErrorWithPostInfo,
};
use std::cell::RefCell;
use frame_system::{self as system, EventRecord, Phase};
mod contracts {
@@ -99,15 +98,6 @@ pub mod test_utils {
}
}
thread_local! {
static EXISTENTIAL_DEPOSIT: RefCell<u64> = RefCell::new(0);
}
pub struct ExistentialDeposit;
impl Get<u64> for ExistentialDeposit {
fn get() -> u64 { EXISTENTIAL_DEPOSIT.with(|v| *v.borrow()) }
}
#[derive(Clone, Eq, PartialEq, Debug)]
pub struct Test;
parameter_types! {
@@ -115,6 +105,7 @@ parameter_types! {
pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::one();
pub static ExistentialDeposit: u64 = 0;
}
impl frame_system::Trait for Test {
type BaseCallFilter = ();