mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 10:15:42 +00:00
break out subsystem-util and subsystem-test-helpers into individual crates (#1553)
* break out subsystem-util and subsystem-test-helpers into individual crates * cause all packages to check successfully
This commit is contained in:
committed by
GitHub
parent
21cec309a4
commit
9fda6cb416
Generated
+57
-1
@@ -4342,6 +4342,7 @@ dependencies = [
|
|||||||
"polkadot-network-bridge",
|
"polkadot-network-bridge",
|
||||||
"polkadot-node-primitives",
|
"polkadot-node-primitives",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sc-network",
|
"sc-network",
|
||||||
"smol 0.2.0",
|
"smol 0.2.0",
|
||||||
@@ -4494,6 +4495,7 @@ dependencies = [
|
|||||||
"parking_lot 0.10.2",
|
"parking_lot 0.10.2",
|
||||||
"polkadot-node-primitives",
|
"polkadot-node-primitives",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sc-network",
|
"sc-network",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
@@ -4536,6 +4538,7 @@ dependencies = [
|
|||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"polkadot-erasure-coding",
|
"polkadot-erasure-coding",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
"polkadot-overseer",
|
"polkadot-overseer",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
@@ -4553,6 +4556,8 @@ dependencies = [
|
|||||||
"polkadot-erasure-coding",
|
"polkadot-erasure-coding",
|
||||||
"polkadot-node-primitives",
|
"polkadot-node-primitives",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
|
"polkadot-node-subsystem-util",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"polkadot-statement-table",
|
"polkadot-statement-table",
|
||||||
"sc-client-api",
|
"sc-client-api",
|
||||||
@@ -4572,6 +4577,7 @@ dependencies = [
|
|||||||
"futures 0.3.5",
|
"futures 0.3.5",
|
||||||
"log 0.4.8",
|
"log 0.4.8",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-util",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sc-keystore",
|
"sc-keystore",
|
||||||
"wasm-timer",
|
"wasm-timer",
|
||||||
@@ -4588,6 +4594,7 @@ dependencies = [
|
|||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"polkadot-node-primitives",
|
"polkadot-node-primitives",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
"polkadot-parachain",
|
"polkadot-parachain",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sp-blockchain",
|
"sp-blockchain",
|
||||||
@@ -4602,6 +4609,7 @@ dependencies = [
|
|||||||
"futures 0.3.5",
|
"futures 0.3.5",
|
||||||
"maplit",
|
"maplit",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sp-blockchain",
|
"sp-blockchain",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
@@ -4643,6 +4651,7 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log 0.4.8",
|
"log 0.4.8",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-util",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
"tokio 0.2.21",
|
"tokio 0.2.21",
|
||||||
@@ -4655,6 +4664,7 @@ dependencies = [
|
|||||||
"futures 0.3.5",
|
"futures 0.3.5",
|
||||||
"polkadot-node-primitives",
|
"polkadot-node-primitives",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sp-api",
|
"sp-api",
|
||||||
"sp-blockchain",
|
"sp-blockchain",
|
||||||
@@ -4665,7 +4675,6 @@ dependencies = [
|
|||||||
name = "polkadot-node-primitives"
|
name = "polkadot-node-primitives"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"polkadot-statement-table",
|
"polkadot-statement-table",
|
||||||
@@ -4687,6 +4696,51 @@ dependencies = [
|
|||||||
"parking_lot 0.10.2",
|
"parking_lot 0.10.2",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"polkadot-node-primitives",
|
"polkadot-node-primitives",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
|
"polkadot-primitives",
|
||||||
|
"polkadot-statement-table",
|
||||||
|
"sc-network",
|
||||||
|
"smallvec 1.4.1",
|
||||||
|
"sp-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "polkadot-node-subsystem-test-helpers"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"derive_more 0.99.9",
|
||||||
|
"futures 0.3.5",
|
||||||
|
"futures-timer 3.0.2",
|
||||||
|
"log 0.4.8",
|
||||||
|
"parity-scale-codec",
|
||||||
|
"parking_lot 0.10.2",
|
||||||
|
"pin-project",
|
||||||
|
"polkadot-node-primitives",
|
||||||
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-primitives",
|
||||||
|
"polkadot-statement-table",
|
||||||
|
"sc-network",
|
||||||
|
"smallvec 1.4.1",
|
||||||
|
"sp-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "polkadot-node-subsystem-util"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"assert_matches",
|
||||||
|
"async-trait",
|
||||||
|
"derive_more 0.99.9",
|
||||||
|
"futures 0.3.5",
|
||||||
|
"futures-timer 3.0.2",
|
||||||
|
"log 0.4.8",
|
||||||
|
"parity-scale-codec",
|
||||||
|
"parking_lot 0.10.2",
|
||||||
|
"pin-project",
|
||||||
|
"polkadot-node-primitives",
|
||||||
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"polkadot-statement-table",
|
"polkadot-statement-table",
|
||||||
"sc-keystore",
|
"sc-keystore",
|
||||||
@@ -4746,6 +4800,7 @@ dependencies = [
|
|||||||
"parking_lot 0.10.2",
|
"parking_lot 0.10.2",
|
||||||
"polkadot-node-primitives",
|
"polkadot-node-primitives",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sc-network",
|
"sc-network",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
@@ -5102,6 +5157,7 @@ dependencies = [
|
|||||||
"parking_lot 0.10.2",
|
"parking_lot 0.10.2",
|
||||||
"polkadot-node-primitives",
|
"polkadot-node-primitives",
|
||||||
"polkadot-node-subsystem",
|
"polkadot-node-subsystem",
|
||||||
|
"polkadot-node-subsystem-test-helpers",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
"sp-keyring",
|
"sp-keyring",
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ members = [
|
|||||||
"node/primitives",
|
"node/primitives",
|
||||||
"node/service",
|
"node/service",
|
||||||
"node/subsystem",
|
"node/subsystem",
|
||||||
|
"node/subsystem-test-helpers",
|
||||||
|
"node/subsystem-util",
|
||||||
"node/test-service",
|
"node/test-service",
|
||||||
|
|
||||||
"parachain/test-parachains",
|
"parachain/test-parachains",
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ derive_more = "0.99.9"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
futures = { version = "0.3.5", features = ["thread-pool"] }
|
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem", features = [ "test-helpers" ] }
|
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||||
kvdb-memorydb = "0.7.0"
|
kvdb-memorydb = "0.7.0"
|
||||||
assert_matches = "1.3.0"
|
assert_matches = "1.3.0"
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ mod tests {
|
|||||||
AvailableData, BlockData, HeadData, GlobalValidationData, LocalValidationData, PoV,
|
AvailableData, BlockData, HeadData, GlobalValidationData, LocalValidationData, PoV,
|
||||||
OmittedValidationData,
|
OmittedValidationData,
|
||||||
};
|
};
|
||||||
use polkadot_subsystem::test_helpers;
|
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||||
|
|
||||||
struct TestHarness {
|
struct TestHarness {
|
||||||
virtual_overseer: test_helpers::TestSubsystemContextHandle<AvailabilityStoreMessage>,
|
virtual_overseer: test_helpers::TestSubsystemContextHandle<AvailabilityStoreMessage>,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ keystore = { package = "sc-keystore", git = "https://github.com/paritytech/subst
|
|||||||
polkadot-primitives = { path = "../../../primitives" }
|
polkadot-primitives = { path = "../../../primitives" }
|
||||||
polkadot-node-primitives = { path = "../../primitives" }
|
polkadot-node-primitives = { path = "../../primitives" }
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
|
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
|
||||||
|
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
|
||||||
erasure-coding = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
|
erasure-coding = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
|
||||||
statement-table = { package = "polkadot-statement-table", path = "../../../statement-table" }
|
statement-table = { package = "polkadot-statement-table", path = "../../../statement-table" }
|
||||||
derive_more = "0.99.9"
|
derive_more = "0.99.9"
|
||||||
@@ -24,4 +25,4 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
|||||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
futures = { version = "0.3.5", features = ["thread-pool"] }
|
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||||
assert_matches = "1.3.0"
|
assert_matches = "1.3.0"
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem", features = [ "test-helpers" ] }
|
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||||
|
|||||||
@@ -45,14 +45,14 @@ use polkadot_subsystem::{
|
|||||||
ProvisionerMessage, RuntimeApiMessage, StatementDistributionMessage, ValidationFailed,
|
ProvisionerMessage, RuntimeApiMessage, StatementDistributionMessage, ValidationFailed,
|
||||||
RuntimeApiRequest,
|
RuntimeApiRequest,
|
||||||
},
|
},
|
||||||
util::{
|
};
|
||||||
self,
|
use polkadot_node_subsystem_util::{
|
||||||
request_session_index_for_child,
|
self as util,
|
||||||
request_validator_groups,
|
request_session_index_for_child,
|
||||||
request_validators,
|
request_validator_groups,
|
||||||
request_from_runtime,
|
request_validators,
|
||||||
Validator,
|
request_from_runtime,
|
||||||
},
|
Validator,
|
||||||
delegated_subsystem,
|
delegated_subsystem,
|
||||||
};
|
};
|
||||||
use statement_table::{
|
use statement_table::{
|
||||||
@@ -896,13 +896,13 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct TestHarness {
|
struct TestHarness {
|
||||||
virtual_overseer: polkadot_subsystem::test_helpers::TestSubsystemContextHandle<CandidateBackingMessage>,
|
virtual_overseer: polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle<CandidateBackingMessage>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_harness<T: Future<Output=()>>(keystore: KeyStorePtr, test: impl FnOnce(TestHarness) -> T) {
|
fn test_harness<T: Future<Output=()>>(keystore: KeyStorePtr, test: impl FnOnce(TestHarness) -> T) {
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
|
|
||||||
let (context, virtual_overseer) = polkadot_subsystem::test_helpers::make_subsystem_context(pool.clone());
|
let (context, virtual_overseer) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone());
|
||||||
|
|
||||||
let subsystem = CandidateBackingSubsystem::run(context, keystore, pool.clone());
|
let subsystem = CandidateBackingSubsystem::run(context, keystore, pool.clone());
|
||||||
|
|
||||||
@@ -960,7 +960,7 @@ mod tests {
|
|||||||
|
|
||||||
// Tests that the subsystem performs actions that are requied on startup.
|
// Tests that the subsystem performs actions that are requied on startup.
|
||||||
async fn test_startup(
|
async fn test_startup(
|
||||||
virtual_overseer: &mut polkadot_subsystem::test_helpers::TestSubsystemContextHandle<CandidateBackingMessage>,
|
virtual_overseer: &mut polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle<CandidateBackingMessage>,
|
||||||
test_state: &TestState,
|
test_state: &TestState,
|
||||||
) {
|
) {
|
||||||
// Start work on some new parent.
|
// Start work on some new parent.
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ futures = "0.3.5"
|
|||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
polkadot-primitives = { path = "../../../primitives" }
|
polkadot-primitives = { path = "../../../primitives" }
|
||||||
polkadot-node-subsystem = { path = "../../subsystem" }
|
polkadot-node-subsystem = { path = "../../subsystem" }
|
||||||
|
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
|
||||||
keystore = { package = "sc-keystore", git = "https://github.com/paritytech/substrate", branch = "master" }
|
keystore = { package = "sc-keystore", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
wasm-timer = "0.2.4"
|
wasm-timer = "0.2.4"
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ use polkadot_node_subsystem::{
|
|||||||
BitfieldSigningMessage, CandidateBackingMessage, RuntimeApiMessage,
|
BitfieldSigningMessage, CandidateBackingMessage, RuntimeApiMessage,
|
||||||
},
|
},
|
||||||
errors::RuntimeApiError,
|
errors::RuntimeApiError,
|
||||||
util::{self, JobManager, JobTrait, ToJobTrait, Validator},
|
};
|
||||||
|
use polkadot_node_subsystem_util::{
|
||||||
|
self as util, JobManager, JobTrait, ToJobTrait, Validator
|
||||||
};
|
};
|
||||||
use polkadot_primitives::v1::{AvailabilityBitfield, CoreState, Hash, ValidatorIndex};
|
use polkadot_primitives::v1::{AvailabilityBitfield, CoreState, Hash, ValidatorIndex};
|
||||||
use std::{convert::TryFrom, pin::Pin, time::Duration};
|
use std::{convert::TryFrom, pin::Pin, time::Duration};
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ log = "0.4.8"
|
|||||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
futures = { version = "0.3.5", features = ["thread-pool"] }
|
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||||
assert_matches = "1.3.0"
|
assert_matches = "1.3.0"
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem", features = ["test-helpers"] }
|
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ fn validate_candidate_exhaustive<B: ValidationBackend, S: SpawnNamed + 'static>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use polkadot_subsystem::test_helpers;
|
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||||
use polkadot_primitives::v1::{HeadData, BlockData};
|
use polkadot_primitives::v1::{HeadData, BlockData};
|
||||||
use sp_core::testing::TaskExecutor;
|
use sp_core::testing::TaskExecutor;
|
||||||
use futures::executor;
|
use futures::executor;
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsys
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
futures = { version = "0.3.5", features = ["thread-pool"] }
|
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem", features = ["test-helpers"] }
|
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ mod tests {
|
|||||||
use futures::{future::BoxFuture, channel::oneshot};
|
use futures::{future::BoxFuture, channel::oneshot};
|
||||||
|
|
||||||
use polkadot_primitives::v1::{Hash, BlockNumber, BlockId, Header};
|
use polkadot_primitives::v1::{Hash, BlockNumber, BlockId, Header};
|
||||||
use polkadot_subsystem::test_helpers::{make_subsystem_context, TestSubsystemContextHandle};
|
use polkadot_node_subsystem_test_helpers::{make_subsystem_context, TestSubsystemContextHandle};
|
||||||
use sp_blockchain::Info as BlockInfo;
|
use sp_blockchain::Info as BlockInfo;
|
||||||
use sp_core::testing::TaskExecutor;
|
use sp_core::testing::TaskExecutor;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ futures = "0.3.5"
|
|||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
polkadot-primitives = { path = "../../../primitives" }
|
polkadot-primitives = { path = "../../../primitives" }
|
||||||
polkadot-node-subsystem = { path = "../../subsystem" }
|
polkadot-node-subsystem = { path = "../../subsystem" }
|
||||||
|
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
|
|||||||
@@ -25,16 +25,17 @@ use futures::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use polkadot_node_subsystem::{
|
use polkadot_node_subsystem::{
|
||||||
delegated_subsystem,
|
|
||||||
errors::{ChainApiError, RuntimeApiError},
|
errors::{ChainApiError, RuntimeApiError},
|
||||||
messages::{
|
messages::{
|
||||||
AllMessages, ChainApiMessage, ProvisionableData, ProvisionerInherentData,
|
AllMessages, ChainApiMessage, ProvisionableData, ProvisionerInherentData,
|
||||||
ProvisionerMessage, RuntimeApiMessage,
|
ProvisionerMessage, RuntimeApiMessage,
|
||||||
},
|
},
|
||||||
util::{
|
};
|
||||||
self, request_availability_cores, request_global_validation_data,
|
use polkadot_node_subsystem_util::{
|
||||||
request_local_validation_data, JobTrait, ToJobTrait,
|
self as util,
|
||||||
},
|
delegated_subsystem,
|
||||||
|
request_availability_cores, request_global_validation_data,
|
||||||
|
request_local_validation_data, JobTrait, ToJobTrait,
|
||||||
};
|
};
|
||||||
use polkadot_primitives::v1::{
|
use polkadot_primitives::v1::{
|
||||||
validation_data_hash, BackedCandidate, BlockNumber, CoreState, Hash, OccupiedCoreAssumption,
|
validation_data_hash, BackedCandidate, BlockNumber, CoreState, Hash, OccupiedCoreAssumption,
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsys
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
futures = { version = "0.3.5", features = ["thread-pool"] }
|
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem", features = ["test-helpers"] }
|
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ mod tests {
|
|||||||
Id as ParaId, OccupiedCoreAssumption, LocalValidationData, SessionIndex, ValidationCode,
|
Id as ParaId, OccupiedCoreAssumption, LocalValidationData, SessionIndex, ValidationCode,
|
||||||
CommittedCandidateReceipt, CandidateEvent,
|
CommittedCandidateReceipt, CandidateEvent,
|
||||||
};
|
};
|
||||||
use polkadot_subsystem::test_helpers;
|
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||||
use sp_core::testing::TaskExecutor;
|
use sp_core::testing::TaskExecutor;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ polkadot-network = { path = "../../../network" }
|
|||||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem", features = [ "test-helpers" ] }
|
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||||
bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
|
bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
parking_lot = "0.10.0"
|
parking_lot = "0.10.0"
|
||||||
|
|||||||
@@ -607,7 +607,7 @@ mod test {
|
|||||||
use futures::executor;
|
use futures::executor;
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
use polkadot_primitives::v1::{Signed, ValidatorPair, AvailabilityBitfield};
|
use polkadot_primitives::v1::{Signed, ValidatorPair, AvailabilityBitfield};
|
||||||
use polkadot_subsystem::test_helpers::make_subsystem_context;
|
use polkadot_node_subsystem_test_helpers::make_subsystem_context;
|
||||||
use smol_timeout::TimeoutExt;
|
use smol_timeout::TimeoutExt;
|
||||||
use sp_core::crypto::Pair;
|
use sp_core::crypto::Pair;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|||||||
@@ -19,5 +19,5 @@ polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsys
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_matches = "1.3.0"
|
assert_matches = "1.3.0"
|
||||||
parking_lot = "0.10.0"
|
parking_lot = "0.10.0"
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem", features = [ "test-helpers" ] }
|
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -521,7 +521,7 @@ mod tests {
|
|||||||
use assert_matches::assert_matches;
|
use assert_matches::assert_matches;
|
||||||
|
|
||||||
use polkadot_subsystem::messages::{StatementDistributionMessage, BitfieldDistributionMessage};
|
use polkadot_subsystem::messages::{StatementDistributionMessage, BitfieldDistributionMessage};
|
||||||
use polkadot_subsystem::test_helpers::{SingleItemSink, SingleItemStream};
|
use polkadot_node_subsystem_test_helpers::{SingleItemSink, SingleItemStream};
|
||||||
|
|
||||||
// The subsystem's view of the network - only supports a single call to `event_stream`.
|
// The subsystem's view of the network - only supports a single call to `event_stream`.
|
||||||
struct TestNetwork {
|
struct TestNetwork {
|
||||||
@@ -540,7 +540,7 @@ mod tests {
|
|||||||
TestNetwork,
|
TestNetwork,
|
||||||
TestNetworkHandle,
|
TestNetworkHandle,
|
||||||
) {
|
) {
|
||||||
let (net_tx, net_rx) = polkadot_subsystem::test_helpers::single_item_sink();
|
let (net_tx, net_rx) = polkadot_node_subsystem_test_helpers::single_item_sink();
|
||||||
let (action_tx, action_rx) = mpsc::unbounded();
|
let (action_tx, action_rx) = mpsc::unbounded();
|
||||||
|
|
||||||
(
|
(
|
||||||
@@ -621,13 +621,13 @@ mod tests {
|
|||||||
|
|
||||||
struct TestHarness {
|
struct TestHarness {
|
||||||
network_handle: TestNetworkHandle,
|
network_handle: TestNetworkHandle,
|
||||||
virtual_overseer: polkadot_subsystem::test_helpers::TestSubsystemContextHandle<NetworkBridgeMessage>,
|
virtual_overseer: polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle<NetworkBridgeMessage>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_harness<T: Future<Output=()>>(test: impl FnOnce(TestHarness) -> T) {
|
fn test_harness<T: Future<Output=()>>(test: impl FnOnce(TestHarness) -> T) {
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (network, network_handle) = new_test_network();
|
let (network, network_handle) = new_test_network();
|
||||||
let (context, virtual_overseer) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (context, virtual_overseer) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
let network_bridge = run_network(
|
let network_bridge = run_network(
|
||||||
network,
|
network,
|
||||||
|
|||||||
@@ -20,4 +20,4 @@ polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsys
|
|||||||
parking_lot = "0.10.0"
|
parking_lot = "0.10.0"
|
||||||
assert_matches = "1.3.0"
|
assert_matches = "1.3.0"
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem", features = [ "test-helpers" ] }
|
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||||
|
|||||||
@@ -639,7 +639,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
let mut descriptor = CandidateDescriptor::default();
|
let mut descriptor = CandidateDescriptor::default();
|
||||||
descriptor.pov_hash = pov_hash;
|
descriptor.pov_hash = pov_hash;
|
||||||
|
|
||||||
@@ -719,7 +719,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
let mut descriptor = CandidateDescriptor::default();
|
let mut descriptor = CandidateDescriptor::default();
|
||||||
descriptor.pov_hash = pov_hash;
|
descriptor.pov_hash = pov_hash;
|
||||||
|
|
||||||
@@ -797,7 +797,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
handle_network_update(
|
handle_network_update(
|
||||||
@@ -869,7 +869,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
// Peer A answers our request before peer B.
|
// Peer A answers our request before peer B.
|
||||||
@@ -957,7 +957,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
// Peer A answers our request: right relay parent, awaited hash, wrong PoV.
|
// Peer A answers our request: right relay parent, awaited hash, wrong PoV.
|
||||||
@@ -1020,7 +1020,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
// Peer A answers our request: right relay parent, awaited hash, wrong PoV.
|
// Peer A answers our request: right relay parent, awaited hash, wrong PoV.
|
||||||
@@ -1081,7 +1081,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
// Peer A answers our request: right relay parent, awaited hash, wrong PoV.
|
// Peer A answers our request: right relay parent, awaited hash, wrong PoV.
|
||||||
@@ -1139,7 +1139,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
let max_plausibly_awaited = n_validators * 2;
|
let max_plausibly_awaited = n_validators * 2;
|
||||||
@@ -1224,7 +1224,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
let pov_hash = make_pov(vec![1, 2, 3]).hash();
|
let pov_hash = make_pov(vec![1, 2, 3]).hash();
|
||||||
@@ -1286,7 +1286,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
let pov_hash = make_pov(vec![1, 2, 3]).hash();
|
let pov_hash = make_pov(vec![1, 2, 3]).hash();
|
||||||
@@ -1363,7 +1363,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
handle_network_update(
|
handle_network_update(
|
||||||
@@ -1446,7 +1446,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
handle_network_update(
|
handle_network_update(
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ indexmap = "1.4.0"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
parking_lot = "0.10.0"
|
parking_lot = "0.10.0"
|
||||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem", features = ["test-helpers"] }
|
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||||
assert_matches = "1.3.0"
|
assert_matches = "1.3.0"
|
||||||
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -1235,7 +1235,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
let peer = PeerId::random();
|
let peer = PeerId::random();
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
@@ -1327,7 +1327,7 @@ mod tests {
|
|||||||
].into_iter().collect();
|
].into_iter().collect();
|
||||||
|
|
||||||
let pool = sp_core::testing::TaskExecutor::new();
|
let pool = sp_core::testing::TaskExecutor::new();
|
||||||
let (mut ctx, mut handle) = polkadot_subsystem::test_helpers::make_subsystem_context(pool);
|
let (mut ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
|
||||||
|
|
||||||
executor::block_on(async move {
|
executor::block_on(async move {
|
||||||
let statement = {
|
let statement = {
|
||||||
|
|||||||
@@ -10,5 +10,4 @@ polkadot-primitives = { path = "../../primitives" }
|
|||||||
polkadot-statement-table = { path = "../../statement-table" }
|
polkadot-statement-table = { path = "../../statement-table" }
|
||||||
parity-scale-codec = { version = "1.3.4", default-features = false, features = ["derive"] }
|
parity-scale-codec = { version = "1.3.4", default-features = false, features = ["derive"] }
|
||||||
runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||||
async-trait = "0.1"
|
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
[package]
|
||||||
|
name = "polkadot-node-subsystem-test-helpers"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
description = "Subsystem traits and message definitions"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
async-trait = "0.1"
|
||||||
|
derive_more = "0.99.9"
|
||||||
|
futures = "0.3.5"
|
||||||
|
futures-timer = "3.0.2"
|
||||||
|
log = "0.4.8"
|
||||||
|
parity-scale-codec = "1.3.4"
|
||||||
|
parking_lot = "0.10.0"
|
||||||
|
pin-project = "0.4.22"
|
||||||
|
polkadot-node-primitives = { path = "../primitives" }
|
||||||
|
polkadot-node-subsystem = { path = "../subsystem" }
|
||||||
|
polkadot-primitives = { path = "../../primitives" }
|
||||||
|
polkadot-statement-table = { path = "../../statement-table" }
|
||||||
|
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
smallvec = "1.4.1"
|
||||||
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
+2
-2
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
//! Utilities for testing subsystems.
|
//! Utilities for testing subsystems.
|
||||||
|
|
||||||
use crate::{SubsystemContext, FromOverseer, SubsystemResult, SubsystemError};
|
use polkadot_node_subsystem::{SubsystemContext, FromOverseer, SubsystemResult, SubsystemError};
|
||||||
use crate::messages::AllMessages;
|
use polkadot_node_subsystem::messages::AllMessages;
|
||||||
|
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use futures::channel::mpsc;
|
use futures::channel::mpsc;
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
[package]
|
||||||
|
name = "polkadot-node-subsystem-util"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
description = "Subsystem traits and message definitions"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
async-trait = "0.1"
|
||||||
|
derive_more = "0.99.9"
|
||||||
|
futures = "0.3.5"
|
||||||
|
futures-timer = "3.0.2"
|
||||||
|
keystore = { package = "sc-keystore", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
log = "0.4.8"
|
||||||
|
parity-scale-codec = "1.3.4"
|
||||||
|
parking_lot = { version = "0.10.0", optional = true }
|
||||||
|
pin-project = "0.4.22"
|
||||||
|
polkadot-node-primitives = { path = "../primitives" }
|
||||||
|
polkadot-node-subsystem = { path = "../subsystem" }
|
||||||
|
polkadot-primitives = { path = "../../primitives" }
|
||||||
|
polkadot-statement-table = { path = "../../statement-table" }
|
||||||
|
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
smallvec = "1.4.1"
|
||||||
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
streamunordered = "0.5.1"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
assert_matches = "1.3.0"
|
||||||
|
async-trait = "0.1"
|
||||||
|
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||||
|
parking_lot = "0.10.0"
|
||||||
|
polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" }
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
//! or determining what their validator ID is. These common interests are factored into
|
//! or determining what their validator ID is. These common interests are factored into
|
||||||
//! this module.
|
//! this module.
|
||||||
|
|
||||||
use crate::{
|
use polkadot_node_subsystem::{
|
||||||
errors::{ChainApiError, RuntimeApiError},
|
errors::{ChainApiError, RuntimeApiError},
|
||||||
messages::{AllMessages, RuntimeApiMessage, RuntimeApiRequest, RuntimeApiSender},
|
messages::{AllMessages, RuntimeApiMessage, RuntimeApiRequest, RuntimeApiSender},
|
||||||
FromOverseer, SpawnedSubsystem, Subsystem, SubsystemContext, SubsystemError, SubsystemResult,
|
FromOverseer, SpawnedSubsystem, Subsystem, SubsystemContext, SubsystemError, SubsystemResult,
|
||||||
@@ -43,7 +43,7 @@ use polkadot_primitives::v1::{
|
|||||||
SessionIndex, Signed, SigningContext, ValidationCode, ValidatorId, ValidatorIndex,
|
SessionIndex, Signed, SigningContext, ValidationCode, ValidatorId, ValidatorIndex,
|
||||||
ValidatorPair,
|
ValidatorPair,
|
||||||
};
|
};
|
||||||
use sp_core::Pair;
|
use sp_core::{Pair, traits::SpawnNamed};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
@@ -53,10 +53,15 @@ use std::{
|
|||||||
};
|
};
|
||||||
use streamunordered::{StreamUnordered, StreamYield};
|
use streamunordered::{StreamUnordered, StreamYield};
|
||||||
|
|
||||||
/// This reexport is required so that external crates can use the `delegated_subsystem` macro properly.
|
/// These reexports are required so that external crates can use the `delegated_subsystem` macro properly.
|
||||||
///
|
pub mod reexports {
|
||||||
/// Otherwise, downstream crates might have to modify their `Cargo.toml` to ensure `sp-core` appeared there.
|
pub use sp_core::traits::SpawnNamed;
|
||||||
pub use sp_core::traits::SpawnNamed;
|
pub use polkadot_node_subsystem::{
|
||||||
|
SpawnedSubsystem,
|
||||||
|
Subsystem,
|
||||||
|
SubsystemContext,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Duration a job will wait after sending a stop signal before hard-aborting.
|
/// Duration a job will wait after sending a stop signal before hard-aborting.
|
||||||
pub const JOB_GRACEFUL_STOP_DURATION: Duration = Duration::from_secs(1);
|
pub const JOB_GRACEFUL_STOP_DURATION: Duration = Duration::from_secs(1);
|
||||||
@@ -655,9 +660,9 @@ where
|
|||||||
run_args: &Job::RunArgs,
|
run_args: &Job::RunArgs,
|
||||||
err_tx: &mut Option<mpsc::Sender<(Option<Hash>, JobsError<Job::Error>)>>,
|
err_tx: &mut Option<mpsc::Sender<(Option<Hash>, JobsError<Job::Error>)>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
use crate::ActiveLeavesUpdate;
|
use polkadot_node_subsystem::ActiveLeavesUpdate;
|
||||||
use crate::FromOverseer::{Communication, Signal};
|
use polkadot_node_subsystem::FromOverseer::{Communication, Signal};
|
||||||
use crate::OverseerSignal::{ActiveLeaves, BlockFinalized, Conclude};
|
use polkadot_node_subsystem::OverseerSignal::{ActiveLeaves, BlockFinalized, Conclude};
|
||||||
|
|
||||||
match incoming {
|
match incoming {
|
||||||
Ok(Signal(ActiveLeaves(ActiveLeavesUpdate {
|
Ok(Signal(ActiveLeaves(ActiveLeavesUpdate {
|
||||||
@@ -783,7 +788,7 @@ where
|
|||||||
/// It is possible to create a type which implements `Subsystem` by simply doing:
|
/// It is possible to create a type which implements `Subsystem` by simply doing:
|
||||||
///
|
///
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// pub type ExampleSubsystem<Spawner, Context> = util::JobManager<Spawner, Context, ExampleJob>;
|
/// pub type ExampleSubsystem<Spawner, Context> = JobManager<Spawner, Context, ExampleJob>;
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// However, doing this requires that job itself and all types which comprise it (i.e. `ToJob`, `FromJob`, `Error`, `RunArgs`)
|
/// However, doing this requires that job itself and all types which comprise it (i.e. `ToJob`, `FromJob`, `Error`, `RunArgs`)
|
||||||
@@ -791,7 +796,7 @@ where
|
|||||||
/// can reduce the total number of public types exposed, i.e.
|
/// can reduce the total number of public types exposed, i.e.
|
||||||
///
|
///
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// type Manager<Spawner, Context> = util::JobManager<Spawner, Context, ExampleJob>;
|
/// type Manager<Spawner, Context> = JobManager<Spawner, Context, ExampleJob>;
|
||||||
/// pub struct ExampleSubsystem {
|
/// pub struct ExampleSubsystem {
|
||||||
/// manager: Manager<Spawner, Context>,
|
/// manager: Manager<Spawner, Context>,
|
||||||
/// }
|
/// }
|
||||||
@@ -820,7 +825,7 @@ macro_rules! delegated_subsystem {
|
|||||||
($job:ident($run_args:ty) <- $to_job:ty as $subsystem:ident; $subsystem_name:expr) => {
|
($job:ident($run_args:ty) <- $to_job:ty as $subsystem:ident; $subsystem_name:expr) => {
|
||||||
#[doc = "Manager type for the "]
|
#[doc = "Manager type for the "]
|
||||||
#[doc = $subsystem_name]
|
#[doc = $subsystem_name]
|
||||||
type Manager<Spawner, Context> = $crate::util::JobManager<Spawner, Context, $job>;
|
type Manager<Spawner, Context> = $crate::JobManager<Spawner, Context, $job>;
|
||||||
|
|
||||||
#[doc = "An implementation of the "]
|
#[doc = "An implementation of the "]
|
||||||
#[doc = $subsystem_name]
|
#[doc = $subsystem_name]
|
||||||
@@ -830,15 +835,15 @@ macro_rules! delegated_subsystem {
|
|||||||
|
|
||||||
impl<Spawner, Context> $subsystem<Spawner, Context>
|
impl<Spawner, Context> $subsystem<Spawner, Context>
|
||||||
where
|
where
|
||||||
Spawner: Clone + $crate::util::SpawnNamed + Send + Unpin,
|
Spawner: Clone + $crate::reexports::SpawnNamed + Send + Unpin,
|
||||||
Context: $crate::SubsystemContext,
|
Context: $crate::reexports::SubsystemContext,
|
||||||
<Context as $crate::SubsystemContext>::Message: Into<$to_job>,
|
<Context as $crate::reexports::SubsystemContext>::Message: Into<$to_job>,
|
||||||
{
|
{
|
||||||
#[doc = "Creates a new "]
|
#[doc = "Creates a new "]
|
||||||
#[doc = $subsystem_name]
|
#[doc = $subsystem_name]
|
||||||
pub fn new(spawner: Spawner, run_args: $run_args) -> Self {
|
pub fn new(spawner: Spawner, run_args: $run_args) -> Self {
|
||||||
$subsystem {
|
$subsystem {
|
||||||
manager: $crate::util::JobManager::new(spawner, run_args)
|
manager: $crate::JobManager::new(spawner, run_args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -848,13 +853,13 @@ macro_rules! delegated_subsystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Spawner, Context> $crate::Subsystem<Context> for $subsystem<Spawner, Context>
|
impl<Spawner, Context> $crate::reexports::Subsystem<Context> for $subsystem<Spawner, Context>
|
||||||
where
|
where
|
||||||
Spawner: $crate::util::SpawnNamed + Send + Clone + Unpin + 'static,
|
Spawner: $crate::reexports::SpawnNamed + Send + Clone + Unpin + 'static,
|
||||||
Context: $crate::SubsystemContext,
|
Context: $crate::reexports::SubsystemContext,
|
||||||
<Context as $crate::SubsystemContext>::Message: Into<$to_job>,
|
<Context as $crate::reexports::SubsystemContext>::Message: Into<$to_job>,
|
||||||
{
|
{
|
||||||
fn start(self, ctx: Context) -> $crate::SpawnedSubsystem {
|
fn start(self, ctx: Context) -> $crate::reexports::SpawnedSubsystem {
|
||||||
self.manager.start(ctx)
|
self.manager.start(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -863,10 +868,9 @@ macro_rules! delegated_subsystem {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use super::{Error as UtilError, JobManager, JobTrait, JobsError, ToJobTrait};
|
||||||
|
use polkadot_node_subsystem::{
|
||||||
messages::{AllMessages, CandidateSelectionMessage},
|
messages::{AllMessages, CandidateSelectionMessage},
|
||||||
test_helpers::{self, make_subsystem_context},
|
|
||||||
util::{self, JobManager, JobTrait, JobsError, ToJobTrait},
|
|
||||||
ActiveLeavesUpdate, FromOverseer, OverseerSignal, SpawnedSubsystem, Subsystem,
|
ActiveLeavesUpdate, FromOverseer, OverseerSignal, SpawnedSubsystem, Subsystem,
|
||||||
};
|
};
|
||||||
use assert_matches::assert_matches;
|
use assert_matches::assert_matches;
|
||||||
@@ -878,6 +882,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
use futures_timer::Delay;
|
use futures_timer::Delay;
|
||||||
use polkadot_primitives::v1::Hash;
|
use polkadot_primitives::v1::Hash;
|
||||||
|
use polkadot_node_subsystem_test_helpers::{self as test_helpers, make_subsystem_context};
|
||||||
use std::{collections::HashMap, convert::TryFrom, pin::Pin, time::Duration};
|
use std::{collections::HashMap, convert::TryFrom, pin::Pin, time::Duration};
|
||||||
|
|
||||||
// basic usage: in a nutshell, when you want to define a subsystem, just focus on what its jobs do;
|
// basic usage: in a nutshell, when you want to define a subsystem, just focus on what its jobs do;
|
||||||
@@ -941,13 +946,13 @@ mod tests {
|
|||||||
// we include it in the RunArgs
|
// we include it in the RunArgs
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
enum FromJob {
|
enum FromJob {
|
||||||
Test(String),
|
Test,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FromJob> for AllMessages {
|
impl From<FromJob> for AllMessages {
|
||||||
fn from(from_job: FromJob) -> AllMessages {
|
fn from(from_job: FromJob) -> AllMessages {
|
||||||
match from_job {
|
match from_job {
|
||||||
FromJob::Test(s) => AllMessages::Test(s),
|
FromJob::Test => AllMessages::CandidateSelection(CandidateSelectionMessage::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1054,10 +1059,9 @@ mod tests {
|
|||||||
fn starting_and_stopping_job_works() {
|
fn starting_and_stopping_job_works() {
|
||||||
let relay_parent: Hash = [0; 32].into();
|
let relay_parent: Hash = [0; 32].into();
|
||||||
let mut run_args = HashMap::new();
|
let mut run_args = HashMap::new();
|
||||||
let test_message = format!("greetings from {}", relay_parent);
|
|
||||||
run_args.insert(
|
run_args.insert(
|
||||||
relay_parent.clone(),
|
relay_parent.clone(),
|
||||||
vec![FromJob::Test(test_message.clone())],
|
vec![FromJob::Test],
|
||||||
);
|
);
|
||||||
|
|
||||||
test_harness(run_args, |mut overseer_handle, err_rx| async move {
|
test_harness(run_args, |mut overseer_handle, err_rx| async move {
|
||||||
@@ -1068,7 +1072,7 @@ mod tests {
|
|||||||
.await;
|
.await;
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
overseer_handle.recv().await,
|
overseer_handle.recv().await,
|
||||||
AllMessages::Test(msg) if msg == test_message
|
AllMessages::CandidateSelection(_)
|
||||||
);
|
);
|
||||||
overseer_handle
|
overseer_handle
|
||||||
.send(FromOverseer::Signal(OverseerSignal::ActiveLeaves(
|
.send(FromOverseer::Signal(OverseerSignal::ActiveLeaves(
|
||||||
@@ -1098,7 +1102,7 @@ mod tests {
|
|||||||
assert_eq!(errs[0].0, Some(relay_parent));
|
assert_eq!(errs[0].0, Some(relay_parent));
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
errs[0].1,
|
errs[0].1,
|
||||||
JobsError::Utility(util::Error::JobNotFound(match_relay_parent)) if relay_parent == match_relay_parent
|
JobsError::Utility(UtilError::JobNotFound(match_relay_parent)) if relay_parent == match_relay_parent
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,6 @@ async-trait = "0.1"
|
|||||||
derive_more = "0.99.9"
|
derive_more = "0.99.9"
|
||||||
futures = "0.3.5"
|
futures = "0.3.5"
|
||||||
futures-timer = "3.0.2"
|
futures-timer = "3.0.2"
|
||||||
keystore = { package = "sc-keystore", git = "https://github.com/paritytech/substrate", branch = "master" }
|
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
parity-scale-codec = "1.3.4"
|
parity-scale-codec = "1.3.4"
|
||||||
parking_lot = { version = "0.10.0", optional = true }
|
parking_lot = { version = "0.10.0", optional = true }
|
||||||
@@ -21,13 +20,10 @@ polkadot-statement-table = { path = "../../statement-table" }
|
|||||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
smallvec = "1.4.1"
|
smallvec = "1.4.1"
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
streamunordered = "0.5.1"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_matches = "1.3.0"
|
assert_matches = "1.3.0"
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
futures = { version = "0.3.5", features = ["thread-pool"] }
|
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||||
parking_lot = "0.10.0"
|
parking_lot = "0.10.0"
|
||||||
|
polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" }
|
||||||
[features]
|
|
||||||
test-helpers = [ "parking_lot" ]
|
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ use crate::messages::AllMessages;
|
|||||||
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod messages;
|
pub mod messages;
|
||||||
pub mod util;
|
|
||||||
#[cfg(any(test, feature = "test-helpers"))]
|
|
||||||
pub mod test_helpers;
|
|
||||||
|
|
||||||
/// How many slots are stack-reserved for active leaves updates
|
/// How many slots are stack-reserved for active leaves updates
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ impl CandidateSelectionMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for CandidateSelectionMessage {
|
||||||
|
fn default() -> Self {
|
||||||
|
CandidateSelectionMessage::Invalid(Default::default(), Default::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Messages received by the Candidate Backing subsystem.
|
/// Messages received by the Candidate Backing subsystem.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CandidateBackingMessage {
|
pub enum CandidateBackingMessage {
|
||||||
@@ -509,10 +515,4 @@ pub enum AllMessages {
|
|||||||
NetworkBridge(NetworkBridgeMessage),
|
NetworkBridge(NetworkBridgeMessage),
|
||||||
/// Message for the Chain API subsystem
|
/// Message for the Chain API subsystem
|
||||||
ChainApi(ChainApiMessage),
|
ChainApi(ChainApiMessage),
|
||||||
/// Test message
|
|
||||||
///
|
|
||||||
/// This variant is only valid while testing, but makes the process of testing the
|
|
||||||
/// subsystem job manager much simpler.
|
|
||||||
#[cfg(test)]
|
|
||||||
Test(String),
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user