diff --git a/lightning/src/offers/invoice_request.rs b/lightning/src/offers/invoice_request.rs index 3b7f0ed763e..1f62b2766e7 100644 --- a/lightning/src/offers/invoice_request.rs +++ b/lightning/src/offers/invoice_request.rs @@ -1721,6 +1721,24 @@ mod tests { Ok(_) => panic!("expected error"), Err(e) => assert_eq!(e, Bolt12SemanticError::InvalidAmount), } + + let invoice_request = OfferBuilder::new(recipient_pubkey()) + .amount(Amount::Currency {iso4217_code: *b"USD", amount: 1000}) + .build_unchecked() + .request_invoice(vec![1; 32], payer_pubkey()).unwrap() + .build().unwrap() + .sign(payer_sign).unwrap(); + assert_eq!(invoice_request.amount(), Some(Amount::Currency {iso4217_code: *b"USD", amount: 1000})); + + match OfferBuilder::new(recipient_pubkey()) + .amount(Amount::Currency {iso4217_code: *b"USD", amount: 100}) + .build_unchecked() + .request_invoice(vec![1; 32], payer_pubkey()) + .unwrap().amount_msats(150_000_000) + { + Ok(_) => panic!("expected error"), + Err(e) => assert_eq!(e, Bolt12SemanticError::UnsupportedCurrency), + } } #[test]