| 488 | |
| 489 | #[test] |
| 490 | fn test_amount_all_any() { |
| 491 | let t = r#"{"any": "any", "all": "all", "not_any": "42msat", "not_all": "31337msat"}"#; |
| 492 | |
| 493 | #[derive(Serialize, Deserialize, Debug, PartialEq)] |
| 494 | struct T { |
| 495 | all: AmountOrAll, |
| 496 | not_all: AmountOrAll, |
| 497 | any: AmountOrAny, |
| 498 | not_any: AmountOrAny, |
| 499 | } |
| 500 | |
| 501 | let parsed: T = serde_json::from_str(t).unwrap(); |
| 502 | |
| 503 | let expected = T { |
| 504 | all: AmountOrAll::All, |
| 505 | any: AmountOrAny::Any, |
| 506 | not_all: AmountOrAll::Amount(Amount { msat: 31337 }), |
| 507 | not_any: AmountOrAny::Amount(Amount { msat: 42 }), |
| 508 | }; |
| 509 | assert_eq!(expected, parsed); |
| 510 | |
| 511 | let serialized: String = serde_json::to_string(&parsed).unwrap(); |
| 512 | assert_eq!( |
| 513 | serialized, |
| 514 | r#"{"all":"all","not_all":"31337msat","any":"any","not_any":"42msat"}"# |
| 515 | ); |
| 516 | } |
| 517 | |
| 518 | #[test] |
| 519 | fn test_parse_feerate() { |