Skip to content

Commit 3a97f39

Browse files
committed
zcash_client_sqlite: Fix block_fully_scanned test.
1 parent 5f9bcc2 commit 3a97f39

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

zcash_client_sqlite/src/wallet.rs

+12-18
Original file line numberDiff line numberDiff line change
@@ -2941,42 +2941,36 @@ mod tests {
29412941
// Scan a block above the wallet's birthday height.
29422942
let not_our_key = ExtendedSpendingKey::master(&[]).to_diversifiable_full_viewing_key();
29432943
let not_our_value = NonNegativeAmount::const_from_u64(10000);
2944-
let end_height = st.sapling_activation_height() + 2;
2944+
let start_height = st.sapling_activation_height();
29452945
let _ = st.generate_block_at(
2946-
end_height,
2947-
BlockHash([37; 32]),
2946+
start_height,
2947+
BlockHash([0; 32]),
29482948
&not_our_key,
29492949
AddressType::DefaultExternal,
29502950
not_our_value,
2951-
17,
2952-
17,
2951+
0,
2952+
0,
29532953
);
2954+
let (mid_height, _, _) =
2955+
st.generate_next_block(&not_our_key, AddressType::DefaultExternal, not_our_value);
2956+
let (end_height, _, _) =
2957+
st.generate_next_block(&not_our_key, AddressType::DefaultExternal, not_our_value);
2958+
2959+
// Scan the last block first
29542960
st.scan_cached_blocks(end_height, 1);
29552961

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

29602966
// Scan the block at the wallet's birthday height.
2961-
let start_height = st.sapling_activation_height();
2962-
let _ = st.generate_block_at(
2963-
start_height,
2964-
BlockHash([0; 32]),
2965-
&not_our_key,
2966-
AddressType::DefaultExternal,
2967-
not_our_value,
2968-
0,
2969-
0,
2970-
);
29712967
st.scan_cached_blocks(start_height, 1);
29722968

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

29762972
// Scan the block in between the two previous blocks.
2977-
let (h, _, _) =
2978-
st.generate_next_block(&not_our_key, AddressType::DefaultExternal, not_our_value);
2979-
st.scan_cached_blocks(h, 1);
2973+
st.scan_cached_blocks(mid_height, 1);
29802974

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

0 commit comments

Comments
 (0)