Skip to content

Commit

Permalink
zcash_client_sqlite: Fix invalid_chain_cache_disconnected tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Mar 24, 2024
1 parent e67a978 commit 81954e2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion zcash_client_sqlite/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ where
value,
prior_cached_block.sapling_end_size,
prior_cached_block.orchard_end_size,
false,
);

(height, res, nf)
Expand Down Expand Up @@ -529,6 +530,7 @@ where
value: NonNegativeAmount,
initial_sapling_tree_size: u32,
initial_orchard_tree_size: u32,
allow_broken_hash_chain: bool,
) -> (Cache::InsertResult, Fvk::Nullifier) {
let mut prior_cached_block = self
.latest_cached_block_below_height(height)
Expand All @@ -542,7 +544,9 @@ where
// we need to generate a new prior cached block that the block to be generated can
// successfully chain from, with the provided tree sizes.
if prior_cached_block.chain_state.block_height() == height - 1 {
assert_eq!(prev_hash, prior_cached_block.chain_state.block_hash());
if !allow_broken_hash_chain {
assert_eq!(prev_hash, prior_cached_block.chain_state.block_hash());
}
} else {
let final_sapling_tree =
(prior_cached_block.sapling_end_size..initial_sapling_tree_size).fold(
Expand Down
3 changes: 3 additions & 0 deletions zcash_client_sqlite/src/testing/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,7 @@ pub(crate) fn birthday_in_anchor_shard<T: ShieldedPoolTester>() {
not_our_value,
initial_sapling_tree_size,
initial_orchard_tree_size,
false,
);
for _ in 1..9 {
st.generate_next_block(&not_our_key, AddressType::DefaultExternal, not_our_value);
Expand Down Expand Up @@ -1392,6 +1393,7 @@ pub(crate) fn checkpoint_gaps<T: ShieldedPoolTester>() {
not_our_value,
st.latest_cached_block().unwrap().sapling_end_size,
st.latest_cached_block().unwrap().orchard_end_size,
false,
);

// Scan the block
Expand Down Expand Up @@ -1888,6 +1890,7 @@ pub(crate) fn invalid_chain_cache_disconnected<T: ShieldedPoolTester>() {
NonNegativeAmount::const_from_u64(8),
2,
2,
true,
);
st.generate_next_block(
&dfvk,
Expand Down
1 change: 1 addition & 0 deletions zcash_client_sqlite/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3103,6 +3103,7 @@ mod tests {
not_our_value,
0,
0,
false,
);
let (mid_height, _, _) =
st.generate_next_block(&not_our_key, AddressType::DefaultExternal, not_our_value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use zcash_keys::keys::UnifiedFullViewingKey;
use zcash_primitives::consensus;
use zip32::fingerprint::SeedFingerprint;

use super::{add_account_birthdays, receiving_key_scopes, v_transactions_note_uniqueness, wallet_summaries};
use super::{
add_account_birthdays, receiving_key_scopes, v_transactions_note_uniqueness, wallet_summaries,
};

/// The migration that switched from presumed seed-derived account IDs to supporting
/// HD accounts and all sorts of imported keys.
Expand Down
3 changes: 3 additions & 0 deletions zcash_client_sqlite/src/wallet/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ pub(crate) mod tests {
value,
initial_sapling_tree_size,
initial_orchard_tree_size,
false,
);

for _ in 1..=10 {
Expand Down Expand Up @@ -1107,6 +1108,7 @@ pub(crate) mod tests {
NonNegativeAmount::const_from_u64(10000),
frontier_tree_size + 10,
frontier_tree_size + 10,
false,
);
st.scan_cached_blocks(max_scanned, 1);

Expand Down Expand Up @@ -1293,6 +1295,7 @@ pub(crate) mod tests {
NonNegativeAmount::const_from_u64(10000),
frontier_tree_size + 10,
frontier_tree_size + 10,
false,
);
st.scan_cached_blocks(max_scanned, 1);

Expand Down

0 comments on commit 81954e2

Please sign in to comment.