From 9c90bf49c937409af34c0a563fb198d3f3494d37 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Wed, 30 Apr 2025 17:10:24 +0100 Subject: [PATCH] Add lock by time and denomination display regression tests The existing display regression tests only tested height locktimes. Denomination display regression and round trip were not tested. Add tests for time locktimes and denomination. --- units/tests/str.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/units/tests/str.rs b/units/tests/str.rs index 767ed6a9f..98e06f72e 100644 --- a/units/tests/str.rs +++ b/units/tests/str.rs @@ -3,6 +3,7 @@ //! Do basic regression tests on the `Display` and `FromStr` impls. use bitcoin_units::locktime::{absolute, relative}; +use bitcoin_units::amount::Denomination; use bitcoin_units::{Amount, BlockHeight, BlockInterval, FeeRate, SignedAmount, Weight}; macro_rules! check { @@ -24,6 +25,9 @@ check! { amount_unsigned_one_sat, Amount, Amount::ONE_SAT, "0.00000001 BTC"; amount_unsigned_max_money, Amount, Amount::MAX, "21000000 BTC"; + denomination_btc, Denomination, Denomination::BTC, "BTC"; + denomination_sat, Denomination, Denomination::SAT, "satoshi"; + amount_signed_one_sat, SignedAmount, SignedAmount::ONE_SAT, "0.00000001 BTC"; amount_signed_max_money, SignedAmount, SignedAmount::MAX, "21000000 BTC"; @@ -43,6 +47,12 @@ check! { lock_by_height_relative_min, relative::Height, relative::Height::MIN, "0"; lock_by_height_relative_max, relative::Height, relative::Height::MAX, "65535"; + lock_by_time_absolute_min, absolute::Time, absolute::Time::MIN, "500000000"; + lock_by_time_absolute_max, absolute::Time, absolute::Time::MAX, "4294967295"; + + lock_by_time_relative_min, relative::Time, relative::Time::MIN, "0"; + lock_by_time_relative_max, relative::Time, relative::Time::MAX, "65535"; + weight_min, Weight, Weight::MIN, "0"; weight_max, Weight, Weight::MAX, "18446744073709551615"; weight_max_block, Weight, Weight::MAX_BLOCK, "4000000";