From 6c6a89b1d13fa2a5200318c943404d2bf673d94a Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Sun, 7 May 2023 08:47:53 +0200 Subject: [PATCH] Add sub-sat fractions parsing regression test This test triggers the bug fixed in previous commit. --- bitcoin/src/amount.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bitcoin/src/amount.rs b/bitcoin/src/amount.rs index 80dc06ea..4bb62d92 100644 --- a/bitcoin/src/amount.rs +++ b/bitcoin/src/amount.rs @@ -1684,6 +1684,8 @@ mod tests { p("12345678901.12345678", btc), Ok(Amount::from_sat(12_345_678_901__123_456_78)) ); + assert_eq!(p("1000.0", msat), Ok(Amount::from_sat(1))); + assert_eq!(p("1000.000000000000000000000000000", msat), Ok(Amount::from_sat(1))); // make sure satoshi > i64::max_value() is checked. let amount = Amount::from_sat(i64::max_value() as u64);