From c98dff3f7efa54427882a59224a0c12d609524b8 Mon Sep 17 00:00:00 2001 From: yancy Date: Thu, 12 Dec 2024 10:29:07 -0600 Subject: [PATCH] Test types MIN/MAX instead of i64::MIN/i64::MAX 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. --- api/units/all-features.txt | 24 ++++++++++++------------ api/units/alloc-only.txt | 24 ++++++++++++------------ api/units/no-features.txt | 24 ++++++++++++------------ units/src/amount/tests.rs | 8 ++++---- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/api/units/all-features.txt b/api/units/all-features.txt index bb04d3c075..66adfa66c7 100644 --- a/api/units/all-features.txt +++ b/api/units/all-features.txt @@ -635,19 +635,19 @@ pub bitcoin_units::amount::ParseDenominationError::PossiblyConfusing(bitcoin_uni pub bitcoin_units::amount::ParseDenominationError::Unknown(bitcoin_units::amount::error::UnknownDenominationError) pub bitcoin_units::amount::error::ParseDenominationError::PossiblyConfusing(bitcoin_units::amount::error::PossiblyConfusingDenominationError) pub bitcoin_units::amount::error::ParseDenominationError::Unknown(bitcoin_units::amount::error::UnknownDenominationError) -pub const bitcoin_units::Amount::MAX: bitcoin_units::Amount -pub const bitcoin_units::Amount::MAX_MONEY: bitcoin_units::Amount -pub const bitcoin_units::Amount::MIN: bitcoin_units::Amount -pub const bitcoin_units::Amount::ONE_BTC: bitcoin_units::Amount -pub const bitcoin_units::Amount::ONE_SAT: bitcoin_units::Amount +pub const bitcoin_units::Amount::MAX: Self +pub const bitcoin_units::Amount::MAX_MONEY: Self +pub const bitcoin_units::Amount::MIN: Self +pub const bitcoin_units::Amount::ONE_BTC: Self +pub const bitcoin_units::Amount::ONE_SAT: Self pub const bitcoin_units::Amount::SIZE: usize -pub const bitcoin_units::Amount::ZERO: bitcoin_units::Amount -pub const bitcoin_units::SignedAmount::MAX: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::MAX_MONEY: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::MIN: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::ONE_BTC: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::ONE_SAT: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::ZERO: bitcoin_units::SignedAmount +pub const bitcoin_units::Amount::ZERO: Self +pub const bitcoin_units::SignedAmount::MAX: Self +pub const bitcoin_units::SignedAmount::MAX_MONEY: Self +pub const bitcoin_units::SignedAmount::MIN: Self +pub const bitcoin_units::SignedAmount::ONE_BTC: Self +pub const bitcoin_units::SignedAmount::ONE_SAT: Self +pub const bitcoin_units::SignedAmount::ZERO: Self pub const bitcoin_units::amount::Denomination::BTC: Self pub const bitcoin_units::amount::Denomination::SAT: Self pub const bitcoin_units::block::BlockHeight::MAX: Self diff --git a/api/units/alloc-only.txt b/api/units/alloc-only.txt index da91d6a062..79fbedd91c 100644 --- a/api/units/alloc-only.txt +++ b/api/units/alloc-only.txt @@ -593,19 +593,19 @@ pub bitcoin_units::amount::ParseDenominationError::PossiblyConfusing(bitcoin_uni pub bitcoin_units::amount::ParseDenominationError::Unknown(bitcoin_units::amount::error::UnknownDenominationError) pub bitcoin_units::amount::error::ParseDenominationError::PossiblyConfusing(bitcoin_units::amount::error::PossiblyConfusingDenominationError) pub bitcoin_units::amount::error::ParseDenominationError::Unknown(bitcoin_units::amount::error::UnknownDenominationError) -pub const bitcoin_units::Amount::MAX: bitcoin_units::Amount -pub const bitcoin_units::Amount::MAX_MONEY: bitcoin_units::Amount -pub const bitcoin_units::Amount::MIN: bitcoin_units::Amount -pub const bitcoin_units::Amount::ONE_BTC: bitcoin_units::Amount -pub const bitcoin_units::Amount::ONE_SAT: bitcoin_units::Amount +pub const bitcoin_units::Amount::MAX: Self +pub const bitcoin_units::Amount::MAX_MONEY: Self +pub const bitcoin_units::Amount::MIN: Self +pub const bitcoin_units::Amount::ONE_BTC: Self +pub const bitcoin_units::Amount::ONE_SAT: Self pub const bitcoin_units::Amount::SIZE: usize -pub const bitcoin_units::Amount::ZERO: bitcoin_units::Amount -pub const bitcoin_units::SignedAmount::MAX: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::MAX_MONEY: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::MIN: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::ONE_BTC: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::ONE_SAT: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::ZERO: bitcoin_units::SignedAmount +pub const bitcoin_units::Amount::ZERO: Self +pub const bitcoin_units::SignedAmount::MAX: Self +pub const bitcoin_units::SignedAmount::MAX_MONEY: Self +pub const bitcoin_units::SignedAmount::MIN: Self +pub const bitcoin_units::SignedAmount::ONE_BTC: Self +pub const bitcoin_units::SignedAmount::ONE_SAT: Self +pub const bitcoin_units::SignedAmount::ZERO: Self pub const bitcoin_units::amount::Denomination::BTC: Self pub const bitcoin_units::amount::Denomination::SAT: Self pub const bitcoin_units::block::BlockHeight::MAX: Self diff --git a/api/units/no-features.txt b/api/units/no-features.txt index e055093b7b..e4244c9d1e 100644 --- a/api/units/no-features.txt +++ b/api/units/no-features.txt @@ -577,19 +577,19 @@ pub bitcoin_units::amount::ParseDenominationError::PossiblyConfusing(bitcoin_uni pub bitcoin_units::amount::ParseDenominationError::Unknown(bitcoin_units::amount::error::UnknownDenominationError) pub bitcoin_units::amount::error::ParseDenominationError::PossiblyConfusing(bitcoin_units::amount::error::PossiblyConfusingDenominationError) pub bitcoin_units::amount::error::ParseDenominationError::Unknown(bitcoin_units::amount::error::UnknownDenominationError) -pub const bitcoin_units::Amount::MAX: bitcoin_units::Amount -pub const bitcoin_units::Amount::MAX_MONEY: bitcoin_units::Amount -pub const bitcoin_units::Amount::MIN: bitcoin_units::Amount -pub const bitcoin_units::Amount::ONE_BTC: bitcoin_units::Amount -pub const bitcoin_units::Amount::ONE_SAT: bitcoin_units::Amount +pub const bitcoin_units::Amount::MAX: Self +pub const bitcoin_units::Amount::MAX_MONEY: Self +pub const bitcoin_units::Amount::MIN: Self +pub const bitcoin_units::Amount::ONE_BTC: Self +pub const bitcoin_units::Amount::ONE_SAT: Self pub const bitcoin_units::Amount::SIZE: usize -pub const bitcoin_units::Amount::ZERO: bitcoin_units::Amount -pub const bitcoin_units::SignedAmount::MAX: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::MAX_MONEY: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::MIN: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::ONE_BTC: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::ONE_SAT: bitcoin_units::SignedAmount -pub const bitcoin_units::SignedAmount::ZERO: bitcoin_units::SignedAmount +pub const bitcoin_units::Amount::ZERO: Self +pub const bitcoin_units::SignedAmount::MAX: Self +pub const bitcoin_units::SignedAmount::MAX_MONEY: Self +pub const bitcoin_units::SignedAmount::MIN: Self +pub const bitcoin_units::SignedAmount::ONE_BTC: Self +pub const bitcoin_units::SignedAmount::ONE_SAT: Self +pub const bitcoin_units::SignedAmount::ZERO: Self pub const bitcoin_units::amount::Denomination::BTC: Self pub const bitcoin_units::amount::Denomination::SAT: Self pub const bitcoin_units::block::BlockHeight::MAX: Self diff --git a/units/src/amount/tests.rs b/units/src/amount/tests.rs index ca2774750e..c97f541e50 100644 --- a/units/src/amount/tests.rs +++ b/units/src/amount/tests.rs @@ -624,12 +624,12 @@ fn to_from_string_in() { assert_eq!(sa_str(&sa_sat(-1).to_string_in(D::MicroBitcoin), D::MicroBitcoin), Ok(sa_sat(-1))); 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()) ); // Test an overflow bug in `abs()` 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()) ); } @@ -903,12 +903,12 @@ fn checked_sum_amounts() { assert_eq!(None, sum); 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(); assert_eq!(None, sum); 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(); assert_eq!(None, sum);