Merge rust-bitcoin/rust-bitcoin#3274: Add Arbitrary to SignedAmount type

3f244db19d Add Arbitrary to SignedAmount type (yancy)

Pull request description:

  While proptesting, I've found Arbitrary for SingedAmount to be useful.  Would appreciate adding this as well.

ACKs for top commit:
  tcharding:
    ACK 3f244db19d
  Kixunil:
    ACK 3f244db19d

Tree-SHA512: f293215505db85998135c75e147f4cb0031a08c7db619b706e6c7d632c6f23783af56992531396aecc6e3da55b107a7f2c7ec4d68a3e5737ebcf4225f306ed29
This commit is contained in:
merge-script 2024-08-30 20:08:17 +00:00
commit c2e3e86106
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 8 additions and 0 deletions

View File

@ -1593,6 +1593,14 @@ impl core::iter::Sum for SignedAmount {
} }
} }
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for SignedAmount {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
let s = i64::arbitrary(u)?;
Ok(SignedAmount(s))
}
}
/// Calculates the sum over the iterator using checked arithmetic. /// Calculates the sum over the iterator using checked arithmetic.
pub trait CheckedSum<R>: private::SumSeal<R> { pub trait CheckedSum<R>: private::SumSeal<R> {
/// Calculates the sum over the iterator using checked arithmetic. If an over or underflow would /// Calculates the sum over the iterator using checked arithmetic. If an over or underflow would