From 9c256cc88e4b71f7ee4e486a10b0be26c31a5f66 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 8 Jun 2021 22:21:54 +0000 Subject: [PATCH] Add a fuzz check for `Uint128::increment` --- fuzz/fuzz_targets/uint128_fuzz.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fuzz/fuzz_targets/uint128_fuzz.rs b/fuzz/fuzz_targets/uint128_fuzz.rs index 9b8b2afa..6b832ade 100644 --- a/fuzz/fuzz_targets/uint128_fuzz.rs +++ b/fuzz/fuzz_targets/uint128_fuzz.rs @@ -40,6 +40,10 @@ fn do_test(data: &[u8]) { assert_eq!(128 - a_native.leading_zeros() as usize, a.bits()); assert_eq!(a_native as u64, bitcoin::util::uint::Uint128::from_u64(a_native as u64).unwrap().low_u64()); + let mut a_inc = a.clone(); + a_inc.increment(); + check_eq!(a_native.wrapping_add(1), a_inc); + // Checks with two numbers: let (b_native, b) = read_ints!(16);