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:
Boluwatife Bakre
2022-09-08 11:46:25 +01:00
committed by GitHub
parent bec123a50f
commit 3ec4d13e9f
32 changed files with 378 additions and 402 deletions
+5 -8
View File
@@ -19,8 +19,6 @@
#![cfg(test)]
use std::cell::RefCell;
use sp_core::H256;
use sp_runtime::{
testing::Header,
@@ -100,18 +98,17 @@ impl pallet_balances::Config for Test {
type AccountStore = System;
type WeightInfo = ();
}
thread_local! {
static TEN_TO_FOURTEEN: RefCell<Vec<u128>> = RefCell::new(vec![10,11,12,13,14]);
parameter_types! {
static TenToFourteenTestValue: Vec<u128> = vec![10,11,12,13,14];
}
pub struct TenToFourteen;
impl SortedMembers<u128> for TenToFourteen {
fn sorted_members() -> Vec<u128> {
TEN_TO_FOURTEEN.with(|v| v.borrow().clone())
TenToFourteenTestValue::get().clone()
}
#[cfg(feature = "runtime-benchmarks")]
fn add(new: &u128) {
TEN_TO_FOURTEEN.with(|v| {
let mut members = v.borrow_mut();
TenToFourteenTestValue::mutate(|members| {
members.push(*new);
members.sort();
})
@@ -119,7 +116,7 @@ impl SortedMembers<u128> for TenToFourteen {
}
impl ContainsLengthBound for TenToFourteen {
fn max_len() -> usize {
TEN_TO_FOURTEEN.with(|v| v.borrow().len())
TenToFourteenTestValue::get().len()
}
fn min_len() -> usize {
0