Skip to content

Commit 82b85c1

Browse files
committed
Check PaymentKind explicitly in full_cycle tests
1 parent d57f67f commit 82b85c1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/common/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![allow(dead_code)]
33

44
use ldk_node::io::sqlite_store::SqliteStore;
5-
use ldk_node::payment::{PaymentDirection, PaymentStatus};
5+
use ldk_node::payment::{PaymentDirection, PaymentKind, PaymentStatus};
66
use ldk_node::{Builder, Config, Event, LogLevel, Node, NodeError};
77

88
use lightning::ln::msgs::SocketAddress;
@@ -447,9 +447,11 @@ pub(crate) fn do_channel_full_cycle<E: ElectrumApi>(
447447
assert_eq!(node_a.payment(&payment_id).unwrap().status, PaymentStatus::Succeeded);
448448
assert_eq!(node_a.payment(&payment_id).unwrap().direction, PaymentDirection::Outbound);
449449
assert_eq!(node_a.payment(&payment_id).unwrap().amount_msat, Some(invoice_amount_1_msat));
450+
assert!(matches!(node_a.payment(&payment_id).unwrap().kind, PaymentKind::Bolt11 { .. }));
450451
assert_eq!(node_b.payment(&payment_id).unwrap().status, PaymentStatus::Succeeded);
451452
assert_eq!(node_b.payment(&payment_id).unwrap().direction, PaymentDirection::Inbound);
452453
assert_eq!(node_b.payment(&payment_id).unwrap().amount_msat, Some(invoice_amount_1_msat));
454+
assert!(matches!(node_b.payment(&payment_id).unwrap().kind, PaymentKind::Bolt11 { .. }));
453455

454456
// Assert we fail duplicate outbound payments and check the status hasn't changed.
455457
assert_eq!(Err(NodeError::DuplicatePayment), node_a.bolt11_payment().send(&invoice));
@@ -492,9 +494,11 @@ pub(crate) fn do_channel_full_cycle<E: ElectrumApi>(
492494
assert_eq!(node_a.payment(&payment_id).unwrap().status, PaymentStatus::Succeeded);
493495
assert_eq!(node_a.payment(&payment_id).unwrap().direction, PaymentDirection::Outbound);
494496
assert_eq!(node_a.payment(&payment_id).unwrap().amount_msat, Some(overpaid_amount_msat));
497+
assert!(matches!(node_a.payment(&payment_id).unwrap().kind, PaymentKind::Bolt11 { .. }));
495498
assert_eq!(node_b.payment(&payment_id).unwrap().status, PaymentStatus::Succeeded);
496499
assert_eq!(node_b.payment(&payment_id).unwrap().direction, PaymentDirection::Inbound);
497500
assert_eq!(node_b.payment(&payment_id).unwrap().amount_msat, Some(overpaid_amount_msat));
501+
assert!(matches!(node_b.payment(&payment_id).unwrap().kind, PaymentKind::Bolt11 { .. }));
498502

499503
// Test "zero-amount" invoice payment
500504
println!("\nB receive_variable_amount_payment");
@@ -526,9 +530,11 @@ pub(crate) fn do_channel_full_cycle<E: ElectrumApi>(
526530
assert_eq!(node_a.payment(&payment_id).unwrap().status, PaymentStatus::Succeeded);
527531
assert_eq!(node_a.payment(&payment_id).unwrap().direction, PaymentDirection::Outbound);
528532
assert_eq!(node_a.payment(&payment_id).unwrap().amount_msat, Some(determined_amount_msat));
533+
assert!(matches!(node_a.payment(&payment_id).unwrap().kind, PaymentKind::Bolt11 { .. }));
529534
assert_eq!(node_b.payment(&payment_id).unwrap().status, PaymentStatus::Succeeded);
530535
assert_eq!(node_b.payment(&payment_id).unwrap().direction, PaymentDirection::Inbound);
531536
assert_eq!(node_b.payment(&payment_id).unwrap().amount_msat, Some(determined_amount_msat));
537+
assert!(matches!(node_b.payment(&payment_id).unwrap().kind, PaymentKind::Bolt11 { .. }));
532538

533539
// Test spontaneous/keysend payments
534540
println!("\nA send_spontaneous_payment");
@@ -550,9 +556,19 @@ pub(crate) fn do_channel_full_cycle<E: ElectrumApi>(
550556
assert_eq!(node_a.payment(&keysend_payment_id).unwrap().status, PaymentStatus::Succeeded);
551557
assert_eq!(node_a.payment(&keysend_payment_id).unwrap().direction, PaymentDirection::Outbound);
552558
assert_eq!(node_a.payment(&keysend_payment_id).unwrap().amount_msat, Some(keysend_amount_msat));
559+
assert!(matches!(
560+
node_a.payment(&keysend_payment_id).unwrap().kind,
561+
PaymentKind::Spontaneous { .. }
562+
));
553563
assert_eq!(node_b.payment(&keysend_payment_id).unwrap().status, PaymentStatus::Succeeded);
554564
assert_eq!(node_b.payment(&keysend_payment_id).unwrap().direction, PaymentDirection::Inbound);
555565
assert_eq!(node_b.payment(&keysend_payment_id).unwrap().amount_msat, Some(keysend_amount_msat));
566+
assert!(matches!(
567+
node_b.payment(&keysend_payment_id).unwrap().kind,
568+
PaymentKind::Spontaneous { .. }
569+
));
570+
assert_eq!(node_a.list_payments().len(), 4);
571+
assert_eq!(node_b.list_payments().len(), 5);
556572

557573
println!("\nB close_channel");
558574
node_b.close_channel(&user_channel_id, node_a.node_id()).unwrap();

0 commit comments

Comments
 (0)