From fd4239f1d2c86c26f521b351afd9a5863cb9c82b Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 23 Jun 2022 13:54:34 +1000 Subject: [PATCH] Use custom digit grouping clippy emits a bunch of: warning: digits grouped inconsistently by underscores We have a custom grouping elsewhere in this file 10_000_000_00 sats == 10 BTC Fix up all instances of large sats amount to uniformly using this format and add compiler directives where needed to shoosh clippy. --- src/util/amount.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/util/amount.rs b/src/util/amount.rs index e2eff86b..8ca6a164 100644 --- a/src/util/amount.rs +++ b/src/util/amount.rs @@ -1622,9 +1622,9 @@ mod tests { assert_eq!(p("1.1", btc), Ok(Amount::from_sat(1_100_000_00))); assert_eq!(p("100", sat), Ok(Amount::from_sat(100))); assert_eq!(p("55", sat), Ok(Amount::from_sat(55))); - assert_eq!(p("5500000000000000000", sat), Ok(Amount::from_sat(5_500_000_000_000_000_000))); + assert_eq!(p("5500000000000000000", sat), Ok(Amount::from_sat(55_000_000_000_000_000_00))); // Should this even pass? - assert_eq!(p("5500000000000000000.", sat), Ok(Amount::from_sat(5_500_000_000_000_000_000))); + assert_eq!(p("5500000000000000000.", sat), Ok(Amount::from_sat(55_000_000_000_000_000_00))); assert_eq!( p("12345678901.12345678", btc), Ok(Amount::from_sat(12_345_678_901__123_456_78)) @@ -2006,6 +2006,7 @@ mod tests { #[cfg(feature = "serde")] #[test] + #[allow(clippy::inconsistent_digit_grouping)] // Group to show 100,000,000 sats per bitcoin. fn serde_as_btc() { use serde_json; @@ -2041,6 +2042,7 @@ mod tests { #[cfg(feature = "serde")] #[test] + #[allow(clippy::inconsistent_digit_grouping)] // Group to show 100,000,000 sats per bitcoin. fn serde_as_btc_opt() { use serde_json; @@ -2054,8 +2056,8 @@ mod tests { } let with = T { - amt: Some(Amount::from_sat(2__500_000_00)), - samt: Some(SignedAmount::from_sat(-2__500_000_00)), + amt: Some(Amount::from_sat(2_500_000_00)), + samt: Some(SignedAmount::from_sat(-2_500_000_00)), }; let without = T { amt: None, @@ -2085,6 +2087,7 @@ mod tests { #[cfg(feature = "serde")] #[test] + #[allow(clippy::inconsistent_digit_grouping)] // Group to show 100,000,000 sats per bitcoin. fn serde_as_sat_opt() { use serde_json; @@ -2098,8 +2101,8 @@ mod tests { } let with = T { - amt: Some(Amount::from_sat(2__500_000_00)), - samt: Some(SignedAmount::from_sat(-2__500_000_00)), + amt: Some(Amount::from_sat(2_500_000_00)), + samt: Some(SignedAmount::from_sat(-2_500_000_00)), }; let without = T { amt: None,