diff --git a/bitcoin/tests/serde.rs b/bitcoin/tests/serde.rs index 807f838a6..dff93b0c5 100644 --- a/bitcoin/tests/serde.rs +++ b/bitcoin/tests/serde.rs @@ -110,7 +110,7 @@ fn serde_regression_txin() { #[test] fn serde_regression_txout() { let txout = - TxOut { value: Amount::MAX_MONEY, script_pubkey: ScriptBuf::from(vec![0u8, 1u8, 2u8]) }; + TxOut { value: Amount::MAX, script_pubkey: ScriptBuf::from(vec![0u8, 1u8, 2u8]) }; let got = serialize(&txout).unwrap(); let want = include_bytes!("data/serde/txout_bincode") as &[_]; assert_eq!(got, want) diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs index 5e5b4c5a2..bdabfefde 100644 --- a/units/src/amount/signed.rs +++ b/units/src/amount/signed.rs @@ -54,7 +54,7 @@ mod encapsulate { /// /// Caller to guarantee that `satoshi` is within valid range. /// - /// See [`Self::MIN`] and [`Self::MAX_MONEY`]. + /// See [`Self::MIN`] and [`Self::MAX`]. pub const fn from_sat_unchecked(satoshi: i64) -> SignedAmount { SignedAmount(satoshi) } /// Gets the number of satoshis in this [`SignedAmount`]. diff --git a/units/src/amount/tests.rs b/units/src/amount/tests.rs index af41eaf62..a692ca650 100644 --- a/units/src/amount/tests.rs +++ b/units/src/amount/tests.rs @@ -725,15 +725,28 @@ fn to_from_string_in() { assert_eq!(ua_str(&ua_sat(21_000_000).to_string_in(D::Bit), D::Bit), Ok(ua_sat(21_000_000))); assert_eq!(ua_str(&ua_sat(0).to_string_in(D::Satoshi), D::Satoshi), Ok(ua_sat(0))); - assert!(ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::Bitcoin), D::Bitcoin).is_ok()); - assert!(ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::CentiBitcoin), D::CentiBitcoin) - .is_ok()); - assert!(ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::MilliBitcoin), D::MilliBitcoin) - .is_ok()); - assert!(ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::MicroBitcoin), D::MicroBitcoin) - .is_ok()); + assert!( + ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::Bitcoin), D::Bitcoin).is_ok() + ); + assert!(ua_str( + &ua_sat(Amount::MAX.to_sat()).to_string_in(D::CentiBitcoin), + D::CentiBitcoin + ) + .is_ok()); + assert!(ua_str( + &ua_sat(Amount::MAX.to_sat()).to_string_in(D::MilliBitcoin), + D::MilliBitcoin + ) + .is_ok()); + assert!(ua_str( + &ua_sat(Amount::MAX.to_sat()).to_string_in(D::MicroBitcoin), + D::MicroBitcoin + ) + .is_ok()); assert!(ua_str(&ua_sat(Amount::MAX.to_sat()).to_string_in(D::Bit), D::Bit).is_ok()); - 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!( sa_str(&SignedAmount::MAX.to_string_in(D::Satoshi), D::MicroBitcoin), @@ -1276,7 +1289,7 @@ fn check_const() { assert_eq!(Amount::ONE_BTC.to_sat(), 100_000_000); assert_eq!(SignedAmount::FIFTY_BTC.to_sat(), SignedAmount::ONE_BTC.to_sat() * 50); assert_eq!(Amount::FIFTY_BTC.to_sat(), Amount::ONE_BTC.to_sat() * 50); - assert_eq!(Amount::MAX_MONEY.to_sat() as i64, SignedAmount::MAX_MONEY.to_sat()); + assert_eq!(Amount::MAX.to_sat() as i64, SignedAmount::MAX.to_sat()); } // Sanity check than stdlib supports the set of reference combinations for the ops we want. diff --git a/units/src/amount/unsigned.rs b/units/src/amount/unsigned.rs index ae9c3f5c2..27435fba0 100644 --- a/units/src/amount/unsigned.rs +++ b/units/src/amount/unsigned.rs @@ -52,7 +52,7 @@ mod encapsulate { impl Amount { /// Constructs a new [`Amount`] with satoshi precision and the given number of satoshis. /// - /// Caller to guarantee that `satoshi` is within valid range. See [`Self::MAX_MONEY`]. + /// Caller to guarantee that `satoshi` is within valid range. See [`Self::MAX`]. pub const fn from_sat_unchecked(satoshi: u64) -> Amount { Self(satoshi) } /// Gets the number of satoshis in this [`Amount`]. diff --git a/units/tests/str.rs b/units/tests/str.rs index 89068bf9b..0b365af20 100644 --- a/units/tests/str.rs +++ b/units/tests/str.rs @@ -22,10 +22,10 @@ macro_rules! check { check! { amount_unsigned_one_sat, Amount, Amount::ONE_SAT, "0.00000001 BTC"; - amount_unsigned_max_money, Amount, Amount::MAX_MONEY, "21000000 BTC"; + amount_unsigned_max_money, Amount, Amount::MAX, "21000000 BTC"; amount_signed_one_sat, SignedAmount, SignedAmount::ONE_SAT, "0.00000001 BTC"; - amount_signed_max_money, SignedAmount, SignedAmount::MAX_MONEY, "21000000 BTC"; + amount_signed_max_money, SignedAmount, SignedAmount::MAX, "21000000 BTC"; block_height_min, BlockHeight, BlockHeight::MIN, "0"; block_height_max, BlockHeight, BlockHeight::MAX, "4294967295";