units: Assert roundtrip SignedAmount/str overflows

Add a unit test to prove that attempting to roundtrip a `SignedAmount`
greater than `MAX` through a string fails.
This commit is contained in:
Tobin C. Harding 2024-01-22 09:14:26 +11:00
parent baadcf4c0a
commit b2344e019d
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 1 additions and 0 deletions

View File

@ -1782,6 +1782,7 @@ mod tests {
// make sure satoshi > i64::MAX is checked.
let amount = Amount::from_sat(i64::MAX as u64);
assert_eq!(Amount::from_str_in(&amount.to_string_in(sat), sat), Ok(amount));
assert!(SignedAmount::from_str_in(&(amount + Amount(1)).to_string_in(sat), sat).is_err());
assert!(Amount::from_str_in(&(amount + Amount(1)).to_string_in(sat), sat).is_ok());
assert_eq!(p("12.000", Denomination::MilliSatoshi), Err(E::TooPrecise));