Skip to content

Commit fd426a0

Browse files
committed
Add missing UnknownRequiredFeatures tests
1 parent ce7a02d commit fd426a0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lightning/src/offers/invoice_request.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,22 @@ mod tests {
982982
}
983983
}
984984

985+
#[test]
986+
fn fails_responding_with_unknown_required_features() {
987+
match OfferBuilder::new("foo".into(), recipient_pubkey())
988+
.amount_msats(1000)
989+
.build().unwrap()
990+
.request_invoice(vec![42; 32], payer_pubkey()).unwrap()
991+
.features_unchecked(InvoiceRequestFeatures::unknown())
992+
.build().unwrap()
993+
.sign(payer_sign).unwrap()
994+
.respond_with_no_std(payment_paths(), payment_hash(), now())
995+
{
996+
Ok(_) => panic!("expected error"),
997+
Err(e) => assert_eq!(e, SemanticError::UnknownRequiredFeatures),
998+
}
999+
}
1000+
9851001
#[test]
9861002
fn parses_invoice_request_with_metadata() {
9871003
let invoice_request = OfferBuilder::new("foo".into(), recipient_pubkey())

lightning/src/offers/refund.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,18 @@ mod tests {
809809
assert_eq!(tlv_stream.payer_note, Some(&String::from("baz")));
810810
}
811811

812+
#[test]
813+
fn fails_responding_with_unknown_required_features() {
814+
match RefundBuilder::new("foo".into(), vec![1; 32], payer_pubkey(), 1000).unwrap()
815+
.features_unchecked(InvoiceRequestFeatures::unknown())
816+
.build().unwrap()
817+
.respond_with_no_std(payment_paths(), payment_hash(), recipient_pubkey(), now())
818+
{
819+
Ok(_) => panic!("expected error"),
820+
Err(e) => assert_eq!(e, SemanticError::UnknownRequiredFeatures),
821+
}
822+
}
823+
812824
#[test]
813825
fn parses_refund_with_metadata() {
814826
let refund = RefundBuilder::new("foo".into(), vec![1; 32], payer_pubkey(), 1000).unwrap()

0 commit comments

Comments
 (0)