// Copyright 2021 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see .
#![forbid(unused_crate_dependencies)]
#![forbid(unused_extern_crates)]
//! A set of primitive constructors, to aid in crafting meaningful testcase while reducing repetition.
//!
//! Note that `dummy_` prefixed values are meant to be fillers, that should not matter, and will
//! contain randomness based data.
use polkadot_primitives::v2::{
CandidateCommitments, CandidateDescriptor, CandidateReceipt, CollatorId, CollatorSignature,
CommittedCandidateReceipt, Hash, HeadData, Id as ParaId, ValidationCode, ValidationCodeHash,
ValidatorId,
};
pub use rand;
use sp_application_crypto::sr25519;
use sp_keyring::Sr25519Keyring;
use sp_runtime::generic::Digest;
/// Creates a candidate receipt with filler data.
pub fn dummy_candidate_receipt>(relay_parent: H) -> CandidateReceipt {
CandidateReceipt:: {
commitments_hash: dummy_candidate_commitments(dummy_head_data()).hash(),
descriptor: dummy_candidate_descriptor(relay_parent),
}
}
/// Creates a committed candidate receipt with filler data.
pub fn dummy_committed_candidate_receipt>(
relay_parent: H,
) -> CommittedCandidateReceipt {
CommittedCandidateReceipt:: {
descriptor: dummy_candidate_descriptor::(relay_parent),
commitments: dummy_candidate_commitments(dummy_head_data()),
}
}
/// Create a candidate receipt with a bogus signature and filler data. Optionally set the commitment
/// hash with the `commitments` arg.
pub fn dummy_candidate_receipt_bad_sig(
relay_parent: Hash,
commitments: impl Into