Skip to content

Commit

Permalink
replace saturating_add with max()
Browse files Browse the repository at this point in the history
  • Loading branch information
alindima committed Dec 19, 2023
1 parent f6cc8ad commit 83ac989
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions reed-solomon-novelpoly/src/novel_poly_basis/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ struct ArbitraryData(Vec<u8>);
impl Arbitrary for ArbitraryData {
fn arbitrary(g: &mut Gen) -> Self {
// Limit the len to 1 mib, otherwise the test will take forever
let len = u32::arbitrary(g).saturating_add(2) % (1024 * 1024);
let len = (u32::arbitrary(g) % (1024 * 1024)).max(2);

let data: Vec<u8> = (0..len).map(|_| u8::arbitrary(g)).collect();

Expand All @@ -482,7 +482,7 @@ impl Arbitrary for ArbitraryData {
#[test]
fn round_trip_quickcheck() {
fn property(available_data: ArbitraryData, n_validators: u16) {
let n_validators = n_validators.saturating_add(2);
let n_validators = n_validators.max(2);
let wanted_k = (n_validators as usize - 1) / 3 + 1;
let rs = CodeParams::derive_parameters(n_validators as usize, wanted_k).unwrap().make_encoder();
let chunks = rs.encode::<WrappedShard>(&available_data.0).unwrap();
Expand Down

0 comments on commit 83ac989

Please sign in to comment.