Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alindima committed Aug 28, 2023
1 parent 533f6c9 commit 8adf595
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 deletions.
30 changes: 12 additions & 18 deletions polkadot/node/core/backing/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,26 +262,9 @@ async fn test_startup(virtual_overseer: &mut VirtualOverseer, test_state: &TestS
}
);

// Check if subsystem job issues a request for the minimum backing votes.
// This may or may not happen, depending if the minimum backing votes is already cached in the
// RuntimeInfo.
let next_message = {
let msg = virtual_overseer.recv().await;
match msg {
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
parent,
RuntimeApiRequest::MinimumBackingVotes(tx),
)) if parent == test_state.relay_parent => {
tx.send(Ok(test_state.minimum_backing_votes)).unwrap();
virtual_overseer.recv().await
},
_ => msg,
}
};

// Check that subsystem job issues a request for a validator set.
assert_matches!(
next_message,
virtual_overseer.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(parent, RuntimeApiRequest::Validators(tx))
) if parent == test_state.relay_parent => {
Expand All @@ -308,6 +291,17 @@ async fn test_startup(virtual_overseer: &mut VirtualOverseer, test_state: &TestS
tx.send(Ok(test_state.availability_cores.clone())).unwrap();
}
);

// Check if subsystem job issues a request for the minimum backing votes.
assert_matches!(
virtual_overseer.recv().await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
parent,
RuntimeApiRequest::MinimumBackingVotes(session_index, tx),
)) if parent == test_state.relay_parent && session_index == test_state.signing_context.session_index => {
tx.send(Ok(test_state.minimum_backing_votes)).unwrap();
}
);
}

// Test that a `CandidateBackingMessage::Second` issues validation work
Expand Down
30 changes: 12 additions & 18 deletions polkadot/node/core/backing/src/tests/prospective_parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,9 @@ async fn activate_leaf(
}
);

// Check if subsystem job issues a request for the minimum backing votes.
// This may or may not happen, depending if the minimum backing votes is already cached in
// the `RuntimeInfo`.
let next_message = {
let msg = virtual_overseer.recv().await;
match msg {
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
parent,
RuntimeApiRequest::MinimumBackingVotes(tx),
)) if parent == hash => {
tx.send(Ok(test_state.minimum_backing_votes)).unwrap();
virtual_overseer.recv().await
},
_ => msg,
}
};

// Check that subsystem job issues a request for a validator set.
assert_matches!(
next_message,
virtual_overseer.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(parent, RuntimeApiRequest::Validators(tx))
) if parent == hash => {
Expand Down Expand Up @@ -201,6 +184,17 @@ async fn activate_leaf(
tx.send(Ok(test_state.availability_cores.clone())).unwrap();
}
);

// Check if subsystem job issues a request for the minimum backing votes.
assert_matches!(
virtual_overseer.recv().await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
parent,
RuntimeApiRequest::MinimumBackingVotes(session_index, tx),
)) if parent == hash && session_index == test_state.signing_context.session_index => {
tx.send(Ok(test_state.minimum_backing_votes)).unwrap();
}
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ async fn handle_leaf_activation(
virtual_overseer.recv().await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
parent,
RuntimeApiRequest::MinimumBackingVotes(tx),
)) if parent == *hash => {
RuntimeApiRequest::MinimumBackingVotes(session_index, tx),
)) if parent == *hash && session_index == *session => {
tx.send(Ok(2)).unwrap();
}
);
Expand Down

0 comments on commit 8adf595

Please sign in to comment.