1
// Copyright 2019-2022 PureStake Inc.
2
// This file is part of Moonbeam.
3

            
4
// Moonbeam is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Moonbeam is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Moonbeam.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
//! Embedded specs for testing purposes, must be compiled with --features=test-spec
18
use crate::chain_spec::moonbase::{testnet_genesis, ChainSpec};
19
use crate::chain_spec::{get_from_seed, Extensions};
20
use cumulus_primitives_core::ParaId;
21
use hex_literal::hex;
22
use moonbase_runtime::{currency::UNIT, AccountId, WASM_BINARY};
23
use nimbus_primitives::NimbusId;
24
use sc_service::ChainType;
25

            
26
/// Generate testing chain_spec for staking integration tests with accounts initialized for
27
/// collating and nominating.
28
pub fn staking_spec(para_id: ParaId) -> ChainSpec {
29
	ChainSpec::builder(
30
		WASM_BINARY.expect("WASM binary was not build, please build it!"),
31
		Extensions {
32
			relay_chain: "westend_local".into(),
33
			para_id: para_id.into(),
34
		},
35
	)
36
	.with_name("Moonbase Development Testnet")
37
	.with_id("staking")
38
	.with_chain_type(ChainType::Local)
39
	.with_properties(
40
		serde_json::from_str("{\"tokenDecimals\": 18}").expect("Provided valid json map"),
41
	)
42
	.with_genesis_config(testnet_genesis(
43
		// Root
44
		AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")),
45
		// Treasury Council members: Baltathar, Charleth and Dorothy
46
		vec![
47
			AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
48
			AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
49
			AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
50
		],
51
		// Open Tech Committee members: Alith and Baltathar
52
		vec![
53
			AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")),
54
			AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
55
		],
56
		// Collators
57
		vec![
58
			(
59
				AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")),
60
				get_from_seed::<NimbusId>("Alice"),
61
				1_000 * UNIT,
62
			),
63
			(
64
				AccountId::from(hex!("C0F0f4ab324C46e55D02D0033343B4Be8A55532d")),
65
				get_from_seed::<NimbusId>("Faith"),
66
				1_000 * UNIT,
67
			),
68
		],
69
		// Delegations
70
		vec![],
71
		// Endowed accounts (each minted 1 << 80 balance)
72
		vec![
73
			// Alith, Baltathar, Charleth, Dorothy and Faith
74
			AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")),
75
			AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
76
			AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
77
			AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
78
			AccountId::from(hex!("C0F0f4ab324C46e55D02D0033343B4Be8A55532d")),
79
			// Additional accounts
80
			AccountId::from(hex!("Ff64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB")),
81
			AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
82
		],
83
		3_000_000 * UNIT,
84
		para_id,
85
		// Chain ID
86
		1280,
87
	))
88
	.build()
89
}
90

            
91
#[cfg(feature = "lazy-loading")]
92
pub fn lazy_loading_spec_builder(para_id: ParaId) -> sc_chain_spec::ChainSpecBuilder<Extensions> {
93
	use moonbeam_runtime::currency::{GLMR, SUPPLY_FACTOR};
94
	crate::chain_spec::moonbeam::ChainSpec::builder(
95
		moonbeam_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!"),
96
		Default::default(),
97
	)
98
	.with_name("Lazy Loading")
99
	.with_id("lazy_loading")
100
	.with_chain_type(ChainType::Development)
101
	.with_properties(
102
		serde_json::from_str(
103
			"{\"tokenDecimals\": 18, \"tokenSymbol\": \"GLMR\", \"SS58Prefix\": 1284}",
104
		)
105
		.expect("Provided valid json map"),
106
	)
107
	.with_genesis_config(crate::chain_spec::moonbeam::testnet_genesis(
108
		// Treasury Council members: Baltathar, Charleth and Dorothy
109
		vec![
110
			AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
111
			AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
112
			AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
113
		],
114
		// Open Tech Committee members: Alith and Baltathar
115
		vec![
116
			AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")),
117
			AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
118
		],
119
		// Collators
120
		vec![
121
			(
122
				AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")),
123
				get_from_seed::<NimbusId>("Alice"),
124
				20_000 * GLMR * SUPPLY_FACTOR,
125
			),
126
			(
127
				AccountId::from(hex!("C0F0f4ab324C46e55D02D0033343B4Be8A55532d")),
128
				get_from_seed::<NimbusId>("Faith"),
129
				20_000 * GLMR * SUPPLY_FACTOR,
130
			),
131
		],
132
		// Delegations
133
		vec![],
134
		// Endowed accounts (each minted 1 << 80 balance)
135
		vec![
136
			// Alith, Baltathar, Charleth, Dorothy and Faith
137
			AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")),
138
			AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")),
139
			AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")),
140
			AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")),
141
			AccountId::from(hex!("C0F0f4ab324C46e55D02D0033343B4Be8A55532d")),
142
			// Additional accounts
143
			AccountId::from(hex!("Ff64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB")),
144
			AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
145
		],
146
		1_500_000 * GLMR * SUPPLY_FACTOR,
147
		para_id,
148
		// Chain ID
149
		1280,
150
	))
151
}