mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 13:48:00 +00:00
Fix code duplication in tests (#1575)
This commit is contained in:
committed by
GitHub
parent
756347ab24
commit
d81a2e2fa9
@@ -18,7 +18,7 @@ use self::test_helpers::mock::new_leaf;
|
||||
use super::*;
|
||||
use ::test_helpers::{
|
||||
dummy_candidate_receipt_bad_sig, dummy_collator, dummy_collator_signature,
|
||||
dummy_committed_candidate_receipt, dummy_hash,
|
||||
dummy_committed_candidate_receipt, dummy_hash, validator_pubkeys,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use futures::{future, Future};
|
||||
@@ -48,10 +48,6 @@ mod prospective_parachains;
|
||||
const ASYNC_BACKING_DISABLED_ERROR: RuntimeApiError =
|
||||
RuntimeApiError::NotSupported { runtime_api_name: "test-runtime" };
|
||||
|
||||
fn validator_pubkeys(val_ids: &[Sr25519Keyring]) -> Vec<ValidatorId> {
|
||||
val_ids.iter().map(|v| v.public().into()).collect()
|
||||
}
|
||||
|
||||
fn table_statement_to_primitive(statement: TableStatement) -> Statement {
|
||||
match statement {
|
||||
TableStatement::Seconded(committed_candidate_receipt) =>
|
||||
@@ -299,6 +295,81 @@ async fn test_startup(virtual_overseer: &mut VirtualOverseer, test_state: &TestS
|
||||
);
|
||||
}
|
||||
|
||||
async fn assert_validation_requests(
|
||||
virtual_overseer: &mut VirtualOverseer,
|
||||
validation_code: ValidationCode,
|
||||
) {
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async fn assert_validate_from_exhaustive(
|
||||
virtual_overseer: &mut VirtualOverseer,
|
||||
pvd: &PersistedValidationData,
|
||||
pov: &PoV,
|
||||
validation_code: &ValidationCode,
|
||||
candidate: &CommittedCandidateReceipt,
|
||||
expected_head_data: &HeadData,
|
||||
result_validation_data: PersistedValidationData,
|
||||
) {
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::CandidateValidation(
|
||||
CandidateValidationMessage::ValidateFromExhaustive(
|
||||
_pvd,
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
) if _pvd == *pvd &&
|
||||
_validation_code == *validation_code &&
|
||||
*_pov == *pov && &candidate_receipt.descriptor == candidate.descriptor() &&
|
||||
timeout == PvfExecTimeoutKind::Backing &&
|
||||
candidate.commitments.hash() == candidate_receipt.commitments_hash =>
|
||||
{
|
||||
tx.send(Ok(ValidationResult::Valid(
|
||||
CandidateCommitments {
|
||||
head_data: expected_head_data.clone(),
|
||||
horizontal_messages: Default::default(),
|
||||
upward_messages: Default::default(),
|
||||
new_validation_code: None,
|
||||
processed_downward_messages: 0,
|
||||
hrmp_watermark: 0,
|
||||
},
|
||||
result_validation_data,
|
||||
)))
|
||||
.unwrap();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Test that a `CandidateBackingMessage::Second` issues validation work
|
||||
// and in case validation is successful issues a `StatementDistributionMessage`.
|
||||
#[test]
|
||||
@@ -334,65 +405,18 @@ fn backing_second_works() {
|
||||
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: second }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::CandidateValidation(
|
||||
CandidateValidationMessage::ValidateFromExhaustive(
|
||||
_pvd,
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
) if _pvd == pvd &&
|
||||
_validation_code == validation_code &&
|
||||
*_pov == pov && &candidate_receipt.descriptor == candidate.descriptor() &&
|
||||
timeout == PvfExecTimeoutKind::Backing &&
|
||||
candidate.commitments.hash() == candidate_receipt.commitments_hash =>
|
||||
{
|
||||
tx.send(Ok(ValidationResult::Valid(
|
||||
CandidateCommitments {
|
||||
head_data: expected_head_data.clone(),
|
||||
horizontal_messages: Default::default(),
|
||||
upward_messages: Default::default(),
|
||||
new_validation_code: None,
|
||||
processed_downward_messages: 0,
|
||||
hrmp_watermark: 0,
|
||||
},
|
||||
test_state.validation_data.clone(),
|
||||
)))
|
||||
.unwrap();
|
||||
}
|
||||
);
|
||||
assert_validate_from_exhaustive(
|
||||
&mut virtual_overseer,
|
||||
&pvd,
|
||||
&pov,
|
||||
&validation_code,
|
||||
&candidate,
|
||||
expected_head_data,
|
||||
test_state.validation_data.clone(),
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -499,32 +523,7 @@ fn backing_works() {
|
||||
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: statement }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
// Sending a `Statement::Seconded` for our assignment will start
|
||||
// validation process. The first thing requested is the PoV.
|
||||
@@ -702,32 +701,7 @@ fn backing_works_while_validation_ongoing() {
|
||||
CandidateBackingMessage::Statement(test_state.relay_parent, signed_a.clone());
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: statement }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
// Sending a `Statement::Seconded` for our assignment will start
|
||||
// validation process. The first thing requested is PoV from the
|
||||
@@ -893,32 +867,7 @@ fn backing_misbehavior_works() {
|
||||
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: statement }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -1098,32 +1047,7 @@ fn backing_dont_second_invalid() {
|
||||
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: second }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code_a.hash() => {
|
||||
tx.send(Ok(Some(validation_code_a.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code_a.clone()).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -1163,32 +1087,7 @@ fn backing_dont_second_invalid() {
|
||||
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: second }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code_b.hash() => {
|
||||
tx.send(Ok(Some(validation_code_b.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code_b.clone()).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -1300,32 +1199,7 @@ fn backing_second_after_first_fails_works() {
|
||||
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: statement }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
// Subsystem requests PoV and requests validation.
|
||||
assert_matches!(
|
||||
@@ -1408,32 +1282,7 @@ fn backing_second_after_first_fails_works() {
|
||||
// triggered on the prev step.
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: second }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code_to_second.hash() => {
|
||||
tx.send(Ok(Some(validation_code_to_second.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code_to_second.clone()).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -1494,32 +1343,7 @@ fn backing_works_after_failed_validation() {
|
||||
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: statement }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
// Subsystem requests PoV and requests validation.
|
||||
assert_matches!(
|
||||
@@ -1722,32 +1546,7 @@ fn retry_works() {
|
||||
CandidateBackingMessage::Statement(test_state.relay_parent, signed_a.clone());
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: statement }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
// Subsystem requests PoV and requests validation.
|
||||
// We cancel - should mean retry on next backing statement.
|
||||
@@ -1810,32 +1609,7 @@ fn retry_works() {
|
||||
CandidateBackingMessage::Statement(test_state.relay_parent, signed_c.clone());
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: statement }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -2026,65 +1800,18 @@ fn cannot_second_multiple_candidates_per_parent() {
|
||||
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: second }).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::CandidateValidation(
|
||||
CandidateValidationMessage::ValidateFromExhaustive(
|
||||
_pvd,
|
||||
_validation_code,
|
||||
candidate_receipt,
|
||||
_pov,
|
||||
_,
|
||||
timeout,
|
||||
tx,
|
||||
),
|
||||
) if _pvd == pvd &&
|
||||
_validation_code == validation_code &&
|
||||
*_pov == pov && &candidate_receipt.descriptor == candidate.descriptor() &&
|
||||
timeout == PvfExecTimeoutKind::Backing &&
|
||||
candidate.commitments.hash() == candidate_receipt.commitments_hash =>
|
||||
{
|
||||
tx.send(Ok(ValidationResult::Valid(
|
||||
CandidateCommitments {
|
||||
head_data: expected_head_data.clone(),
|
||||
horizontal_messages: Default::default(),
|
||||
upward_messages: Default::default(),
|
||||
new_validation_code: None,
|
||||
processed_downward_messages: 0,
|
||||
hrmp_watermark: 0,
|
||||
},
|
||||
test_state.validation_data.clone(),
|
||||
)))
|
||||
.unwrap();
|
||||
}
|
||||
);
|
||||
assert_validate_from_exhaustive(
|
||||
&mut virtual_overseer,
|
||||
&pvd,
|
||||
&pov,
|
||||
&validation_code,
|
||||
&candidate,
|
||||
expected_head_data,
|
||||
test_state.validation_data.clone(),
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
@@ -2131,32 +1858,7 @@ fn cannot_second_multiple_candidates_per_parent() {
|
||||
virtual_overseer.send(FromOrchestra::Communication { msg: second }).await;
|
||||
|
||||
// The validation is still requested.
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
|
||||
@@ -208,32 +208,7 @@ async fn assert_validate_seconded_candidate(
|
||||
expected_head_data: &HeadData,
|
||||
fetch_pov: bool,
|
||||
) {
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(parent, RuntimeApiRequest::ValidationCodeByHash(hash, tx))
|
||||
) if parent == relay_parent && hash == validation_code.hash() => {
|
||||
tx.send(Ok(Some(validation_code.clone()))).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
|
||||
) => {
|
||||
tx.send(Ok(1u32.into())).unwrap();
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::RuntimeApi(
|
||||
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionExecutorParams(sess_idx, tx))
|
||||
) if sess_idx == 1 => {
|
||||
tx.send(Ok(Some(ExecutorParams::default()))).unwrap();
|
||||
}
|
||||
);
|
||||
assert_validation_requests(virtual_overseer, validation_code.clone()).await;
|
||||
|
||||
if fetch_pov {
|
||||
assert_matches!(
|
||||
|
||||
Reference in New Issue
Block a user