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:
parent
baadcf4c0a
commit
b2344e019d
|
@ -1782,6 +1782,7 @@ mod tests {
|
||||||
// make sure satoshi > i64::MAX is checked.
|
// make sure satoshi > i64::MAX is checked.
|
||||||
let amount = Amount::from_sat(i64::MAX as u64);
|
let amount = Amount::from_sat(i64::MAX as u64);
|
||||||
assert_eq!(Amount::from_str_in(&amount.to_string_in(sat), sat), Ok(amount));
|
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!(Amount::from_str_in(&(amount + Amount(1)).to_string_in(sat), sat).is_ok());
|
||||||
|
|
||||||
assert_eq!(p("12.000", Denomination::MilliSatoshi), Err(E::TooPrecise));
|
assert_eq!(p("12.000", Denomination::MilliSatoshi), Err(E::TooPrecise));
|
||||||
|
|
Loading…
Reference in New Issue