pallet_paged_list/
mock.rs1#![cfg(feature = "std")]
21
22use crate::{paged_list::StoragePagedListMeta, Config, ListPrefix};
23use frame::testing_prelude::*;
24
25type Block = frame_system::mocking::MockBlock<Test>;
26
27construct_runtime!(
29 pub enum Test {
30 System: frame_system,
31 PagedList: crate,
32 PagedList2: crate::<Instance2>,
33 }
34);
35
36#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
37impl frame_system::Config for Test {
38 type Nonce = u64;
39 type AccountId = u64;
40 type Lookup = IdentityLookup<Self::AccountId>;
41 type Block = Block;
42 type RuntimeEvent = RuntimeEvent;
43}
44
45parameter_types! {
46 pub storage ValuesPerNewPage: u32 = 5;
47 pub const MaxPages: Option<u32> = Some(20);
48}
49
50impl crate::Config for Test {
51 type Value = u32;
52 type ValuesPerNewPage = ValuesPerNewPage;
53}
54
55impl crate::Config<crate::Instance2> for Test {
56 type Value = u32;
57 type ValuesPerNewPage = ValuesPerNewPage;
58}
59
60pub type MetaOf<T, I> =
61 StoragePagedListMeta<ListPrefix<T, I>, <T as Config>::Value, <T as Config>::ValuesPerNewPage>;
62
63pub fn new_test_ext() -> TestState {
65 frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
66}
67
68pub fn test_closure<R>(f: impl FnOnce() -> R) -> R {
70 let mut ext = new_test_ext();
71 ext.execute_with(f)
72}