migrate alliance, fast-unstake and bags list to use derive-impl (#1636)

Moving a few pallets to the latest and greatest `derive_impl` to give it
a try.

Part of #171

---------

Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
Kian Paimani
2023-10-01 16:16:14 +02:00
committed by GitHub
parent e8baac7848
commit 2ed66a0960
12 changed files with 34 additions and 139 deletions
+3 -23
View File
@@ -20,11 +20,11 @@
use super::*;
use crate::{self as bags_list};
use frame_election_provider_support::VoteWeight;
use frame_support::parameter_types;
use frame_support::{derive_impl, parameter_types};
use sp_runtime::BuildStorage;
use std::collections::HashMap;
pub type AccountId = u32;
pub type AccountId = <Runtime as frame_system::Config>::AccountId;
pub type Balance = u32;
parameter_types! {
@@ -48,30 +48,10 @@ impl frame_election_provider_support::ScoreProvider<AccountId> for StakingMock {
}
}
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
type SS58Prefix = ();
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_core::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId;
type Lookup = sp_runtime::traits::IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = ();
type DbWeight = ();
type BlockLength = ();
type BlockWeights = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
+3 -3
View File
@@ -163,7 +163,7 @@ mod pallet {
assert_eq!(Bag::<Runtime>::get(10).unwrap(), Bag::new(Some(1), Some(3), 10));
assert_eq!(Bag::<Runtime>::get(1_000).unwrap(), Bag::new(Some(2), Some(2), 1_000));
assert_eq!(get_list_as_ids(), vec![2u32, 1, 4, 3]);
assert_eq!(get_list_as_ids(), vec![2u64, 1, 4, 3]);
// when
StakingMock::set_score_of(&2, 10);
@@ -272,10 +272,10 @@ mod pallet {
// given
assert_eq!(List::<Runtime>::get_bags(), vec![(20, vec![10, 11, 12])]);
// 11 now has more weight than 10 and can be moved before it.
StakingMock::set_score_of(&11u32, 17);
StakingMock::set_score_of(&11u64, 17);
// when
assert_ok!(BagsList::put_in_front_of_other(RuntimeOrigin::signed(42), 11u32, 10));
assert_ok!(BagsList::put_in_front_of_other(RuntimeOrigin::signed(42), 11u64, 10));
// then
assert_eq!(List::<Runtime>::get_bags(), vec![(20, vec![11, 10, 12])]);