Unverified Commit cfde0767 authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

Adds integration test based on adder collator (#1928)



* Adds integration test based on adder collator

This adds an integration test for parachains that uses the adder
collator. The test will start two relay chain nodes and one collator and
waits until 4 blocks are build and enacted by the parachain.

* Make sure the integration test is run in CI

* Fix wasm compilation

* Update parachain/test-parachains/adder/collator/src/lib.rs
Co-authored-by: Sergey Pepyakin's avatarSergei Shulepov <sergei@parity.io>

* Update cli/src/command.rs
Co-authored-by: Sergey Pepyakin's avatarSergei Shulepov <sergei@parity.io>
parent 75ce90a1
Pipeline #150058 canceled with stages
in 11 minutes and 37 seconds
This diff is collapsed.
......@@ -17,17 +17,19 @@ crate-type = ["cdylib", "rlib"]
log = "0.4.11"
thiserror = "1.0.21"
structopt = { version = "0.3.8", optional = true }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
wasm-bindgen = { version = "0.2.57", optional = true }
wasm-bindgen-futures = { version = "0.4.7", optional = true }
service = { package = "polkadot-service", path = "../node/service", default-features = false, optional = true }
polkadot-parachain = { path = "../parachain", optional = true }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
wasm-bindgen = { version = "0.2.57", optional = true }
wasm-bindgen-futures = { version = "0.4.7", optional = true }
browser-utils = { package = "substrate-browser-utils", git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
# this crate is used only to enable `trie-memory-tracker` feature
# see https://github.com/paritytech/substrate/pull/6745
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
......@@ -36,7 +38,7 @@ sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master",
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
[features]
default = [ "wasmtime", "db", "cli", "full-node", "trie-memory-tracker" ]
default = [ "wasmtime", "db", "cli", "full-node", "trie-memory-tracker", "polkadot-parachain" ]
wasmtime = [ "sc-cli/wasmtime" ]
db = [ "service/db" ]
cli = [
......
......@@ -219,11 +219,11 @@ pub fn run() -> Result<()> {
Some(Subcommand::ValidationWorker(cmd)) => {
let _ = sc_cli::init_logger("", sc_tracing::TracingReceiver::Log, None);
if cfg!(feature = "browser") {
if cfg!(feature = "browser") || cfg!(target_os = "android") {
Err(sc_cli::Error::Input("Cannot run validation worker in browser".into()))
} else {
#[cfg(all(not(feature = "browser"), not(feature = "service-rewr")))]
service::run_validation_worker(&cmd.mem_id)?;
#[cfg(not(any(target_os = "android", feature = "browser")))]
polkadot_parachain::wasm_executor::run_worker(&cmd.mem_id)?;
Ok(())
}
},
......
......@@ -31,19 +31,14 @@ use polkadot_subsystem::{
ValidationFailed, RuntimeApiRequest,
},
};
use polkadot_node_subsystem_util::{
metrics::{self, prometheus},
};
use polkadot_node_subsystem_util::metrics::{self, prometheus};
use polkadot_subsystem::errors::RuntimeApiError;
use polkadot_node_primitives::{ValidationResult, InvalidCandidate};
use polkadot_primitives::v1::{
ValidationCode, PoV, CandidateDescriptor, PersistedValidationData,
OccupiedCoreAssumption, Hash, ValidationOutputs,
};
use polkadot_parachain::wasm_executor::{
self, ValidationPool, ExecutionMode, ValidationError,
InvalidCandidate as WasmInvalidCandidate,
};
use polkadot_parachain::wasm_executor::{self, ExecutionMode, ValidationError, InvalidCandidate as WasmInvalidCandidate};
use polkadot_parachain::primitives::{ValidationResult as WasmValidationResult, ValidationParams};
use parity_scale_codec::Encode;
......@@ -60,57 +55,13 @@ const LOG_TARGET: &'static str = "candidate_validation";
pub struct CandidateValidationSubsystem<S> {
spawn: S,
metrics: Metrics,
}
#[derive(Clone)]
struct MetricsInner {
validation_requests: prometheus::CounterVec<prometheus::U64>,
}
/// Candidate validation metrics.
#[derive(Default, Clone)]
pub struct Metrics(Option<MetricsInner>);
impl Metrics {
fn on_validation_event(&self, event: &Result<ValidationResult, ValidationFailed>) {
if let Some(metrics) = &self.0 {
match event {
Ok(ValidationResult::Valid(_, _)) => {
metrics.validation_requests.with_label_values(&["valid"]).inc();
},
Ok(ValidationResult::Invalid(_)) => {
metrics.validation_requests.with_label_values(&["invalid"]).inc();
},
Err(_) => {
metrics.validation_requests.with_label_values(&["validation failure"]).inc();
},
}
}
}
}
impl metrics::Metrics for Metrics {
fn try_register(registry: &prometheus::Registry) -> Result<Self, prometheus::PrometheusError> {
let metrics = MetricsInner {
validation_requests: prometheus::register(
prometheus::CounterVec::new(
prometheus::Opts::new(
"parachain_validation_requests_total",
"Number of validation requests served.",
),
&["validity"],
)?,
registry,
)?,
};
Ok(Metrics(Some(metrics)))
}
execution_mode: ExecutionMode,
}
impl<S> CandidateValidationSubsystem<S> {
/// Create a new `CandidateValidationSubsystem` with the given task spawner.
pub fn new(spawn: S, metrics: Metrics) -> Self {
CandidateValidationSubsystem { spawn, metrics }
pub fn new(spawn: S, metrics: Metrics, execution_mode: ExecutionMode) -> Self {
CandidateValidationSubsystem { spawn, metrics, execution_mode }
}
}
......@@ -119,7 +70,7 @@ impl<S, C> Subsystem<C> for CandidateValidationSubsystem<S> where
S: SpawnNamed + Clone + 'static,
{
fn start(self, ctx: C) -> SpawnedSubsystem {
let future = run(ctx, self.spawn, self.metrics)
let future = run(ctx, self.spawn, self.metrics, self.execution_mode)
.map_err(|e| SubsystemError::with_origin("candidate-validation", e))
.boxed();
SpawnedSubsystem {
......@@ -133,11 +84,8 @@ async fn run(
mut ctx: impl SubsystemContext<Message = CandidateValidationMessage>,
spawn: impl SpawnNamed + Clone + 'static,
metrics: Metrics,
)
-> SubsystemResult<()>
{
let execution_mode = ExecutionMode::ExternalProcessSelfHost(ValidationPool::new());
execution_mode: ExecutionMode,
) -> SubsystemResult<()> {
loop {
match ctx.recv().await? {
FromOverseer::Signal(OverseerSignal::ActiveLeaves(_)) => {}
......@@ -499,6 +447,51 @@ fn validate_candidate_exhaustive<B: ValidationBackend, S: SpawnNamed + 'static>(
}
}
#[derive(Clone)]
struct MetricsInner {
validation_requests: prometheus::CounterVec<prometheus::U64>,
}
/// Candidate validation metrics.
#[derive(Default, Clone)]
pub struct Metrics(Option<MetricsInner>);
impl Metrics {
fn on_validation_event(&self, event: &Result<ValidationResult, ValidationFailed>) {
if let Some(metrics) = &self.0 {
match event {
Ok(ValidationResult::Valid(_, _)) => {
metrics.validation_requests.with_label_values(&["valid"]).inc();
},
Ok(ValidationResult::Invalid(_)) => {
metrics.validation_requests.with_label_values(&["invalid"]).inc();
},
Err(_) => {
metrics.validation_requests.with_label_values(&["validation failure"]).inc();
},
}
}
}
}
impl metrics::Metrics for Metrics {
fn try_register(registry: &prometheus::Registry) -> Result<Self, prometheus::PrometheusError> {
let metrics = MetricsInner {
validation_requests: prometheus::register(
prometheus::CounterVec::new(
prometheus::Opts::new(
"parachain_validation_requests_total",
"Number of validation requests served.",
),
&["validity"],
)?,
registry,
)?,
};
Ok(Metrics(Some(metrics)))
}
}
#[cfg(test)]
mod tests {
use super::*;
......
......@@ -771,7 +771,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
pallet_sudo: Some(rococo_runtime::SudoConfig {
key: endowed_accounts[0].clone(),
}),
parachains_configuration: Some(rococo_runtime::ParachainConfigConfig {
parachains_configuration: Some(rococo_runtime::ParachainsConfigurationConfig {
config: polkadot_runtime_parachains::configuration::HostConfiguration {
validation_upgrade_frequency: 600u32,
validation_upgrade_delay: 300,
......@@ -1223,7 +1223,7 @@ pub fn rococo_testnet_genesis(
}),
pallet_staking: Some(Default::default()),
pallet_sudo: Some(rococo_runtime::SudoConfig { key: root_key }),
parachains_configuration: Some(rococo_runtime::ParachainConfigConfig {
parachains_configuration: Some(rococo_runtime::ParachainsConfigurationConfig {
config: polkadot_runtime_parachains::configuration::HostConfiguration {
validation_upgrade_frequency: 600u32,
validation_upgrade_delay: 300,
......
......@@ -50,7 +50,7 @@ use service::RpcHandlers;
pub use self::client::{AbstractClient, Client, ClientHandle, ExecuteWithClient, RuntimeApiCollection};
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec, RococoChainSpec};
pub use consensus_common::{Proposal, SelectChain, BlockImport, RecordProof, block_validation::Chain};
pub use polkadot_parachain::wasm_executor::run_worker as run_validation_worker;
pub use polkadot_parachain::wasm_executor::ExecutionMode;
pub use polkadot_primitives::v1::{Block, BlockId, CollatorId, Hash, Id as ParaId};
pub use sc_client_api::{Backend, ExecutionStrategy, CallExecutor};
pub use sc_consensus::LongestChain;
......@@ -296,6 +296,7 @@ fn real_overseer<Spawner, RuntimeClient>(
registry: Option<&Registry>,
spawner: Spawner,
_: IsCollator,
_: ExecutionMode,
) -> Result<(Overseer<Spawner>, OverseerHandler), Error>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
......@@ -321,6 +322,7 @@ fn real_overseer<Spawner, RuntimeClient>(
registry: Option<&Registry>,
spawner: Spawner,
is_collator: IsCollator,
execution_mode: ExecutionMode,
) -> Result<(Overseer<Spawner>, OverseerHandler), Error>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
......@@ -375,6 +377,7 @@ where
candidate_validation: CandidateValidationSubsystem::new(
spawner.clone(),
Metrics::register(registry)?,
execution_mode,
),
chain_api: ChainApiSubsystem::new(
runtime_client.clone(),
......@@ -476,6 +479,7 @@ pub fn new_full<RuntimeApi, Executor>(
is_collator: IsCollator,
grandpa_pause: Option<(u32, u32)>,
authority_discovery_config: Option<AuthorityWorkerConfig>,
execution_mode: ExecutionMode,
) -> Result<NewFull<Arc<FullClient<RuntimeApi, Executor>>>, Error>
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
......@@ -611,6 +615,7 @@ pub fn new_full<RuntimeApi, Executor>(
prometheus_registry.as_ref(),
spawner,
is_collator,
execution_mode,
)?;
let overseer_handler_clone = overseer_handler.clone();
......@@ -910,6 +915,7 @@ pub fn build_full(
is_collator,
grandpa_pause,
authority_discovery_config,
Default::default(),
).map(|full| full.with_client(Client::Rococo))
} else if config.chain_spec.is_kusama() {
new_full::<kusama_runtime::RuntimeApi, KusamaExecutor>(
......@@ -917,6 +923,7 @@ pub fn build_full(
is_collator,
grandpa_pause,
authority_discovery_config,
Default::default(),
).map(|full| full.with_client(Client::Kusama))
} else if config.chain_spec.is_westend() {
new_full::<westend_runtime::RuntimeApi, WestendExecutor>(
......@@ -924,6 +931,7 @@ pub fn build_full(
is_collator,
grandpa_pause,
authority_discovery_config,
Default::default(),
).map(|full| full.with_client(Client::Westend))
} else {
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
......@@ -931,6 +939,7 @@ pub fn build_full(
is_collator,
grandpa_pause,
authority_discovery_config,
Default::default(),
).map(|full| full.with_client(Client::Polkadot))
}
}
......@@ -292,6 +292,7 @@ pub async fn signing_key(validators: &[ValidatorId], keystore: SyncCryptoStorePt
///
/// It can be created if the local node is a validator in the context of a particular
/// relay chain block.
#[derive(Debug)]
pub struct Validator {
signing_context: SigningContext,
key: ValidatorId,
......
......@@ -11,6 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.3.4", default-features =
polkadot-test-runtime = { path = "../../../runtime/test-runtime" }
polkadot-test-service = { path = "../service" }
polkadot-primitives = { path = "../../../primitives" }
polkadot-node-subsystem = { path = "../../subsystem" }
# Substrate dependencies
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "master" }
......
......@@ -69,7 +69,14 @@ impl InitPolkadotBlockBuilder for Client {
inherent_data
.put_data(sp_timestamp::INHERENT_IDENTIFIER, &timestamp)
.expect("Put timestamp failed");
.expect("Put timestamp inherent data");
inherent_data
.put_data(
polkadot_primitives::v1::INCLUSION_INHERENT_IDENTIFIER,
&polkadot_node_subsystem::messages::ProvisionerInherentData::default(),
)
.expect("Put inclusion inherent data");
let inherents = block_builder.create_inherents(inherent_data).expect("Creates inherents");
......
......@@ -15,13 +15,17 @@ tempfile = "3.1.0"
# Polkadot dependencies
polkadot-overseer = { path = "../../overseer" }
polkadot-primitives = { path = "../../../primitives" }
polkadot-parachain = { path = "../../../parachain" }
polkadot-rpc = { path = "../../../rpc" }
polkadot-runtime-common = { path = "../../../runtime/common" }
polkadot-service = { path = "../../service" }
polkadot-node-subsystem = { path = "../../subsystem" }
polkadot-node-primitives = { path = "../../primitives" }
polkadot-test-runtime = { path = "../../../runtime/test-runtime" }
polkadot-runtime-parachains = { path = "../../../runtime/parachains" }
# Substrate dependencies
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master" }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master" }
......@@ -39,7 +43,6 @@ sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-informant = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
service = { package = "sc-service", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
......
......@@ -16,10 +16,11 @@
//! Chain specifications for the test runtime.
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use babe_primitives::AuthorityId as BabeId;
use grandpa::AuthorityId as GrandpaId;
use pallet_staking::Forcing;
use polkadot_primitives::v0::{ValidatorId, AccountId};
use polkadot_primitives::v1::{ValidatorId, AccountId};
use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions};
use polkadot_test_runtime::constants::currency::DOTS;
use sc_chain_spec::{ChainSpec, ChainType};
......@@ -53,7 +54,6 @@ pub fn polkadot_local_testnet_genesis() -> polkadot_test_runtime::GenesisConfig
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
get_authority_keys_from_seed("Charlie"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
......@@ -63,13 +63,14 @@ pub fn polkadot_local_testnet_genesis() -> polkadot_test_runtime::GenesisConfig
/// Helper function to generate stash, controller and session key from seed
fn get_authority_keys_from_seed(
seed: &str,
) -> (AccountId, AccountId, BabeId, GrandpaId, ValidatorId) {
) -> (AccountId, AccountId, BabeId, GrandpaId, ValidatorId, AuthorityDiscoveryId) {
(
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<BabeId>(seed),
get_from_seed::<GrandpaId>(seed),
get_from_seed::<ValidatorId>(seed),
get_from_seed::<AuthorityDiscoveryId>(seed),
)
}
......@@ -92,46 +93,47 @@ fn testnet_accounts() -> Vec<AccountId> {
/// Helper function to create polkadot GenesisConfig for testing
fn polkadot_testnet_genesis(
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ValidatorId)>,
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ValidatorId, AuthorityDiscoveryId)>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> polkadot_test_runtime::GenesisConfig {
use polkadot_test_runtime as polkadot;
use polkadot_test_runtime as runtime;
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
const ENDOWMENT: u128 = 1_000_000 * DOTS;
const STASH: u128 = 100 * DOTS;
polkadot::GenesisConfig {
frame_system: Some(polkadot::SystemConfig {
code: polkadot::WASM_BINARY.expect("Wasm binary must be built for testing").to_vec(),
runtime::GenesisConfig {
frame_system: Some(runtime::SystemConfig {
code: runtime::WASM_BINARY.expect("Wasm binary must be built for testing").to_vec(),
..Default::default()
}),
pallet_indices: Some(polkadot::IndicesConfig { indices: vec![] }),
pallet_balances: Some(polkadot::BalancesConfig {
pallet_indices: Some(runtime::IndicesConfig { indices: vec![] }),
pallet_balances: Some(runtime::BalancesConfig {
balances: endowed_accounts
.iter()
.map(|k| (k.clone(), ENDOWMENT))
.collect(),
}),
pallet_session: Some(polkadot::SessionConfig {
pallet_session: Some(runtime::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
polkadot_test_runtime::SessionKeys {
runtime::SessionKeys {
babe: x.2.clone(),
grandpa: x.3.clone(),
parachain_validator: x.4.clone(),
authority_discovery: x.5.clone(),
},
)
})
.collect::<Vec<_>>(),
}),
pallet_staking: Some(polkadot::StakingConfig {
pallet_staking: Some(runtime::StakingConfig {
minimum_validator_count: 1,
validator_count: 2,
stakers: initial_authorities
......@@ -141,7 +143,7 @@ fn polkadot_testnet_genesis(
x.0.clone(),
x.1.clone(),
STASH,
polkadot::StakerStatus::Validator,
runtime::StakerStatus::Validator,
)
})
.collect(),
......@@ -152,13 +154,24 @@ fn polkadot_testnet_genesis(
}),
pallet_babe: Some(Default::default()),
pallet_grandpa: Some(Default::default()),
pallet_authority_discovery: Some(polkadot::AuthorityDiscoveryConfig { keys: vec![] }),
claims: Some(polkadot::ClaimsConfig {
pallet_authority_discovery: Some(runtime::AuthorityDiscoveryConfig { keys: vec![] }),
claims: Some(runtime::ClaimsConfig {
claims: vec![],
vesting: vec![],
}),
pallet_vesting: Some(polkadot::VestingConfig { vesting: vec![] }),
pallet_sudo: Some(polkadot::SudoConfig { key: root_key }),
pallet_vesting: Some(runtime::VestingConfig { vesting: vec![] }),
pallet_sudo: Some(runtime::SudoConfig { key: root_key }),
parachains_configuration: Some(runtime::ParachainsConfigurationConfig {
config: polkadot_runtime_parachains::configuration::HostConfiguration {
validation_upgrade_frequency: 10u32,
validation_upgrade_delay: 5,
acceptance_period: 1200,
max_code_size: 5 * 1024 * 1024,
max_head_data_size: 32 * 1024,
group_rotation_frequency: 10,
..Default::default()
},
}),
}
}
......
......@@ -23,17 +23,22 @@ pub mod chain_spec;
pub use chain_spec::*;
use futures::future::Future;
use polkadot_overseer::OverseerHandler;
use polkadot_primitives::v1::{Id as ParaId, HeadData, ValidationCode, Balance};
use polkadot_primitives::v1::{
Id as ParaId, HeadData, ValidationCode, Balance, CollatorPair, CollatorId, ValidationData, Hash,
};
use polkadot_runtime_common::BlockHashCount;
use polkadot_service::{
new_full, NewFull, FullClient, ClientHandle, ExecuteWithClient, IsCollator,
NewFull, FullClient, ClientHandle, ExecuteWithClient, IsCollator,
};
use polkadot_node_subsystem::messages::{CollatorProtocolMessage, CollationGenerationMessage};
use polkadot_test_runtime::{
Runtime, SignedExtra, SignedPayload, VERSION, ParasSudoWrapperCall, SudoCall, UncheckedExtrinsic,
};
use polkadot_test_runtime::{Runtime, SignedExtra, SignedPayload, VERSION, ParasSudoWrapperCall, UncheckedExtrinsic};
use polkadot_node_primitives::{Collation, CollationGenerationConfig};
use polkadot_runtime_parachains::paras::ParaGenesisArgs;
use sc_chain_spec::ChainSpec;
use sc_client_api::execution_extensions::ExecutionStrategies;
use sc_executor::native_executor_instance;
use sc_informant::OutputFormat;
use sc_network::{
config::{NetworkConfiguration, TransportConfig},
multiaddr,
......@@ -49,7 +54,7 @@ use sp_blockchain::HeaderBackend;
use sp_keyring::Sr25519Keyring;
use sp_runtime::{codec::Encode, generic, traits::IdentifyAccount, MultiSigner};
use sp_state_machine::BasicExternalities;
use std::{sync::Arc, time::Duration};
use std::{sync::Arc, time::Duration, pin::Pin};
use substrate_test_client::{BlockchainEventsExt, RpcHandlersExt, RpcTransactionOutput, RpcTransactionError};
native_executor_instance!(
......@@ -64,23 +69,25 @@ pub type Client = FullClient<polkadot_test_runtime::RuntimeApi, PolkadotTestExec
pub use polkadot_service::FullBackend;
/// Create a new Polkadot test service for a full node.
/// Create a new full node.
#[sc_cli::prefix_logs_with(config.network.node_name.as_str())]
pub fn polkadot_test_new_full(
pub fn new_full(
config: Configuration,
is_collator: IsCollator,
) -> Result<
NewFull<Arc<Client>>,
ServiceError,
> {
new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor>(
polkadot_service::new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor>(
config,
IsCollator::No,
is_collator,
None,
Some(sc_authority_discovery::WorkerConfig {
query_interval: Duration::from_secs(1),
query_start_delay: Duration::from_secs(0),
..Default::default()
}),
polkadot_parachain::wasm_executor::ExecutionMode::InProcess,
).map_err(Into::into)
}
......@@ -105,11 +112,14 @@ pub fn node_config(
task_executor: TaskExecutor,
key: Sr25519Keyring,
boot_nodes: Vec<MultiaddrWithPeerId>,
is_validator: bool,
) -> Configuration {
let base_path = BasePath::new_temp_dir().expect("could not create temporary directory");
let root = base_path.path();
let role = Role::Authority {
sentry_nodes: Vec::new(),
let role = if is_validator {
Role::Authority { sentry_nodes: Vec::new() }
} else {
Role::Full
};
let key_seed = key.to_seed();
let mut spec = polkadot_local_testnet_config();
......@@ -127,17 +137,19 @@ pub fn node_config(
Default::default(),
None,
);
let informant_output_format = OutputFormat {
enable_color: false,
};
network_config.boot_nodes = boot_nodes;
network_config.allow_non_globals_in_dht = true;
let addr: multiaddr::Multiaddr = multiaddr::Protocol::Memory(rand::random()).into();
network_config
.listen_addresses
.push(multiaddr::Protocol::Memory(rand::random()).into());
.push(addr.clone());
network_config
.public_addresses
.push(addr);