Removing without_storage_info from scored-pool pallet. (#11996)

* Removing without_storage_info from scored-pool pallet.

* Addressing PR feedback

* typo

* typo

* Addressing PR comments and formatting code

* Removing unwanted import

* Adding a map_err

* cargo fmt

Co-authored-by: parity-processbot <>
This commit is contained in:
Hector Bulgarini
2022-09-08 17:57:42 +02:00
committed by GitHub
parent 5afe00d89c
commit bb680c093c
3 changed files with 80 additions and 38 deletions
+20 -19
View File
@@ -21,7 +21,7 @@ use super::*;
use crate as pallet_scored_pool;
use frame_support::{
ord_parameter_types, parameter_types,
bounded_vec, construct_runtime, ord_parameter_types, parameter_types,
traits::{ConstU32, ConstU64, GenesisBuild},
};
use frame_system::EnsureSignedBy;
@@ -34,7 +34,7 @@ use sp_runtime::{
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
@@ -96,13 +96,13 @@ impl pallet_balances::Config for Test {
}
parameter_types! {
pub static MembersTestValue: Vec<u64> = vec![];
pub static MembersTestValue: BoundedVec<u64,ConstU32<10_u32>> = bounded_vec![0,10];
}
pub struct TestChangeMembers;
impl ChangeMembers<u64> for TestChangeMembers {
fn change_members_sorted(incoming: &[u64], outgoing: &[u64], new: &[u64]) {
let mut old_plus_incoming = MembersTestValue::get().to_vec();
let mut old_plus_incoming = MembersTestValue::get().into_inner();
old_plus_incoming.extend_from_slice(incoming);
old_plus_incoming.sort();
@@ -112,13 +112,15 @@ impl ChangeMembers<u64> for TestChangeMembers {
assert_eq!(old_plus_incoming, new_plus_outgoing);
MembersTestValue::mutate(|m| *m = new.to_vec());
MembersTestValue::set(<BoundedVec<u64, ConstU32<10_u32>>>::truncate_from(new.to_vec()));
}
}
impl InitializeMembers<u64> for TestChangeMembers {
fn initialize_members(new_members: &[u64]) {
MembersTestValue::mutate(|m| *m = new_members.to_vec());
MembersTestValue::set(<BoundedVec<u64, ConstU32<10_u32>>>::truncate_from(
new_members.to_vec(),
));
}
}
@@ -132,25 +134,24 @@ impl Config for Test {
type Period = ConstU64<4>;
type Score = u64;
type ScoreOrigin = EnsureSignedBy<ScoreOrigin, u64>;
type MaximumMembers = ConstU32<10>;
}
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![
(5, 500_000),
(10, 500_000),
(15, 500_000),
(20, 500_000),
(31, 500_000),
(40, 500_000),
(99, 1),
],
let mut balances = vec![];
for i in 1..31 {
balances.push((i, 500_000));
}
.assimilate_storage(&mut t)
.unwrap();
balances.push((31, 500_000));
balances.push((40, 500_000));
balances.push((99, 1));
pallet_balances::GenesisConfig::<Test> { balances }
.assimilate_storage(&mut t)
.unwrap();
pallet_scored_pool::GenesisConfig::<Test> {
pool: vec![(5, None), (10, Some(1)), (20, Some(2)), (31, Some(2)), (40, Some(3))],
pool: bounded_vec![(10, Some(1)), (20, Some(2)), (31, Some(2)), (40, Some(3)), (5, None)],
member_count: 2,
}
.assimilate_storage(&mut t)