Skip to content

Commit 4442e83

Browse files
tests: update bolt12_proof_of_payment test for enum pattern
This patch updates the bolt12_proof_of_payment test to use pattern matching on the new PaidBolt12Invoice enum instead of checking the kind field and accessing optional invoice fields. Problem: The test was using the old struct-based API with .kind field and .bolt12_invoice.as_ref(), which no longer exists after converting PaidBolt12Invoice to an enum. Solution: Use Rust pattern matching on the PaidBolt12Invoice enum to extract the invoice directly from the variant, which is more idiomatic and takes advantage of the type system. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 32ce6bc commit 4442e83

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/integration_tests_rust.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use ldk_node::config::{AsyncPaymentsRole, EsploraSyncConfig};
3030
use ldk_node::entropy::NodeEntropy;
3131
use ldk_node::liquidity::LSPS2ServiceConfig;
3232
use ldk_node::payment::{
33-
ConfirmationStatus, PaidBolt12InvoiceKind, PaymentDetails, PaymentDirection, PaymentKind,
33+
ConfirmationStatus, PaidBolt12Invoice, PaymentDetails, PaymentDirection, PaymentKind,
3434
PaymentStatus, UnifiedPaymentResult,
3535
};
3636
use ldk_node::{Builder, Event, NodeError};
@@ -1367,11 +1367,15 @@ async fn bolt12_proof_of_payment() {
13671367
// Verify the BOLT12 invoice is present and contains the correct payment hash
13681368
let paid_invoice =
13691369
bolt12_invoice.expect("bolt12_invoice should be present for BOLT12 payments");
1370-
assert_eq!(paid_invoice.kind, PaidBolt12InvoiceKind::Bolt12Invoice);
1371-
let invoice =
1372-
paid_invoice.bolt12_invoice.as_ref().expect("bolt12_invoice should be present");
1373-
assert_eq!(invoice.payment_hash(), payment_hash);
1374-
assert_eq!(invoice.amount_msats(), expected_amount_msat);
1370+
match paid_invoice {
1371+
PaidBolt12Invoice::Bolt12Invoice(invoice) => {
1372+
assert_eq!(invoice.payment_hash(), payment_hash);
1373+
assert_eq!(invoice.amount_msats(), expected_amount_msat);
1374+
},
1375+
PaidBolt12Invoice::StaticInvoice(_) => {
1376+
panic!("Expected Bolt12Invoice, got StaticInvoice");
1377+
},
1378+
}
13751379

13761380
node_a.event_handled().unwrap();
13771381
},

0 commit comments

Comments
 (0)