Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ edition = '2018'
name = 'moonbeam'
path = 'src/main.rs'

[features]
test-spec = []

[dependencies]
async-io = "1.3"
derive_more = '0.99'
Expand Down
2 changes: 1 addition & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub fn moonbeam_inflation_config() -> InflationInfo<Balance> {
}
}

fn testnet_genesis(
pub fn testnet_genesis(
root_key: AccountId,
stakers: Vec<(AccountId, Option<AccountId>, Balance)>,
inflation_config: InflationInfo<Balance>,
Expand Down
2 changes: 2 additions & 0 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ fn load_spec(
)?)),
"dev" | "development" => Ok(Box::new(chain_spec::development_chain_spec(None, None))),
"local" => Ok(Box::new(chain_spec::get_chain_spec(para_id))),
#[cfg(feature = "test-spec")]
"staking" => Ok(Box::new(crate::test_spec::staking_spec(para_id))),
"" => Err(
"You have not specified what chain to sync. In the future, this will default to \
Moonbeam mainnet. Mainnet is not yet live so you must choose a spec."
Expand Down
2 changes: 2 additions & 0 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#![warn(unused_extern_crates)]

mod chain_spec;
#[cfg(feature = "test-spec")]
mod test_spec;
#[macro_use]
mod service;
mod cli;
Expand Down
71 changes: 71 additions & 0 deletions node/src/test_spec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright 2019-2021 PureStake Inc.
// This file is part of Moonbeam.

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

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

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

//! Embedded specs for testing purposes, must be compiled with --features=test-spec
use crate::chain_spec::{moonbeam_inflation_config, testnet_genesis, ChainSpec, Extensions};
use cumulus_primitives_core::ParaId;
use moonbeam_runtime::{AccountId, GLMR};
use sc_service::ChainType;
use std::str::FromStr;

/// Generate testing chain_spec for staking integration tests with accounts initialized for
/// collating and nominating.
pub fn staking_spec(para_id: ParaId) -> ChainSpec {
ChainSpec::from_genesis(
"Moonbase Development Testnet",
"staking",
ChainType::Local,
move || {
testnet_genesis(
// Root
AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b").unwrap(),
// Collators
vec![
(
AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b").unwrap(),
None,
1_000 * GLMR,
),
(
AccountId::from_str("C0F0f4ab324C46e55D02D0033343B4Be8A55532d").unwrap(),
None,
1_000 * GLMR,
),
],
// Inflation config
moonbeam_inflation_config(),
// Endowed accounts (each minted 1 << 80 balance)
vec![
AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b").unwrap(),
AccountId::from_str("C0F0f4ab324C46e55D02D0033343B4Be8A55532d").unwrap(),
AccountId::from_str("Ff64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB").unwrap(),
AccountId::from_str("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac").unwrap(),
],
para_id,
// Chain ID
1280,
)
},
vec![],
None,
None,
Some(serde_json::from_str("{\"tokenDecimals\": 18}").expect("Provided valid json map")),
Extensions {
relay_chain: "local_testnet".into(),
para_id: para_id.into(),
},
)
}
6 changes: 3 additions & 3 deletions tools/config_moonbeam_staking.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"wsPort": 36946,
"port": 36335,
"balance": "1000",
"chain": "staking-test-spec.json",
"chain": "staking",
"flags": [
"--no-telemetry",
"--no-prometheus",
Expand All @@ -49,7 +49,7 @@
"wsPort": 36947,
"port": 36336,
"balance": "1000",
"chain": "staking-test-spec.json",
"chain": "staking",
"flags": [
"--no-telemetry",
"--no-prometheus",
Expand All @@ -65,7 +65,7 @@
"wsPort": 36948,
"port": 36337,
"balance": "1000",
"chain": "staking-test-spec.json",
"chain": "staking",
"flags": [
"--no-telemetry",
"--no-prometheus",
Expand Down
94 changes: 0 additions & 94 deletions tools/staking-test-spec.json

This file was deleted.