From 2ec6ae364f272c7fff5833921964efad9e2a4b85 Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 20 Aug 2021 05:44:02 +1000 Subject: [PATCH] Improve some test errors (#2643) * Improve error logging in rejection_restores_internal_state * Summarise history tree peaks in debug output Co-authored-by: Conrado Gouvea Co-authored-by: Alfredo Garcia --- zebra-chain/src/history_tree.rs | 7 ++++--- .../src/service/non_finalized_state/tests/prop.rs | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/zebra-chain/src/history_tree.rs b/zebra-chain/src/history_tree.rs index 852fc707..efa025fb 100644 --- a/zebra-chain/src/history_tree.rs +++ b/zebra-chain/src/history_tree.rs @@ -14,6 +14,7 @@ use thiserror::Error; use crate::{ block::{Block, ChainHistoryMmrRootHash, Height}, + fmt::SummaryDebug, orchard, parameters::{Network, NetworkUpgrade}, primitives::zcash_history::{Entry, Tree, V1 as PreOrchard, V2 as OrchardOnward}, @@ -66,7 +67,7 @@ pub struct NonEmptyHistoryTree { size: u32, /// The peaks of the tree, indexed by their position in the array representation /// of the tree. This can be persisted to save the tree. - peaks: BTreeMap, + peaks: SummaryDebug>, /// The height of the most recent block added to the tree. current_height: Height, } @@ -117,7 +118,7 @@ impl NonEmptyHistoryTree { network_upgrade, inner, size, - peaks, + peaks: peaks.into(), current_height, }) } @@ -171,7 +172,7 @@ impl NonEmptyHistoryTree { network_upgrade, inner: tree, size: 1, - peaks, + peaks: peaks.into(), current_height: height, }) } diff --git a/zebra-state/src/service/non_finalized_state/tests/prop.rs b/zebra-state/src/service/non_finalized_state/tests/prop.rs index fec8a17b..a9516eb3 100644 --- a/zebra-state/src/service/non_finalized_state/tests/prop.rs +++ b/zebra-state/src/service/non_finalized_state/tests/prop.rs @@ -182,12 +182,23 @@ fn rejection_restores_internal_state() -> Result<()> { prop_assert!(state.eq_internal_state(&state)); if let Some(first_block) = chain.next() { - state.commit_new_chain(first_block, &finalized_state)?; + let result = state.commit_new_chain(first_block, &finalized_state); + prop_assert_eq!( + result, + Ok(()), + "PreparedChain should generate a valid first block" + ); prop_assert!(state.eq_internal_state(&state)); } for block in chain { - state.commit_block(block, &finalized_state)?; + let result = state.commit_block(block.clone(), &finalized_state); + prop_assert_eq!( + result, + Ok(()), + "PreparedChain should generate a valid block at {:?}", + block.height, + ); prop_assert!(state.eq_internal_state(&state)); }