@@ -2941,42 +2941,36 @@ mod tests {
2941
2941
// Scan a block above the wallet's birthday height.
2942
2942
let not_our_key = ExtendedSpendingKey :: master ( & [ ] ) . to_diversifiable_full_viewing_key ( ) ;
2943
2943
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 ( ) ;
2945
2945
let _ = st. generate_block_at (
2946
- end_height ,
2947
- BlockHash ( [ 37 ; 32 ] ) ,
2946
+ start_height ,
2947
+ BlockHash ( [ 0 ; 32 ] ) ,
2948
2948
& not_our_key,
2949
2949
AddressType :: DefaultExternal ,
2950
2950
not_our_value,
2951
- 17 ,
2952
- 17 ,
2951
+ 0 ,
2952
+ 0 ,
2953
2953
) ;
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
2954
2960
st. scan_cached_blocks ( end_height, 1 ) ;
2955
2961
2956
2962
// The wallet should still have no fully-scanned block, as no scanned block range
2957
2963
// overlaps the wallet's birthday.
2958
2964
assert_eq ! ( block_fully_scanned( & st) , None ) ;
2959
2965
2960
2966
// 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
- ) ;
2971
2967
st. scan_cached_blocks ( start_height, 1 ) ;
2972
2968
2973
2969
// The fully-scanned height should now be that of the scanned block.
2974
2970
assert_eq ! ( block_fully_scanned( & st) , Some ( start_height) ) ;
2975
2971
2976
2972
// 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 ) ;
2980
2974
2981
2975
// The fully-scanned height should now be the latest block, as the two disjoint
2982
2976
// ranges have been connected.
0 commit comments