Skip to content

Commit

Permalink
Test types MIN/MAX instead of i64::MIN/i64::MAX
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yancyribbens committed Dec 15, 2024
1 parent c40e251 commit c98dff3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
24 changes: 12 additions & 12 deletions api/units/all-features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions api/units/alloc-only.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions api/units/no-features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions units/src/amount/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
);
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit c98dff3

Please sign in to comment.