Skip to content

Commit f7ef725

Browse files
kianenigmabkchr
andauthored
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>
1 parent a01079f commit f7ef725

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

src/lib.rs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,6 @@ mod tests {
571571
traits::{BlakeTwo256, IdentityLookup},
572572
Perbill,
573573
};
574-
use std::cell::RefCell;
575574
use smallvec::smallvec;
576575

577576
const CALL: &<Runtime as frame_system::Trait>::Call =
@@ -599,20 +598,14 @@ mod tests {
599598
pub enum Origin for Runtime {}
600599
}
601600

602-
thread_local! {
603-
static EXTRINSIC_BASE_WEIGHT: RefCell<u64> = RefCell::new(0);
604-
}
605-
606-
pub struct ExtrinsicBaseWeight;
607-
impl Get<u64> for ExtrinsicBaseWeight {
608-
fn get() -> u64 { EXTRINSIC_BASE_WEIGHT.with(|v| *v.borrow()) }
609-
}
610-
611601
parameter_types! {
612602
pub const BlockHashCount: u64 = 250;
613603
pub const MaximumBlockWeight: Weight = 1024;
614604
pub const MaximumBlockLength: u32 = 2 * 1024;
615605
pub const AvailableBlockRatio: Perbill = Perbill::one();
606+
pub static ExtrinsicBaseWeight: u64 = 0;
607+
pub static TransactionByteFee: u64 = 1;
608+
pub static WeightToFee: u64 = 1;
616609
}
617610

618611
impl frame_system::Trait for Runtime {
@@ -656,17 +649,7 @@ mod tests {
656649
type MaxLocks = ();
657650
type WeightInfo = ();
658651
}
659-
thread_local! {
660-
static TRANSACTION_BYTE_FEE: RefCell<u64> = RefCell::new(1);
661-
static WEIGHT_TO_FEE: RefCell<u64> = RefCell::new(1);
662-
}
663-
664-
pub struct TransactionByteFee;
665-
impl Get<u64> for TransactionByteFee {
666-
fn get() -> u64 { TRANSACTION_BYTE_FEE.with(|v| *v.borrow()) }
667-
}
668652

669-
pub struct WeightToFee;
670653
impl WeightToFeePolynomial for WeightToFee {
671654
type Balance = u64;
672655

0 commit comments

Comments
 (0)