mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Approval voting full subsystem tests (#3391)
* node/approval-voting: Introduce Backend trait and Overlaybackend This commit introduces a Backend trait and attempts to move away from the Action model via an OverlayBackend as in the ChainSelection subsystem. * node/approval-voting: Add WriteOps for StoredBlockRange and BlocksAtHeight * node/approval-voting: Add load_all_blocks to overlay * node/approval-voting: Get all module tests to pass. This commit modifies all tests to ensure tests are passing. * node/approval-voting: Address oversights in the previous commit This commit addresses some oversights in the prior commit. 1. Inner errors in backend.write were swallowed 2. One-off write functions removed to avoid useless abstraction 3. Touch-ups in general * node/approval-voting: Move from TestDB to dyn KeyValueDB This commit removes the TestDB from tests.rs and replaces it with an in-memory kvdb. * node/approval-voting: Address feedback * node/approval-voting: Add license to ops.rs * node/approval-voting: Address second-pass feedback * Add TODO * node/approval-voting: Bump spec_version * node/approval-voting: Address final comments. * node/approval-voting: Introduce framework for full subsystem tests * node/approval-voting: Introduce basic tests to attempt to provide coverage via full subsystem tests * node/approval-voting: Introduce Chainbuilder
This commit is contained in:
Generated
+1
@@ -6044,6 +6044,7 @@ dependencies = [
|
||||
"polkadot-node-subsystem-util",
|
||||
"polkadot-overseer",
|
||||
"polkadot-primitives",
|
||||
"rand 0.8.4",
|
||||
"rand_core 0.5.1",
|
||||
"sc-client-api",
|
||||
"sc-keystore",
|
||||
|
||||
@@ -42,3 +42,4 @@ maplit = "1.0.2"
|
||||
polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
|
||||
assert_matches = "1.4.0"
|
||||
kvdb-memorydb = "0.10.0"
|
||||
rand = "0.8"
|
||||
|
||||
@@ -557,7 +557,7 @@ pub(crate) async fn handle_new_head<'a>(
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::approval_db::v1::DbBackend;
|
||||
use polkadot_node_subsystem_test_helpers::make_subsystem_context;
|
||||
@@ -565,11 +565,11 @@ mod tests {
|
||||
use polkadot_primitives::v1::{SessionInfo, ValidatorIndex};
|
||||
use polkadot_node_subsystem::messages::AllMessages;
|
||||
use sp_core::testing::TaskExecutor;
|
||||
use sp_runtime::{Digest, DigestItem};
|
||||
use sp_consensus_babe::{
|
||||
pub(crate) use sp_runtime::{Digest, DigestItem};
|
||||
pub(crate) use sp_consensus_babe::{
|
||||
Epoch as BabeEpoch, BabeEpochConfiguration, AllowedSlots,
|
||||
};
|
||||
use sp_consensus_babe::digests::{CompatibleDigestItem, PreDigest, SecondaryVRFPreDigest};
|
||||
pub(crate) use sp_consensus_babe::digests::{CompatibleDigestItem, PreDigest, SecondaryVRFPreDigest};
|
||||
use sp_keyring::sr25519::Keyring as Sr25519Keyring;
|
||||
use assert_matches::assert_matches;
|
||||
use merlin::Transcript;
|
||||
@@ -650,7 +650,7 @@ mod tests {
|
||||
}
|
||||
|
||||
// used for generating assignments where the validity of the VRF doesn't matter.
|
||||
fn garbage_vrf() -> (VRFOutput, VRFProof) {
|
||||
pub(crate) fn garbage_vrf() -> (VRFOutput, VRFProof) {
|
||||
let key = Sr25519Keyring::Alice.pair();
|
||||
let key: &schnorrkel::Keypair = key.as_ref();
|
||||
|
||||
|
||||
@@ -85,9 +85,13 @@ use crate::backend::{Backend, OverlayedBackend};
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod old_tests;
|
||||
|
||||
const APPROVAL_SESSIONS: SessionIndex = 6;
|
||||
const APPROVAL_CHECKING_TIMEOUT: Duration = Duration::from_secs(120);
|
||||
const APPROVAL_CACHE_SIZE: usize = 1024;
|
||||
const TICK_TOO_FAR_IN_FUTURE: Tick = 20; // 10 seconds.
|
||||
const LOG_TARGET: &str = "parachain::approval-voting";
|
||||
|
||||
/// Configuration for the approval voting subsystem
|
||||
@@ -1420,9 +1424,8 @@ fn check_and_import_assignment(
|
||||
assignment: IndirectAssignmentCert,
|
||||
candidate_index: CandidateIndex,
|
||||
) -> SubsystemResult<(AssignmentCheckResult, Vec<Action>)> {
|
||||
const TICK_TOO_FAR_IN_FUTURE: Tick = 20; // 10 seconds.
|
||||
|
||||
let tick_now = state.clock.tick_now();
|
||||
|
||||
let block_entry = match db.load_block_entry(&assignment.block_hash)? {
|
||||
Some(b) => b,
|
||||
None => return Ok((AssignmentCheckResult::Bad(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user