Skip to content

Commit

Permalink
Increase coverage of state height serialization proptests #7443
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Dec 7, 2023
1 parent 8ac73c3 commit 8153127
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions zebra-state/src/service/finalized_state/disk_format/tests/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn roundtrip_block_height() {
// 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 = val.clamp(Height(0), MAX_ON_DISK_HEIGHT);
val.0 %= MAX_ON_DISK_HEIGHT.0 + 1;
assert_value_properties(val)
}
);
Expand Down Expand Up @@ -77,7 +77,7 @@ fn roundtrip_transaction_location() {

proptest!(
|(mut val in any::<TransactionLocation>())| {
val.height = val.height.clamp(Height(0), MAX_ON_DISK_HEIGHT);
val.height.0 %= MAX_ON_DISK_HEIGHT.0 + 1;
assert_value_properties(val)
}
);
Expand Down Expand Up @@ -145,7 +145,7 @@ fn roundtrip_output_location() {

proptest!(
|(mut val in any::<OutputLocation>())| {
*val.height_mut() = val.height().clamp(Height(0), MAX_ON_DISK_HEIGHT);
val.height_mut().0 %= MAX_ON_DISK_HEIGHT.0 + 1;
assert_value_properties(val)
}
);
Expand All @@ -157,7 +157,7 @@ fn roundtrip_address_location() {

proptest!(
|(mut val in any::<AddressLocation>())| {
*val.height_mut() = val.height().clamp(Height(0), MAX_ON_DISK_HEIGHT);
val.height_mut().0 %= MAX_ON_DISK_HEIGHT.0 + 1;
assert_value_properties(val)
}
);
Expand All @@ -169,7 +169,7 @@ fn roundtrip_address_balance_location() {

proptest!(
|(mut val in any::<AddressBalanceLocation>())| {
*val.height_mut() = val.address_location().height().clamp(Height(0), MAX_ON_DISK_HEIGHT);
val.height_mut().0 %= MAX_ON_DISK_HEIGHT.0 + 1;
assert_value_properties(val)
}
);
Expand All @@ -188,8 +188,8 @@ fn roundtrip_address_unspent_output() {

proptest!(
|(mut val in any::<AddressUnspentOutput>())| {
*val.address_location_mut().height_mut() = val.address_location().height().clamp(Height(0), MAX_ON_DISK_HEIGHT);
*val.unspent_output_location_mut().height_mut() = val.unspent_output_location().height().clamp(Height(0), MAX_ON_DISK_HEIGHT);
val.address_location_mut().height_mut().0 %= MAX_ON_DISK_HEIGHT.0 + 1;
val.unspent_output_location_mut().height_mut().0 %= MAX_ON_DISK_HEIGHT.0 + 1;

assert_value_properties(val)
}
Expand All @@ -202,8 +202,8 @@ fn roundtrip_address_transaction() {

proptest!(
|(mut val in any::<AddressTransaction>())| {
*val.address_location_mut().height_mut() = val.address_location().height().clamp(Height(0), MAX_ON_DISK_HEIGHT);
val.transaction_location_mut().height = val.transaction_location().height.clamp(Height(0), MAX_ON_DISK_HEIGHT);
val.address_location_mut().height_mut().0 %= MAX_ON_DISK_HEIGHT.0 + 1;
val.transaction_location_mut().height.0 %= MAX_ON_DISK_HEIGHT.0 + 1;

assert_value_properties(val)
}
Expand Down Expand Up @@ -464,7 +464,6 @@ fn roundtrip_orchard_subtree_data() {
let _init_guard = zebra_test::init();

proptest!(|(mut val in any::<NoteCommitmentSubtreeData<orchard::tree::Node>>())| {
val.end_height = val.end_height.clamp(Height(0), MAX_ON_DISK_HEIGHT);
val.end_height.0 %= MAX_ON_DISK_HEIGHT.0 + 1;
assert_value_properties(val)
});
Expand Down

0 comments on commit 8153127

Please sign in to comment.