zcash_client_sqlite: Ensure that fragmentation also can't occur at scan range ends.
This commit is contained in:
parent
4fe9d61959
commit
fb8c3a178c
|
@ -458,8 +458,8 @@ pub(crate) fn replace_queue_entries(
|
|||
AND :start <= block_range_end
|
||||
)
|
||||
OR (
|
||||
-- the end is contained within the range
|
||||
:end > block_range_start
|
||||
-- the end is contained within or adjacent to the range
|
||||
:end >= block_range_start
|
||||
AND :end <= block_range_end
|
||||
)
|
||||
OR (
|
||||
|
@ -1340,4 +1340,46 @@ mod tests {
|
|||
let actual = suggest_scan_ranges(&st.wallet().conn, Ignored).unwrap();
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replace_queue_entries_merges_subsequent_range() {
|
||||
use ScanPriority::*;
|
||||
|
||||
let mut st = TestBuilder::new().build();
|
||||
|
||||
let ranges = vec![
|
||||
scan_range(150..200, ChainTip),
|
||||
scan_range(100..150, Scanned),
|
||||
scan_range(0..100, Ignored),
|
||||
];
|
||||
|
||||
{
|
||||
let tx = st.wallet_mut().conn.transaction().unwrap();
|
||||
insert_queue_entries(&tx, ranges.iter()).unwrap();
|
||||
tx.commit().unwrap();
|
||||
}
|
||||
|
||||
let actual = suggest_scan_ranges(&st.wallet().conn, Ignored).unwrap();
|
||||
assert_eq!(actual, ranges);
|
||||
|
||||
{
|
||||
let tx = st.wallet_mut().conn.transaction().unwrap();
|
||||
replace_queue_entries(
|
||||
&tx,
|
||||
&(BlockHeight::from(90)..BlockHeight::from(100)),
|
||||
vec![scan_range(90..100, Scanned)].into_iter(),
|
||||
)
|
||||
.unwrap();
|
||||
tx.commit().unwrap();
|
||||
}
|
||||
|
||||
let expected = vec![
|
||||
scan_range(150..200, ChainTip),
|
||||
scan_range(90..150, Scanned),
|
||||
scan_range(0..90, Ignored),
|
||||
];
|
||||
|
||||
let actual = suggest_scan_ranges(&st.wallet().conn, Ignored).unwrap();
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue