referrerpolicy=no-referrer-when-downgrade

westend_emulated_chain/
genesis.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// SPDX-License-Identifier: Apache-2.0
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// 	http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16// Substrate
17use sc_consensus_grandpa::AuthorityId as GrandpaId;
18use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
19use sp_consensus_babe::AuthorityId as BabeId;
20use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
21use sp_core::storage::Storage;
22
23// Polkadot
24use polkadot_primitives::{AssignmentId, ValidatorId};
25
26// Cumulus
27use emulated_integration_tests_common::{
28	accounts, build_genesis_storage, get_host_config, validators,
29};
30use parachains_common::Balance;
31use westend_runtime_constants::currency::UNITS as WND;
32
33pub const ED: Balance = westend_runtime_constants::currency::EXISTENTIAL_DEPOSIT;
34const ENDOWMENT: u128 = 1_000_000 * WND;
35
36fn session_keys(
37	babe: BabeId,
38	grandpa: GrandpaId,
39	para_validator: ValidatorId,
40	para_assignment: AssignmentId,
41	authority_discovery: AuthorityDiscoveryId,
42	beefy: BeefyId,
43) -> westend_runtime::SessionKeys {
44	westend_runtime::SessionKeys {
45		babe,
46		grandpa,
47		para_validator,
48		para_assignment,
49		authority_discovery,
50		beefy,
51	}
52}
53
54pub fn genesis() -> Storage {
55	let genesis_config = westend_runtime::RuntimeGenesisConfig {
56		system: westend_runtime::SystemConfig::default(),
57		balances: westend_runtime::BalancesConfig {
58			balances: accounts::init_balances().iter().cloned().map(|k| (k, ENDOWMENT)).collect(),
59			..Default::default()
60		},
61		session: westend_runtime::SessionConfig {
62			keys: validators::initial_authorities()
63				.iter()
64				.map(|x| {
65					(
66						x.0.clone(),
67						x.0.clone(),
68						session_keys(
69							x.2.clone(),
70							x.3.clone(),
71							x.4.clone(),
72							x.5.clone(),
73							x.6.clone(),
74							x.7.clone(),
75						),
76					)
77				})
78				.collect::<Vec<_>>(),
79			..Default::default()
80		},
81		babe: westend_runtime::BabeConfig {
82			authorities: Default::default(),
83			epoch_config: westend_runtime::BABE_GENESIS_EPOCH_CONFIG,
84			..Default::default()
85		},
86		configuration: westend_runtime::ConfigurationConfig { config: get_host_config() },
87		..Default::default()
88	};
89
90	build_genesis_storage(&genesis_config, westend_runtime::WASM_BINARY.unwrap())
91}