Skip to content

Commit

Permalink
Limit random heights to database range
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Dec 7, 2023
1 parent 5dcad35 commit 8ac73c3
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use proptest::{arbitrary::any, prelude::*};

use crate::{
service::finalized_state::arbitrary::assert_value_properties, SaplingScannedDatabaseIndex,
SaplingScannedResult, SaplingScanningKey,
SaplingScannedResult, SaplingScanningKey, MAX_ON_DISK_HEIGHT,
};

#[test]
Expand All @@ -18,7 +18,15 @@ fn roundtrip_sapling_scanning_key() {
fn roundtrip_sapling_db_index() {
let _init_guard = zebra_test::init();

proptest!(|(val in any::<SaplingScannedDatabaseIndex>())| assert_value_properties(val));
proptest!(
|(mut val in any::<SaplingScannedDatabaseIndex>())| {
// Limit the random height to the valid on-disk range.
// Blocks outside this range are rejected before they reach the state.
// (It would take decades to generate a valid chain this high.)
val.tx_loc.height.0 %= MAX_ON_DISK_HEIGHT.0 + 1;
assert_value_properties(val)
}
);
}

#[test]
Expand Down

0 comments on commit 8ac73c3

Please sign in to comment.