Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
tdimitrov committed Nov 14, 2022
1 parent 6217969 commit 71f5851
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
6 changes: 4 additions & 2 deletions node/core/dispute-coordinator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ use polkadot_node_subsystem::{
messages::{AllMessages, BlockDescription, RuntimeApiMessage, RuntimeApiRequest},
ActivatedLeaf, ActiveLeavesUpdate, LeafStatus,
};
use polkadot_node_subsystem_test_helpers::{make_subsystem_context, TestSubsystemContextHandle};
use polkadot_node_subsystem_test_helpers::{
make_buffered_subsystem_context, TestSubsystemContextHandle,
};
use polkadot_primitives::v2::{
ApprovalVote, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash,
CandidateReceipt, CoreIndex, DisputeStatement, GroupIndex, Hash, HeadData, Header, IndexedVec,
Expand Down Expand Up @@ -523,7 +525,7 @@ impl TestState {
F: FnOnce(TestState, VirtualOverseer) -> BoxFuture<'static, TestState>,
{
self.known_session = None;
let (ctx, ctx_handle) = make_subsystem_context(TaskExecutor::new());
let (ctx, ctx_handle) = make_buffered_subsystem_context(TaskExecutor::new(), 1);
let subsystem = DisputeCoordinatorSubsystem::new(
self.db.clone(),
self.config.clone(),
Expand Down
13 changes: 10 additions & 3 deletions node/subsystem-test-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,19 @@ impl<M> TestSubsystemContextHandle<M> {
}
}

/// Make a test subsystem context.
/// Make a test subsystem context with `buffer_size == 0`.
pub fn make_subsystem_context<M, S>(
spawner: S,
) -> (TestSubsystemContext<M, SpawnGlue<S>>, TestSubsystemContextHandle<M>) {
let (overseer_tx, overseer_rx) = mpsc::channel(1);
make_buffered_subsystem_context(spawner, 0)
}

/// Make a test subsystem context.
pub fn make_buffered_subsystem_context<M, S>(
spawner: S,
buffer_size: usize,
) -> (TestSubsystemContext<M, SpawnGlue<S>>, TestSubsystemContextHandle<M>) {
let (overseer_tx, overseer_rx) = mpsc::channel(buffer_size);
let (all_messages_tx, all_messages_rx) = mpsc::unbounded();

(
Expand All @@ -296,7 +304,6 @@ pub fn make_subsystem_context<M, S>(
TestSubsystemContextHandle { tx: overseer_tx, rx: all_messages_rx },
)
}

/// Test a subsystem, mocking the overseer
///
/// Pass in two async closures: one mocks the overseer, the other runs the test from the perspective of a subsystem.
Expand Down

0 comments on commit 71f5851

Please sign in to comment.