mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 21:08:01 +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:
@@ -1058,7 +1058,6 @@ impl<T: Trait> ContainsLengthBound for Module<T> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::cell::RefCell;
|
||||
use frame_support::{assert_ok, assert_noop, assert_err_with_weight, parameter_types,
|
||||
weights::Weight,
|
||||
};
|
||||
@@ -1123,36 +1122,13 @@ mod tests {
|
||||
pub const CandidacyBond: u64 = 3;
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static VOTING_BOND: RefCell<u64> = RefCell::new(2);
|
||||
static DESIRED_MEMBERS: RefCell<u32> = RefCell::new(2);
|
||||
static DESIRED_RUNNERS_UP: RefCell<u32> = RefCell::new(2);
|
||||
static TERM_DURATION: RefCell<u64> = RefCell::new(5);
|
||||
}
|
||||
|
||||
pub struct VotingBond;
|
||||
impl Get<u64> for VotingBond {
|
||||
fn get() -> u64 { VOTING_BOND.with(|v| *v.borrow()) }
|
||||
}
|
||||
|
||||
pub struct DesiredMembers;
|
||||
impl Get<u32> for DesiredMembers {
|
||||
fn get() -> u32 { DESIRED_MEMBERS.with(|v| *v.borrow()) }
|
||||
}
|
||||
|
||||
pub struct DesiredRunnersUp;
|
||||
impl Get<u32> for DesiredRunnersUp {
|
||||
fn get() -> u32 { DESIRED_RUNNERS_UP.with(|v| *v.borrow()) }
|
||||
}
|
||||
|
||||
pub struct TermDuration;
|
||||
impl Get<u64> for TermDuration {
|
||||
fn get() -> u64 { TERM_DURATION.with(|v| *v.borrow()) }
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
pub static MEMBERS: RefCell<Vec<u64>> = RefCell::new(vec![]);
|
||||
pub static PRIME: RefCell<Option<u64>> = RefCell::new(None);
|
||||
frame_support::parameter_types! {
|
||||
pub static VotingBond: u64 = 2;
|
||||
pub static DesiredMembers: u32 = 2;
|
||||
pub static DesiredRunnersUp: u32 = 2;
|
||||
pub static TermDuration: u64 = 5;
|
||||
pub static Members: Vec<u64> = vec![];
|
||||
pub static Prime: Option<u64> = None;
|
||||
}
|
||||
|
||||
pub struct TestChangeMembers;
|
||||
|
||||
Reference in New Issue
Block a user