mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 12:17:58 +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-node-primitives",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-test-helpers",
|
||||
"polkadot-primitives",
|
||||
"sc-network",
|
||||
"smol 0.2.0",
|
||||
@@ -4494,6 +4495,7 @@ dependencies = [
|
||||
"parking_lot 0.10.2",
|
||||
"polkadot-node-primitives",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-test-helpers",
|
||||
"polkadot-primitives",
|
||||
"sc-network",
|
||||
"sp-core",
|
||||
@@ -4536,6 +4538,7 @@ dependencies = [
|
||||
"parity-scale-codec",
|
||||
"polkadot-erasure-coding",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-test-helpers",
|
||||
"polkadot-overseer",
|
||||
"polkadot-primitives",
|
||||
"sp-core",
|
||||
@@ -4553,6 +4556,8 @@ dependencies = [
|
||||
"polkadot-erasure-coding",
|
||||
"polkadot-node-primitives",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-test-helpers",
|
||||
"polkadot-node-subsystem-util",
|
||||
"polkadot-primitives",
|
||||
"polkadot-statement-table",
|
||||
"sc-client-api",
|
||||
@@ -4572,6 +4577,7 @@ dependencies = [
|
||||
"futures 0.3.5",
|
||||
"log 0.4.8",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-util",
|
||||
"polkadot-primitives",
|
||||
"sc-keystore",
|
||||
"wasm-timer",
|
||||
@@ -4588,6 +4594,7 @@ dependencies = [
|
||||
"parity-scale-codec",
|
||||
"polkadot-node-primitives",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-test-helpers",
|
||||
"polkadot-parachain",
|
||||
"polkadot-primitives",
|
||||
"sp-blockchain",
|
||||
@@ -4602,6 +4609,7 @@ dependencies = [
|
||||
"futures 0.3.5",
|
||||
"maplit",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-test-helpers",
|
||||
"polkadot-primitives",
|
||||
"sp-blockchain",
|
||||
"sp-core",
|
||||
@@ -4643,6 +4651,7 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"log 0.4.8",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-util",
|
||||
"polkadot-primitives",
|
||||
"sp-core",
|
||||
"tokio 0.2.21",
|
||||
@@ -4655,6 +4664,7 @@ dependencies = [
|
||||
"futures 0.3.5",
|
||||
"polkadot-node-primitives",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-test-helpers",
|
||||
"polkadot-primitives",
|
||||
"sp-api",
|
||||
"sp-blockchain",
|
||||
@@ -4665,7 +4675,6 @@ dependencies = [
|
||||
name = "polkadot-node-primitives"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"parity-scale-codec",
|
||||
"polkadot-primitives",
|
||||
"polkadot-statement-table",
|
||||
@@ -4687,6 +4696,51 @@ dependencies = [
|
||||
"parking_lot 0.10.2",
|
||||
"pin-project",
|
||||
"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-statement-table",
|
||||
"sc-keystore",
|
||||
@@ -4746,6 +4800,7 @@ dependencies = [
|
||||
"parking_lot 0.10.2",
|
||||
"polkadot-node-primitives",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-test-helpers",
|
||||
"polkadot-primitives",
|
||||
"sc-network",
|
||||
"sp-core",
|
||||
@@ -5102,6 +5157,7 @@ dependencies = [
|
||||
"parking_lot 0.10.2",
|
||||
"polkadot-node-primitives",
|
||||
"polkadot-node-subsystem",
|
||||
"polkadot-node-subsystem-test-helpers",
|
||||
"polkadot-primitives",
|
||||
"sp-core",
|
||||
"sp-keyring",
|
||||
|
||||
@@ -61,6 +61,8 @@ members = [
|
||||
"node/primitives",
|
||||
"node/service",
|
||||
"node/subsystem",
|
||||
"node/subsystem-test-helpers",
|
||||
"node/subsystem-util",
|
||||
"node/test-service",
|
||||
|
||||
"parachain/test-parachains",
|
||||
|
||||
@@ -19,6 +19,6 @@ derive_more = "0.99.9"
|
||||
[dev-dependencies]
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
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"
|
||||
assert_matches = "1.3.0"
|
||||
|
||||
@@ -316,7 +316,7 @@ mod tests {
|
||||
AvailableData, BlockData, HeadData, GlobalValidationData, LocalValidationData, PoV,
|
||||
OmittedValidationData,
|
||||
};
|
||||
use polkadot_subsystem::test_helpers;
|
||||
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||
|
||||
struct TestHarness {
|
||||
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-node-primitives = { path = "../../primitives" }
|
||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
|
||||
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
|
||||
erasure-coding = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
|
||||
statement-table = { package = "polkadot-statement-table", path = "../../../statement-table" }
|
||||
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" }
|
||||
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||
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,
|
||||
RuntimeApiRequest,
|
||||
},
|
||||
util::{
|
||||
self,
|
||||
request_session_index_for_child,
|
||||
request_validator_groups,
|
||||
request_validators,
|
||||
request_from_runtime,
|
||||
Validator,
|
||||
},
|
||||
};
|
||||
use polkadot_node_subsystem_util::{
|
||||
self as util,
|
||||
request_session_index_for_child,
|
||||
request_validator_groups,
|
||||
request_validators,
|
||||
request_from_runtime,
|
||||
Validator,
|
||||
delegated_subsystem,
|
||||
};
|
||||
use statement_table::{
|
||||
@@ -896,13 +896,13 @@ mod tests {
|
||||
}
|
||||
|
||||
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) {
|
||||
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());
|
||||
|
||||
@@ -960,7 +960,7 @@ mod tests {
|
||||
|
||||
// Tests that the subsystem performs actions that are requied on 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,
|
||||
) {
|
||||
// Start work on some new parent.
|
||||
|
||||
@@ -11,5 +11,6 @@ futures = "0.3.5"
|
||||
log = "0.4.8"
|
||||
polkadot-primitives = { path = "../../../primitives" }
|
||||
polkadot-node-subsystem = { path = "../../subsystem" }
|
||||
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
|
||||
keystore = { package = "sc-keystore", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
wasm-timer = "0.2.4"
|
||||
|
||||
@@ -29,7 +29,9 @@ use polkadot_node_subsystem::{
|
||||
BitfieldSigningMessage, CandidateBackingMessage, RuntimeApiMessage,
|
||||
},
|
||||
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 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" }
|
||||
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||
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)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use polkadot_subsystem::test_helpers;
|
||||
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||
use polkadot_primitives::v1::{HeadData, BlockData};
|
||||
use sp_core::testing::TaskExecutor;
|
||||
use futures::executor;
|
||||
|
||||
@@ -13,5 +13,5 @@ polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsys
|
||||
[dev-dependencies]
|
||||
futures = { version = "0.3.5", features = ["thread-pool"] }
|
||||
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" }
|
||||
|
||||
@@ -121,7 +121,7 @@ mod tests {
|
||||
use futures::{future::BoxFuture, channel::oneshot};
|
||||
|
||||
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_core::testing::TaskExecutor;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ futures = "0.3.5"
|
||||
log = "0.4.8"
|
||||
polkadot-primitives = { path = "../../../primitives" }
|
||||
polkadot-node-subsystem = { path = "../../subsystem" }
|
||||
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
|
||||
|
||||
[dev-dependencies]
|
||||
lazy_static = "1.4"
|
||||
|
||||
@@ -25,16 +25,17 @@ use futures::{
|
||||
prelude::*,
|
||||
};
|
||||
use polkadot_node_subsystem::{
|
||||
delegated_subsystem,
|
||||
errors::{ChainApiError, RuntimeApiError},
|
||||
messages::{
|
||||
AllMessages, ChainApiMessage, ProvisionableData, ProvisionerInherentData,
|
||||
ProvisionerMessage, RuntimeApiMessage,
|
||||
},
|
||||
util::{
|
||||
self, request_availability_cores, request_global_validation_data,
|
||||
request_local_validation_data, JobTrait, ToJobTrait,
|
||||
},
|
||||
};
|
||||
use polkadot_node_subsystem_util::{
|
||||
self as util,
|
||||
delegated_subsystem,
|
||||
request_availability_cores, request_global_validation_data,
|
||||
request_local_validation_data, JobTrait, ToJobTrait,
|
||||
};
|
||||
use polkadot_primitives::v1::{
|
||||
validation_data_hash, BackedCandidate, BlockNumber, CoreState, Hash, OccupiedCoreAssumption,
|
||||
|
||||
@@ -16,4 +16,4 @@ polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsys
|
||||
[dev-dependencies]
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
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,
|
||||
CommittedCandidateReceipt, CandidateEvent,
|
||||
};
|
||||
use polkadot_subsystem::test_helpers;
|
||||
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||
use sp_core::testing::TaskExecutor;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -18,7 +18,7 @@ polkadot-network = { path = "../../../network" }
|
||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
[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"] }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
parking_lot = "0.10.0"
|
||||
|
||||
@@ -607,7 +607,7 @@ mod test {
|
||||
use futures::executor;
|
||||
use maplit::hashmap;
|
||||
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 sp_core::crypto::Pair;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -19,5 +19,5 @@ polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsys
|
||||
[dev-dependencies]
|
||||
assert_matches = "1.3.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" }
|
||||
|
||||
@@ -521,7 +521,7 @@ mod tests {
|
||||
use assert_matches::assert_matches;
|
||||
|
||||
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`.
|
||||
struct TestNetwork {
|
||||
@@ -540,7 +540,7 @@ mod tests {
|
||||
TestNetwork,
|
||||
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();
|
||||
|
||||
(
|
||||
@@ -621,13 +621,13 @@ mod tests {
|
||||
|
||||
struct TestHarness {
|
||||
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) {
|
||||
let pool = sp_core::testing::TaskExecutor::new();
|
||||
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(
|
||||
network,
|
||||
|
||||
@@ -20,4 +20,4 @@ polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsys
|
||||
parking_lot = "0.10.0"
|
||||
assert_matches = "1.3.0"
|
||||
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 (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();
|
||||
descriptor.pov_hash = pov_hash;
|
||||
|
||||
@@ -719,7 +719,7 @@ mod tests {
|
||||
};
|
||||
|
||||
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();
|
||||
descriptor.pov_hash = pov_hash;
|
||||
|
||||
@@ -797,7 +797,7 @@ mod tests {
|
||||
};
|
||||
|
||||
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 {
|
||||
handle_network_update(
|
||||
@@ -869,7 +869,7 @@ mod tests {
|
||||
};
|
||||
|
||||
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 {
|
||||
// Peer A answers our request before peer B.
|
||||
@@ -957,7 +957,7 @@ mod tests {
|
||||
};
|
||||
|
||||
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 {
|
||||
// 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 (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 {
|
||||
// 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 (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 {
|
||||
// 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 (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 {
|
||||
let max_plausibly_awaited = n_validators * 2;
|
||||
@@ -1224,7 +1224,7 @@ mod tests {
|
||||
};
|
||||
|
||||
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 {
|
||||
let pov_hash = make_pov(vec![1, 2, 3]).hash();
|
||||
@@ -1286,7 +1286,7 @@ mod tests {
|
||||
};
|
||||
|
||||
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 {
|
||||
let pov_hash = make_pov(vec![1, 2, 3]).hash();
|
||||
@@ -1363,7 +1363,7 @@ mod tests {
|
||||
};
|
||||
|
||||
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 {
|
||||
handle_network_update(
|
||||
@@ -1446,7 +1446,7 @@ mod tests {
|
||||
};
|
||||
|
||||
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 {
|
||||
handle_network_update(
|
||||
|
||||
@@ -21,7 +21,7 @@ indexmap = "1.4.0"
|
||||
|
||||
[dev-dependencies]
|
||||
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"
|
||||
sp-keyring = { 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 (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();
|
||||
|
||||
executor::block_on(async move {
|
||||
@@ -1327,7 +1327,7 @@ mod tests {
|
||||
].into_iter().collect();
|
||||
|
||||
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 {
|
||||
let statement = {
|
||||
|
||||
@@ -10,5 +10,4 @@ polkadot-primitives = { path = "../../primitives" }
|
||||
polkadot-statement-table = { path = "../../statement-table" }
|
||||
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 }
|
||||
async-trait = "0.1"
|
||||
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.
|
||||
|
||||
use crate::{SubsystemContext, FromOverseer, SubsystemResult, SubsystemError};
|
||||
use crate::messages::AllMessages;
|
||||
use polkadot_node_subsystem::{SubsystemContext, FromOverseer, SubsystemResult, SubsystemError};
|
||||
use polkadot_node_subsystem::messages::AllMessages;
|
||||
|
||||
use futures::prelude::*;
|
||||
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
|
||||
//! this module.
|
||||
|
||||
use crate::{
|
||||
use polkadot_node_subsystem::{
|
||||
errors::{ChainApiError, RuntimeApiError},
|
||||
messages::{AllMessages, RuntimeApiMessage, RuntimeApiRequest, RuntimeApiSender},
|
||||
FromOverseer, SpawnedSubsystem, Subsystem, SubsystemContext, SubsystemError, SubsystemResult,
|
||||
@@ -43,7 +43,7 @@ use polkadot_primitives::v1::{
|
||||
SessionIndex, Signed, SigningContext, ValidationCode, ValidatorId, ValidatorIndex,
|
||||
ValidatorPair,
|
||||
};
|
||||
use sp_core::Pair;
|
||||
use sp_core::{Pair, traits::SpawnNamed};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
convert::{TryFrom, TryInto},
|
||||
@@ -53,10 +53,15 @@ use std::{
|
||||
};
|
||||
use streamunordered::{StreamUnordered, StreamYield};
|
||||
|
||||
/// This reexport is required so that external crates can use the `delegated_subsystem` macro properly.
|
||||
///
|
||||
/// Otherwise, downstream crates might have to modify their `Cargo.toml` to ensure `sp-core` appeared there.
|
||||
pub use sp_core::traits::SpawnNamed;
|
||||
/// These reexports are required so that external crates can use the `delegated_subsystem` macro properly.
|
||||
pub mod reexports {
|
||||
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.
|
||||
pub const JOB_GRACEFUL_STOP_DURATION: Duration = Duration::from_secs(1);
|
||||
@@ -655,9 +660,9 @@ where
|
||||
run_args: &Job::RunArgs,
|
||||
err_tx: &mut Option<mpsc::Sender<(Option<Hash>, JobsError<Job::Error>)>>,
|
||||
) -> bool {
|
||||
use crate::ActiveLeavesUpdate;
|
||||
use crate::FromOverseer::{Communication, Signal};
|
||||
use crate::OverseerSignal::{ActiveLeaves, BlockFinalized, Conclude};
|
||||
use polkadot_node_subsystem::ActiveLeavesUpdate;
|
||||
use polkadot_node_subsystem::FromOverseer::{Communication, Signal};
|
||||
use polkadot_node_subsystem::OverseerSignal::{ActiveLeaves, BlockFinalized, Conclude};
|
||||
|
||||
match incoming {
|
||||
Ok(Signal(ActiveLeaves(ActiveLeavesUpdate {
|
||||
@@ -783,7 +788,7 @@ where
|
||||
/// It is possible to create a type which implements `Subsystem` by simply doing:
|
||||
///
|
||||
/// ```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`)
|
||||
@@ -791,7 +796,7 @@ where
|
||||
/// can reduce the total number of public types exposed, i.e.
|
||||
///
|
||||
/// ```ignore
|
||||
/// type Manager<Spawner, Context> = util::JobManager<Spawner, Context, ExampleJob>;
|
||||
/// type Manager<Spawner, Context> = JobManager<Spawner, Context, ExampleJob>;
|
||||
/// pub struct ExampleSubsystem {
|
||||
/// 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) => {
|
||||
#[doc = "Manager type for the "]
|
||||
#[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 = $subsystem_name]
|
||||
@@ -830,15 +835,15 @@ macro_rules! delegated_subsystem {
|
||||
|
||||
impl<Spawner, Context> $subsystem<Spawner, Context>
|
||||
where
|
||||
Spawner: Clone + $crate::util::SpawnNamed + Send + Unpin,
|
||||
Context: $crate::SubsystemContext,
|
||||
<Context as $crate::SubsystemContext>::Message: Into<$to_job>,
|
||||
Spawner: Clone + $crate::reexports::SpawnNamed + Send + Unpin,
|
||||
Context: $crate::reexports::SubsystemContext,
|
||||
<Context as $crate::reexports::SubsystemContext>::Message: Into<$to_job>,
|
||||
{
|
||||
#[doc = "Creates a new "]
|
||||
#[doc = $subsystem_name]
|
||||
pub fn new(spawner: Spawner, run_args: $run_args) -> Self {
|
||||
$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
|
||||
Spawner: $crate::util::SpawnNamed + Send + Clone + Unpin + 'static,
|
||||
Context: $crate::SubsystemContext,
|
||||
<Context as $crate::SubsystemContext>::Message: Into<$to_job>,
|
||||
Spawner: $crate::reexports::SpawnNamed + Send + Clone + Unpin + 'static,
|
||||
Context: $crate::reexports::SubsystemContext,
|
||||
<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)
|
||||
}
|
||||
}
|
||||
@@ -863,10 +868,9 @@ macro_rules! delegated_subsystem {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
use super::{Error as UtilError, JobManager, JobTrait, JobsError, ToJobTrait};
|
||||
use polkadot_node_subsystem::{
|
||||
messages::{AllMessages, CandidateSelectionMessage},
|
||||
test_helpers::{self, make_subsystem_context},
|
||||
util::{self, JobManager, JobTrait, JobsError, ToJobTrait},
|
||||
ActiveLeavesUpdate, FromOverseer, OverseerSignal, SpawnedSubsystem, Subsystem,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
@@ -878,6 +882,7 @@ mod tests {
|
||||
};
|
||||
use futures_timer::Delay;
|
||||
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};
|
||||
|
||||
// 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
|
||||
#[derive(Clone)]
|
||||
enum FromJob {
|
||||
Test(String),
|
||||
Test,
|
||||
}
|
||||
|
||||
impl From<FromJob> for AllMessages {
|
||||
fn from(from_job: FromJob) -> AllMessages {
|
||||
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() {
|
||||
let relay_parent: Hash = [0; 32].into();
|
||||
let mut run_args = HashMap::new();
|
||||
let test_message = format!("greetings from {}", relay_parent);
|
||||
run_args.insert(
|
||||
relay_parent.clone(),
|
||||
vec![FromJob::Test(test_message.clone())],
|
||||
vec![FromJob::Test],
|
||||
);
|
||||
|
||||
test_harness(run_args, |mut overseer_handle, err_rx| async move {
|
||||
@@ -1068,7 +1072,7 @@ mod tests {
|
||||
.await;
|
||||
assert_matches!(
|
||||
overseer_handle.recv().await,
|
||||
AllMessages::Test(msg) if msg == test_message
|
||||
AllMessages::CandidateSelection(_)
|
||||
);
|
||||
overseer_handle
|
||||
.send(FromOverseer::Signal(OverseerSignal::ActiveLeaves(
|
||||
@@ -1098,7 +1102,7 @@ mod tests {
|
||||
assert_eq!(errs[0].0, Some(relay_parent));
|
||||
assert_matches!(
|
||||
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"
|
||||
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 }
|
||||
@@ -21,13 +20,10 @@ 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"
|
||||
|
||||
[features]
|
||||
test-helpers = [ "parking_lot" ]
|
||||
polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" }
|
||||
|
||||
@@ -36,9 +36,6 @@ use crate::messages::AllMessages;
|
||||
|
||||
pub mod errors;
|
||||
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
|
||||
///
|
||||
|
||||
@@ -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.
|
||||
#[derive(Debug)]
|
||||
pub enum CandidateBackingMessage {
|
||||
@@ -509,10 +515,4 @@ pub enum AllMessages {
|
||||
NetworkBridge(NetworkBridgeMessage),
|
||||
/// Message for the Chain API subsystem
|
||||
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