]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add missing UnknownRequiredFeatures tests
authorJeffrey Czyz <jkczyz@gmail.com>
Mon, 6 Feb 2023 18:55:54 +0000 (12:55 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Tue, 18 Apr 2023 18:30:32 +0000 (13:30 -0500)
lightning/src/offers/invoice_request.rs
lightning/src/offers/refund.rs

index 8364814ede3061f460192572bb282aaa27da5c23..db540ce62ff1e84a316ee0927b3e61711d82b632 100644 (file)
@@ -982,6 +982,22 @@ mod tests {
                }
        }
 
+       #[test]
+       fn fails_responding_with_unknown_required_features() {
+               match OfferBuilder::new("foo".into(), recipient_pubkey())
+                       .amount_msats(1000)
+                       .build().unwrap()
+                       .request_invoice(vec![42; 32], payer_pubkey()).unwrap()
+                       .features_unchecked(InvoiceRequestFeatures::unknown())
+                       .build().unwrap()
+                       .sign(payer_sign).unwrap()
+                       .respond_with_no_std(payment_paths(), payment_hash(), now())
+               {
+                       Ok(_) => panic!("expected error"),
+                       Err(e) => assert_eq!(e, SemanticError::UnknownRequiredFeatures),
+               }
+       }
+
        #[test]
        fn parses_invoice_request_with_metadata() {
                let invoice_request = OfferBuilder::new("foo".into(), recipient_pubkey())
index 51cfebed4a8ae87b06e14ce0cd4afe08a4afbe58..9eda6ecd50c673e104b5c224beb59c1b5714d685 100644 (file)
@@ -809,6 +809,18 @@ mod tests {
                assert_eq!(tlv_stream.payer_note, Some(&String::from("baz")));
        }
 
+       #[test]
+       fn fails_responding_with_unknown_required_features() {
+               match RefundBuilder::new("foo".into(), vec![1; 32], payer_pubkey(), 1000).unwrap()
+                       .features_unchecked(InvoiceRequestFeatures::unknown())
+                       .build().unwrap()
+                       .respond_with_no_std(payment_paths(), payment_hash(), recipient_pubkey(), now())
+               {
+                       Ok(_) => panic!("expected error"),
+                       Err(e) => assert_eq!(e, SemanticError::UnknownRequiredFeatures),
+               }
+       }
+
        #[test]
        fn parses_refund_with_metadata() {
                let refund = RefundBuilder::new("foo".into(), vec![1; 32], payer_pubkey(), 1000).unwrap()