Skip to content
Snippets Groups Projects
Unverified Commit d81a2e2f authored by Tsvetomir Dimitrov's avatar Tsvetomir Dimitrov Committed by GitHub
Browse files

Fix code duplication in tests (#1575)

parent 756347ab
Branches
No related merge requests found
Pipeline #390534 passed with stages
in 42 minutes and 56 seconds
......@@ -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_matches!(
virtual_overseer.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(_, RuntimeApiRequest::SessionIndexForChild(tx))
) => {
tx.send(Ok(1u32.into())).unwrap();
}
);
assert_validation_requests(&mut virtual_overseer, validation_code.clone()).await;
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!(
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use ::test_helpers::{dummy_digest, dummy_hash};
use ::test_helpers::{dummy_digest, dummy_hash, validator_pubkeys};
use futures::{channel::oneshot, future::BoxFuture, prelude::*};
use polkadot_node_subsystem::{
messages::{
......@@ -94,10 +94,6 @@ struct TestState {
const OUR_VALIDATOR: Sr25519Keyring = Sr25519Keyring::Alice;
fn validator_pubkeys(val_ids: &[Sr25519Keyring]) -> Vec<ValidatorId> {
val_ids.iter().map(|v| v.public().into()).collect()
}
impl TestState {
fn new() -> Self {
// Initialize the default session 1. No validators are present there.
......
......@@ -159,6 +159,11 @@ pub fn dummy_pvd(parent_head: HeadData, relay_parent_number: u32) -> PersistedVa
}
}
/// Creates a meaningless signature
pub fn dummy_signature() -> polkadot_primitives::ValidatorSignature {
sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64])
}
/// Create a meaningless candidate, returning its receipt and PVD.
pub fn make_candidate(
relay_parent_hash: Hash,
......@@ -244,6 +249,11 @@ pub fn resign_candidate_descriptor_with_collator<H: AsRef<[u8]>>(
descriptor.signature = signature;
}
/// Extracts validators's public keus (`ValidatorId`) from `Sr25519Keyring`
pub fn validator_pubkeys(val_ids: &[Sr25519Keyring]) -> Vec<ValidatorId> {
val_ids.iter().map(|v| v.public().into()).collect()
}
/// Builder for `CandidateReceipt`.
pub struct TestCandidateBuilder {
pub para_id: ParaId,
......@@ -298,7 +308,3 @@ impl rand::RngCore for AlwaysZeroRng {
Ok(())
}
}
pub fn dummy_signature() -> polkadot_primitives::ValidatorSignature {
sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64])
}
......@@ -17,11 +17,11 @@
use super::*;
use frame_support::{assert_err, assert_ok, assert_storage_noop};
use keyring::Sr25519Keyring;
use primitives::{BlockNumber, ValidatorId, PARACHAIN_KEY_TYPE_ID};
use primitives::{BlockNumber, PARACHAIN_KEY_TYPE_ID};
use sc_keystore::LocalKeystore;
use sp_keystore::{Keystore, KeystorePtr};
use std::sync::Arc;
use test_helpers::{dummy_head_data, dummy_validation_code};
use test_helpers::{dummy_head_data, dummy_validation_code, validator_pubkeys};
use crate::{
configuration::HostConfiguration,
......@@ -39,10 +39,6 @@ static VALIDATORS: &[Sr25519Keyring] = &[
Sr25519Keyring::Ferdie,
];
fn validator_pubkeys(val_ids: &[Sr25519Keyring]) -> Vec<ValidatorId> {
val_ids.iter().map(|v| v.public().into()).collect()
}
fn sign_and_include_pvf_check_statement(stmt: PvfCheckStatement) {
let validators = &[
Sr25519Keyring::Alice,
......
......@@ -22,10 +22,7 @@ use crate::{
use assert_matches::assert_matches;
use keyring::Sr25519Keyring;
use primitives::Hash;
fn validator_pubkeys(val_ids: &[Sr25519Keyring]) -> Vec<ValidatorId> {
val_ids.iter().map(|v| v.public().into()).collect()
}
use test_helpers::validator_pubkeys;
#[test]
fn tracker_earliest_block_number() {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment