Migrate pallet-session to the new pallet macro (#9796)

* Migrate pallet-session to the new pallet macro

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Remove old macros

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
Qinxuan Chen
2021-09-28 11:12:57 +08:00
committed by GitHub
parent 6ec82c7a83
commit 7f550d6dd2
15 changed files with 314 additions and 266 deletions
@@ -30,15 +30,11 @@ use sp_runtime::{
KeyTypeId,
};
use sp_session::MembershipProof;
use super::{
super::{Pallet as SessionModule, SessionIndex},
Config, IdentificationTuple, ProvingTrie,
};
use super::shared;
use sp_std::prelude::*;
use super::{shared, Config, IdentificationTuple, ProvingTrie};
use crate::{Pallet as SessionModule, SessionIndex};
/// A set of validators, which was used for a fixed session index.
struct ValidatorSet<T: Config> {
validator_set: Vec<IdentificationTuple<T>>,
@@ -142,23 +138,24 @@ pub fn keep_newest<T: Config>(n_to_keep: usize) {
#[cfg(test)]
mod tests {
use super::{
super::{onchain, Module},
*,
};
use crate::mock::{
force_new_session, set_next_validators, Session, System, Test, NEXT_VALIDATORS,
use super::*;
use crate::{
historical::{onchain, Module},
mock::{force_new_session, set_next_validators, Session, System, Test, NEXT_VALIDATORS},
};
use codec::Encode;
use frame_support::traits::{KeyOwnerProofSystem, OnInitialize};
use sp_core::{
crypto::key_types::DUMMY,
offchain::{testing::TestOffchainExt, OffchainDbExt, OffchainWorkerExt, StorageKind},
};
use frame_support::BasicExternalities;
use sp_runtime::testing::UintAuthorityId;
use frame_support::{
traits::{GenesisBuild, KeyOwnerProofSystem, OnInitialize},
BasicExternalities,
};
type Historical = Module<Test>;
pub fn new_test_ext() -> sp_io::TestExternalities {