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

overseer: fix build #1596

Merged
2 commits merged into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions node/overseer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,12 +1087,14 @@ mod tests {
use std::sync::atomic;
use futures::{executor, pin_mut, select, channel::mpsc, FutureExt};

use polkadot_primitives::v1::{BlockData, PoV};
use polkadot_primitives::v1::{BlockData, CollatorPair, PoV};
use polkadot_subsystem::DummySubsystem;
use polkadot_subsystem::messages::RuntimeApiRequest;

use polkadot_node_primitives::{Collation, CollationGenerationConfig};
use polkadot_node_network_protocol::{PeerId, ReputationChange, NetworkBridgeEvent};

use sp_core::crypto::Pair as _;

use super::*;


Expand Down Expand Up @@ -1250,7 +1252,6 @@ mod tests {
assert_eq!(s1_results, (0..10).collect::<Vec<_>>());
});
}

// Spawn a subsystem that immediately exits.
//
// Should immediately conclude the overseer itself with an error.
Expand Down Expand Up @@ -1639,6 +1640,25 @@ mod tests {
ChainApiMessage::FinalizedBlockNumber(sender)
}

fn test_collator_generation_msg() -> CollationGenerationMessage {
CollationGenerationMessage::Initialize(CollationGenerationConfig {
key: CollatorPair::generate().0,
collator: Box::new(|_, _| Box::new(TestCollator)),
para_id: Default::default(),
})
}
struct TestCollator;

impl Future for TestCollator {
type Output = Collation;

fn poll(self: Pin<&mut Self>, _cx: &mut futures::task::Context) -> Poll<Self::Output> {
panic!("at the Disco")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕺

}
}

impl Unpin for TestCollator {}

fn test_collator_protocol_msg() -> CollatorProtocolMessage {
CollatorProtocolMessage::CollateOn(Default::default())
}
Expand Down Expand Up @@ -1702,6 +1722,7 @@ mod tests {
candidate_validation: subsystem.clone(),
candidate_backing: subsystem.clone(),
candidate_selection: subsystem.clone(),
collation_generation: subsystem.clone(),
collator_protocol: subsystem.clone(),
statement_distribution: subsystem.clone(),
availability_distribution: subsystem.clone(),
Expand Down Expand Up @@ -1735,6 +1756,7 @@ mod tests {
handler.send_msg(AllMessages::CandidateValidation(test_candidate_validation_msg())).await.unwrap();
handler.send_msg(AllMessages::CandidateBacking(test_candidate_backing_msg())).await.unwrap();
handler.send_msg(AllMessages::CandidateSelection(test_candidate_selection_msg())).await.unwrap();
handler.send_msg(AllMessages::CollationGeneration(test_collator_generation_msg())).await.unwrap();
handler.send_msg(AllMessages::CollatorProtocol(test_collator_protocol_msg())).await.unwrap();
handler.send_msg(AllMessages::StatementDistribution(test_statement_distribution_msg())).await.unwrap();
handler.send_msg(AllMessages::AvailabilityDistribution(test_availability_distribution_msg())).await.unwrap();
Expand All @@ -1752,7 +1774,7 @@ mod tests {

select! {
res = overseer_fut => {
const NUM_SUBSYSTEMS: usize = 14;
const NUM_SUBSYSTEMS: usize = 15;

assert_eq!(stop_signals_received.load(atomic::Ordering::SeqCst), NUM_SUBSYSTEMS);
// x2 because of broadcast_signal on startup
Expand Down