Allow pallet's info to be enumerated (#10053)

* Allow pallet's info to be enumerated

* Fixes

* Formatting

* Flat tuple for getting all pallet instances

* Renaming and fixing reversedness

* Formatting

* Fixes

* Back to nesting

* Back to nestingx

* Revert executive lib

* Reversions

* Reversions

* Fixes

* Fixes

* Formatting

* Fixes

* Spelling

* Comments
This commit is contained in:
Gavin Wood
2021-10-21 10:29:10 +02:00
committed by GitHub
parent 1660bc8cf2
commit 1dc753eb08
9 changed files with 187 additions and 7 deletions
@@ -505,6 +505,48 @@ fn storage_expand() {
});
}
#[test]
fn pallet_metadata_expands() {
use frame_support::traits::{CrateVersion, PalletInfoData, PalletsInfoAccess};
let mut infos = AllPalletsWithSystem::infos();
infos.sort_by_key(|x| x.index);
assert_eq!(
infos,
vec![
PalletInfoData {
index: 0,
name: "System",
module_name: "frame_system",
crate_version: CrateVersion { major: 4, minor: 0, patch: 0 },
},
PalletInfoData {
index: 1,
name: "Example",
module_name: "pallet",
crate_version: CrateVersion { major: 3, minor: 0, patch: 0 },
},
PalletInfoData {
index: 2,
name: "Instance1Example",
module_name: "pallet",
crate_version: CrateVersion { major: 3, minor: 0, patch: 0 },
},
PalletInfoData {
index: 3,
name: "Example2",
module_name: "pallet2",
crate_version: CrateVersion { major: 3, minor: 0, patch: 0 },
},
PalletInfoData {
index: 4,
name: "Instance1Example2",
module_name: "pallet2",
crate_version: CrateVersion { major: 3, minor: 0, patch: 0 },
},
]
);
}
#[test]
fn pallet_hooks_expand() {
TestExternalities::default().execute_with(|| {