Skip to content

Commit

Permalink
zcash_client_sqlite: Fix block_fully_scanned test.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Mar 12, 2024
1 parent 5f9bcc2 commit 3a97f39
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions zcash_client_sqlite/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2941,42 +2941,36 @@ mod tests {
// Scan a block above the wallet's birthday height.
let not_our_key = ExtendedSpendingKey::master(&[]).to_diversifiable_full_viewing_key();
let not_our_value = NonNegativeAmount::const_from_u64(10000);
let end_height = st.sapling_activation_height() + 2;
let start_height = st.sapling_activation_height();
let _ = st.generate_block_at(
end_height,
BlockHash([37; 32]),
start_height,
BlockHash([0; 32]),
&not_our_key,
AddressType::DefaultExternal,
not_our_value,
17,
17,
0,
0,
);
let (mid_height, _, _) =
st.generate_next_block(&not_our_key, AddressType::DefaultExternal, not_our_value);
let (end_height, _, _) =
st.generate_next_block(&not_our_key, AddressType::DefaultExternal, not_our_value);

// Scan the last block first
st.scan_cached_blocks(end_height, 1);

// The wallet should still have no fully-scanned block, as no scanned block range
// overlaps the wallet's birthday.
assert_eq!(block_fully_scanned(&st), None);

// Scan the block at the wallet's birthday height.
let start_height = st.sapling_activation_height();
let _ = st.generate_block_at(
start_height,
BlockHash([0; 32]),
&not_our_key,
AddressType::DefaultExternal,
not_our_value,
0,
0,
);
st.scan_cached_blocks(start_height, 1);

// The fully-scanned height should now be that of the scanned block.
assert_eq!(block_fully_scanned(&st), Some(start_height));

// Scan the block in between the two previous blocks.
let (h, _, _) =
st.generate_next_block(&not_our_key, AddressType::DefaultExternal, not_our_value);
st.scan_cached_blocks(h, 1);
st.scan_cached_blocks(mid_height, 1);

// The fully-scanned height should now be the latest block, as the two disjoint
// ranges have been connected.
Expand Down

0 comments on commit 3a97f39

Please sign in to comment.