Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit f4a2e84

Browse files
authored
chore: move whitelist test to better place and add missing Inactive Issuance (#14130)
* chore: move whitelist test to better palace and add missing `Inactive Issuance` * remove duplicated --------- Co-authored-by: parity-processbot <>
1 parent 6507a79 commit f4a2e84

File tree

4 files changed

+38
-76
lines changed

4 files changed

+38
-76
lines changed

bin/node-template/runtime/src/lib.rs

-37
Original file line numberDiff line numberDiff line change
@@ -573,40 +573,3 @@ impl_runtime_apis! {
573573
}
574574
}
575575
}
576-
577-
#[cfg(test)]
578-
mod tests {
579-
use super::*;
580-
use frame_support::traits::WhitelistedStorageKeys;
581-
use sp_core::hexdisplay::HexDisplay;
582-
use std::collections::HashSet;
583-
584-
#[test]
585-
fn check_whitelist() {
586-
let whitelist: HashSet<String> = AllPalletsWithSystem::whitelisted_storage_keys()
587-
.iter()
588-
.map(|e| HexDisplay::from(&e.key).to_string())
589-
.collect();
590-
591-
// Block Number
592-
assert!(
593-
whitelist.contains("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac")
594-
);
595-
// Total Issuance
596-
assert!(
597-
whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80")
598-
);
599-
// Execution Phase
600-
assert!(
601-
whitelist.contains("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a")
602-
);
603-
// Event Count
604-
assert!(
605-
whitelist.contains("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850")
606-
);
607-
// System Events
608-
assert!(
609-
whitelist.contains("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7")
610-
);
611-
}
612-
}

bin/node/runtime/src/lib.rs

-36
Original file line numberDiff line numberDiff line change
@@ -2486,44 +2486,8 @@ impl_runtime_apis! {
24862486
mod tests {
24872487
use super::*;
24882488
use frame_election_provider_support::NposSolution;
2489-
use frame_support::traits::WhitelistedStorageKeys;
24902489
use frame_system::offchain::CreateSignedTransaction;
2491-
use sp_core::hexdisplay::HexDisplay;
24922490
use sp_runtime::UpperOf;
2493-
use std::collections::HashSet;
2494-
2495-
#[test]
2496-
fn check_whitelist() {
2497-
let whitelist: HashSet<String> = AllPalletsWithSystem::whitelisted_storage_keys()
2498-
.iter()
2499-
.map(|e| HexDisplay::from(&e.key).to_string())
2500-
.collect();
2501-
2502-
// Block Number
2503-
assert!(
2504-
whitelist.contains("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac")
2505-
);
2506-
// Total Issuance
2507-
assert!(
2508-
whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80")
2509-
);
2510-
// Execution Phase
2511-
assert!(
2512-
whitelist.contains("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a")
2513-
);
2514-
// Event Count
2515-
assert!(
2516-
whitelist.contains("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850")
2517-
);
2518-
// System Events
2519-
assert!(
2520-
whitelist.contains("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7")
2521-
);
2522-
// System BlockWeight
2523-
assert!(
2524-
whitelist.contains("26aa394eea5630e07c48ae0c9558cef734abf5cb34d6244378cddbf18e849d96")
2525-
);
2526-
}
25272491

25282492
#[test]
25292493
fn validate_transaction_submitter_bounds() {

frame/balances/src/tests/mod.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,22 @@ use frame_support::{
2727
parameter_types,
2828
traits::{
2929
tokens::fungible, ConstU32, ConstU64, ConstU8, Imbalance as ImbalanceT, OnUnbalanced,
30-
StorageMapShim, StoredMap,
30+
StorageMapShim, StoredMap, WhitelistedStorageKeys,
3131
},
3232
weights::{IdentityFee, Weight},
3333
RuntimeDebug,
3434
};
3535
use frame_system::{self as system, RawOrigin};
3636
use pallet_transaction_payment::{ChargeTransactionPayment, CurrencyAdapter, Multiplier};
3737
use scale_info::TypeInfo;
38-
use sp_core::H256;
38+
use sp_core::{hexdisplay::HexDisplay, H256};
3939
use sp_io;
4040
use sp_runtime::{
4141
testing::Header,
4242
traits::{BadOrigin, IdentityLookup, SignedExtension, Zero},
4343
ArithmeticError, DispatchError, DispatchResult, FixedPointNumber, TokenError,
4444
};
45+
use std::collections::BTreeSet;
4546

4647
mod currency_tests;
4748
mod dispatchable_tests;
@@ -304,3 +305,15 @@ fn weights_sane() {
304305
let info = crate::Call::<Test>::force_unreserve { who: 10, amount: 4 }.get_dispatch_info();
305306
assert_eq!(<() as crate::WeightInfo>::force_unreserve(), info.weight);
306307
}
308+
309+
#[test]
310+
fn check_whitelist() {
311+
let whitelist: BTreeSet<String> = AllPalletsWithSystem::whitelisted_storage_keys()
312+
.iter()
313+
.map(|s| HexDisplay::from(&s.key).to_string())
314+
.collect();
315+
// Inactive Issuance
316+
assert!(whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f1ccde6872881f893a21de93dfe970cd5"));
317+
// Total Issuance
318+
assert!(whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"));
319+
}

frame/system/src/tests.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,36 @@ use crate::*;
1919
use frame_support::{
2020
assert_noop, assert_ok,
2121
dispatch::{Pays, PostDispatchInfo, WithPostDispatchInfo},
22+
traits::WhitelistedStorageKeys,
2223
};
24+
use std::collections::BTreeSet;
25+
2326
use mock::{RuntimeOrigin, *};
24-
use sp_core::H256;
27+
use sp_core::{hexdisplay::HexDisplay, H256};
2528
use sp_runtime::{
2629
traits::{BlakeTwo256, Header},
2730
DispatchError, DispatchErrorWithPostInfo,
2831
};
2932

33+
#[test]
34+
fn check_whitelist() {
35+
let whitelist: BTreeSet<String> = AllPalletsWithSystem::whitelisted_storage_keys()
36+
.iter()
37+
.map(|s| HexDisplay::from(&s.key).to_string())
38+
.collect();
39+
40+
// Block Number
41+
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"));
42+
// Execution Phase
43+
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a"));
44+
// Event Count
45+
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850"));
46+
// System Events
47+
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7"));
48+
// System BlockWeight
49+
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef734abf5cb34d6244378cddbf18e849d96"));
50+
}
51+
3052
#[test]
3153
fn origin_works() {
3254
let o = RuntimeOrigin::from(RawOrigin::<u64>::Signed(1u64));

0 commit comments

Comments
 (0)