Merge rust-bitcoin/rust-bitcoin#3757: Test types MIN/MAX instead of i64::MIN/i64::MAX

f08d8741d3 Test types MIN/MAX instead of i64::MIN/i64::MAX (yancy)

Pull request description:

  The MIN/MAX for SignedAmount recently changed from i64::MIN and i64::MAX to MAX_MONEY/MIN_MONEY.  Update the tests to reflect this new MIN/MAX since it is no longer valid to create a value above or bellow MAX_MONEY/MIN_MONEY.

ACKs for top commit:
  apoelstra:
    ACK f08d8741d39685b636830680bb891bd414826e88; successfully ran local tests
  tcharding:
    ACK f08d8741d3

Tree-SHA512: 563408240dffaf95f88a9d570e56f9b9b161b422cb59a89828c18b9c784e7acb717f57fe55c80411f104443ac2a3f908f2a98ab1a4b34edab69b6946a723b30c
This commit is contained in:
merge-script 2024-12-18 14:35:37 +00:00
commit ebe43b6f87
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 4 additions and 5 deletions

View File

@ -570,7 +570,6 @@ fn to_from_string_in() {
let ua_str = Amount::from_str_in; let ua_str = Amount::from_str_in;
let ua_sat = Amount::from_sat; let ua_sat = Amount::from_sat;
let sa_str = SignedAmount::from_str_in; let sa_str = SignedAmount::from_str_in;
let sa_sat = SignedAmount::from_sat;
assert_eq!("0.5", Amount::from_sat(50).to_string_in(D::Bit)); assert_eq!("0.5", Amount::from_sat(50).to_string_in(D::Bit));
assert_eq!("-0.5", SignedAmount::from_sat(-50).to_string_in(D::Bit)); assert_eq!("-0.5", SignedAmount::from_sat(-50).to_string_in(D::Bit));
@ -629,12 +628,12 @@ fn to_from_string_in() {
assert!(ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::Satoshi), D::Satoshi).is_ok()); assert!(ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::Satoshi), D::Satoshi).is_ok());
assert_eq!( assert_eq!(
sa_str(&sa_sat(i64::MAX).to_string_in(D::Satoshi), D::MicroBitcoin), sa_str(&SignedAmount::MAX.to_string_in(D::Satoshi), D::MicroBitcoin),
Err(OutOfRangeError::too_big(true).into()) Err(OutOfRangeError::too_big(true).into())
); );
// Test an overflow bug in `abs()` // Test an overflow bug in `abs()`
assert_eq!( assert_eq!(
sa_str(&sa_sat(i64::MIN).to_string_in(D::Satoshi), D::MicroBitcoin), sa_str(&SignedAmount::MIN.to_string_in(D::Satoshi), D::MicroBitcoin),
Err(OutOfRangeError::too_small().into()) Err(OutOfRangeError::too_small().into())
); );
} }
@ -909,12 +908,12 @@ fn checked_sum_amounts() {
assert_eq!(None, sum); assert_eq!(None, sum);
let amounts = let amounts =
[SignedAmount::from_sat(i64::MIN), SignedAmount::from_sat(-1), SignedAmount::from_sat(21)]; [SignedAmount::MIN, SignedAmount::from_sat(-1), SignedAmount::from_sat(21)];
let sum = amounts.into_iter().checked_sum(); let sum = amounts.into_iter().checked_sum();
assert_eq!(None, sum); assert_eq!(None, sum);
let amounts = let amounts =
[SignedAmount::from_sat(i64::MAX), SignedAmount::from_sat(1), SignedAmount::from_sat(21)]; [SignedAmount::MAX, SignedAmount::from_sat(1), SignedAmount::from_sat(21)];
let sum = amounts.into_iter().checked_sum(); let sum = amounts.into_iter().checked_sum();
assert_eq!(None, sum); assert_eq!(None, sum);