Skip to content

Commit fa060f8

Browse files
committed
Ensure no overflows with new proptest
1 parent 627e6cb commit fa060f8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

crates/fuel-gas-price-algorithm/src/v0/tests/algorithm_v0_tests.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,30 @@ proptest! {
5858
}
5959
}
6060

61+
proptest! {
62+
#[test]
63+
fn worst_case__never_overflows(
64+
price: u64,
65+
starting_height: u32,
66+
block_horizon: u32,
67+
percentage: u64
68+
) {
69+
// given
70+
let algorithm = AlgorithmV0 {
71+
new_exec_price: price,
72+
for_height: starting_height,
73+
percentage,
74+
};
75+
76+
// when
77+
let target_height = starting_height.saturating_add(block_horizon);
78+
let _ = algorithm.worst_case(target_height);
79+
80+
// then
81+
// doesn't panic with an overflow
82+
}
83+
}
84+
6185
#[test]
6286
fn worst_case__same_block_gives_new_exec_price() {
6387
// given

0 commit comments

Comments
 (0)