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

Commit

Permalink
fix rolling session window and other utils
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed May 9, 2022
1 parent c3e1824 commit 4944bd2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
11 changes: 7 additions & 4 deletions node/subsystem-util/src/rolling_session_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ mod tests {
use assert_matches::assert_matches;
use polkadot_node_subsystem::messages::{AllMessages, AvailabilityRecoveryMessage};
use polkadot_node_subsystem_test_helpers::make_subsystem_context;
use polkadot_node_subsystem::SubsystemContext;
use polkadot_primitives::v2::Header;
use sp_core::testing::TaskExecutor;

Expand Down Expand Up @@ -329,11 +330,11 @@ mod tests {
let test_fut = {
Box::pin(async move {
let window = match window {
None => RollingSessionWindow::new(&mut sender, TEST_WINDOW_SIZE, hash)
None => RollingSessionWindow::new(sender.clone(), TEST_WINDOW_SIZE, hash)
.await
.unwrap(),
Some(mut window) => {
window.cache_session_info_for_head(&mut sender, hash).await.unwrap();
window.cache_session_info_for_head(sender, hash).await.unwrap();
window
},
};
Expand Down Expand Up @@ -503,8 +504,9 @@ mod tests {
let hash = header.hash();

let test_fut = {
let sender = ctx.sender().clone();
Box::pin(async move {
let res = RollingSessionWindow::new(ctx.sender(), TEST_WINDOW_SIZE, hash).await;
let res = RollingSessionWindow::new(sender, TEST_WINDOW_SIZE, hash).await;
assert!(res.is_err());
})
};
Expand Down Expand Up @@ -563,8 +565,9 @@ mod tests {

let test_fut = {
Box::pin(async move {
let sender = ctx.sender().clone();
let window =
RollingSessionWindow::new(ctx.sender(), TEST_WINDOW_SIZE, hash).await.unwrap();
RollingSessionWindow::new(sender, TEST_WINDOW_SIZE, hash).await.unwrap();

assert_eq!(window.earliest_session, session);
assert_eq!(window.session_info, vec![dummy_session_info(session)]);
Expand Down
17 changes: 11 additions & 6 deletions node/subsystem-util/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum Error {
impl<Sender> JobTrait for FakeCollatorProtocolJob<Sender>
where
Sender: overseer::CollatorProtocolSenderTrait + std::marker::Unpin,
JobSender<Sender>: overseer::CollatorProtocolSenderTrait + std::marker::Unpin,
{
type ToJob = CollatorProtocolMessage;
type OutgoingMessages = overseer::CollatorProtocolOutgoingMessages;
Expand All @@ -86,12 +87,16 @@ where
FakeCollatorProtocolJob { receiver, _phantom: std::marker::PhantomData::<Sender> };

if run_args {
sender
.send_message(CollatorProtocolMessage::Invalid(
dummy_hash(),
dummy_candidate_receipt(dummy_hash()),
))
.await;
// FIXME XXX
// this was a hack for testing, for sending a message to a subsystem itself
// on a bounded channel which is outragiously stupid, even for a test case
// sender
// .send_message(CollatorProtocolMessage::Invalid(
// dummy_hash(),
// dummy_candidate_receipt(dummy_hash()),
// ))
// .await;
unimplemented!("Probably delete this testcase entirely TODO")
}

// it isn't necessary to break run_loop into its own function,
Expand Down

0 comments on commit 4944bd2

Please sign in to comment.