referrerpolicy=no-referrer-when-downgrade

penpal_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 frame_support::parameter_types;
18use sp_core::storage::Storage;
19use sp_keyring::Sr25519Keyring as Keyring;
20
21// Cumulus
22use emulated_integration_tests_common::{
23	accounts, build_genesis_storage, collators, SAFE_XCM_VERSION,
24};
25use parachains_common::{AccountId, Balance};
26use penpal_runtime::xcm_config::{LocalReservableFromAssetHub, RelayLocation, UsdtFromAssetHub};
27// Penpal
28pub const PARA_ID_A: u32 = 2000;
29pub const PARA_ID_B: u32 = 2001;
30pub const ED: Balance = penpal_runtime::EXISTENTIAL_DEPOSIT;
31pub const USDT_ED: Balance = 70_000;
32
33parameter_types! {
34	pub PenpalSudoAccount: AccountId = Keyring::Alice.to_account_id();
35	pub PenpalAssetOwner: AccountId = PenpalSudoAccount::get();
36}
37
38pub fn genesis(para_id: u32) -> Storage {
39	let genesis_config = penpal_runtime::RuntimeGenesisConfig {
40		system: penpal_runtime::SystemConfig::default(),
41		balances: penpal_runtime::BalancesConfig {
42			balances: accounts::init_balances().iter().cloned().map(|k| (k, ED * 4096)).collect(),
43			..Default::default()
44		},
45		parachain_info: penpal_runtime::ParachainInfoConfig {
46			parachain_id: para_id.into(),
47			..Default::default()
48		},
49		collator_selection: penpal_runtime::CollatorSelectionConfig {
50			invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(),
51			candidacy_bond: ED * 16,
52			..Default::default()
53		},
54		session: penpal_runtime::SessionConfig {
55			keys: collators::invulnerables()
56				.into_iter()
57				.map(|(acc, aura)| {
58					(
59						acc.clone(),                          // account id
60						acc,                                  // validator id
61						penpal_runtime::SessionKeys { aura }, // session keys
62					)
63				})
64				.collect(),
65			..Default::default()
66		},
67		polkadot_xcm: penpal_runtime::PolkadotXcmConfig {
68			safe_xcm_version: Some(SAFE_XCM_VERSION),
69			..Default::default()
70		},
71		sudo: penpal_runtime::SudoConfig { key: Some(PenpalSudoAccount::get()) },
72		assets: penpal_runtime::AssetsConfig {
73			assets: vec![(
74				penpal_runtime::xcm_config::TELEPORTABLE_ASSET_ID,
75				PenpalAssetOwner::get(),
76				false,
77				ED,
78			)],
79			..Default::default()
80		},
81		foreign_assets: penpal_runtime::ForeignAssetsConfig {
82			assets: vec![
83				// Relay Native asset representation
84				(RelayLocation::get(), PenpalAssetOwner::get(), true, ED),
85				// Sufficient AssetHub asset representation
86				(LocalReservableFromAssetHub::get(), PenpalAssetOwner::get(), true, ED),
87				// USDT from AssetHub
88				(UsdtFromAssetHub::get(), PenpalAssetOwner::get(), true, USDT_ED),
89			],
90			..Default::default()
91		},
92		..Default::default()
93	};
94
95	build_genesis_storage(
96		&genesis_config,
97		penpal_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
98	)
99}