Pick one - MAX or MAX_MONEY
Just use MAX everywhere in this codebase. After discussion in PR consensus was to just use MAX throughout the codebase. ref: https://github.com/rust-bitcoin/rust-bitcoin/pull/4164#discussion_r1979441438
This commit is contained in:
parent
6d70c77cf9
commit
ac71680202
|
@ -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)
|
||||
|
|
|
@ -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`].
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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`].
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue