referrerpolicy=no-referrer-when-downgrade

node_testing/
genesis.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Genesis Configuration.
20
21use crate::keyring::*;
22use kitchensink_runtime::{
23	constants::currency::*, AccountId, AssetsConfig, BalancesConfig, IndicesConfig,
24	RuntimeGenesisConfig, SessionConfig, SocietyConfig, StakerStatus, StakingConfig,
25};
26use sp_keyring::Ed25519Keyring;
27use sp_runtime::Perbill;
28
29/// Create genesis runtime configuration for tests.
30pub fn config() -> RuntimeGenesisConfig {
31	config_endowed(Default::default())
32}
33
34/// Create genesis runtime configuration for tests with some extra
35/// endowed accounts.
36pub fn config_endowed(extra_endowed: Vec<AccountId>) -> RuntimeGenesisConfig {
37	let mut endowed = vec![
38		(alice(), 111 * DOLLARS),
39		(bob(), 100 * DOLLARS),
40		(charlie(), 100_000_000 * DOLLARS),
41		(dave(), 112 * DOLLARS),
42		(eve(), 101 * DOLLARS),
43		(ferdie(), 101 * DOLLARS),
44	];
45
46	endowed.extend(extra_endowed.into_iter().map(|endowed| (endowed, 100 * DOLLARS)));
47
48	RuntimeGenesisConfig {
49		indices: IndicesConfig { indices: vec![] },
50		balances: BalancesConfig { balances: endowed, ..Default::default() },
51		session: SessionConfig {
52			keys: vec![
53				(alice(), dave(), session_keys_from_seed(Ed25519Keyring::Alice.into())),
54				(bob(), eve(), session_keys_from_seed(Ed25519Keyring::Bob.into())),
55				(charlie(), ferdie(), session_keys_from_seed(Ed25519Keyring::Charlie.into())),
56			],
57			..Default::default()
58		},
59		staking: StakingConfig {
60			stakers: vec![
61				(dave(), dave(), 111 * DOLLARS, StakerStatus::Validator),
62				(eve(), eve(), 100 * DOLLARS, StakerStatus::Validator),
63				(ferdie(), ferdie(), 100 * DOLLARS, StakerStatus::Validator),
64			],
65			validator_count: 3,
66			minimum_validator_count: 0,
67			slash_reward_fraction: Perbill::from_percent(10),
68			invulnerables: vec![alice(), bob(), charlie()],
69			..Default::default()
70		},
71		society: SocietyConfig { pot: 0 },
72		assets: AssetsConfig { assets: vec![(9, alice(), true, 1)], ..Default::default() },
73		..Default::default()
74	}
75}