referrerpolicy=no-referrer-when-downgrade

pallet_example_single_block_migrations/
mock.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: MIT-0
5
6// Permission is hereby granted, free of charge, to any person obtaining a copy of
7// this software and associated documentation files (the "Software"), to deal in
8// the Software without restriction, including without limitation the rights to
9// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10// of the Software, and to permit persons to whom the Software is furnished to do
11// so, subject to the following conditions:
12
13// The above copyright notice and this permission notice shall be included in all
14// copies or substantial portions of the Software.
15
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22// SOFTWARE.
23
24#![cfg(any(all(feature = "try-runtime", test), doc))]
25
26use crate::*;
27use frame_support::{derive_impl, weights::constants::ParityDbWeight};
28
29// Re-export crate as its pallet name for construct_runtime.
30use crate as pallet_example_storage_migration;
31
32type Block = frame_system::mocking::MockBlock<MockRuntime>;
33
34// For testing the pallet, we construct a mock runtime.
35frame_support::construct_runtime!(
36	pub struct MockRuntime {
37		System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
38		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
39		Example: pallet_example_storage_migration::{Pallet, Call, Storage},
40	}
41);
42
43#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
44impl frame_system::Config for MockRuntime {
45	type Block = Block;
46	type AccountData = pallet_balances::AccountData<u64>;
47	type DbWeight = ParityDbWeight;
48}
49
50#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
51impl pallet_balances::Config for MockRuntime {
52	type AccountStore = System;
53}
54
55impl Config for MockRuntime {}
56
57pub fn new_test_ext() -> sp_io::TestExternalities {
58	use sp_runtime::BuildStorage;
59
60	let t = RuntimeGenesisConfig { system: Default::default(), balances: Default::default() }
61		.build_storage()
62		.unwrap();
63	t.into()
64}