Skip to content

Commit eb04f3e

Browse files
test: add test for self payment
1 parent 3d13a83 commit eb04f3e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lightning/src/ln/payment_tests.rs

+23
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,29 @@ fn preflight_probes_yield_event_and_skip() {
15201520
assert!(!nodes[0].node.has_pending_payments());
15211521
}
15221522

1523+
#[test]
1524+
fn test_self_payment() {
1525+
let chanmon_cfg = create_chanmon_cfgs(1);
1526+
let node_cfg = create_node_cfgs(1, &chanmon_cfg);
1527+
let node_chanmgr = create_node_chanmgrs(1, &node_cfg, &[None, None]);
1528+
let nodes = create_network(1, &node_cfg, &node_chanmgr);
1529+
let (payment_hash, payment_secret) = nodes[0].node.create_inbound_payment(Some(1000), 60, None).unwrap();
1530+
let payment_params = PaymentParameters::from_node_id(nodes[0].node.get_our_node_id(), TEST_FINAL_CLTV);
1531+
let route_params = RouteParameters {
1532+
payment_params,
1533+
final_value_msat: 100000,
1534+
};
1535+
let res = nodes[0].node.send_payment(payment_hash, RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0), route_params, Retry::Attempts(0));
1536+
assert!(res.is_ok());
1537+
let events = nodes[0].node.get_and_clear_pending_events();
1538+
assert_eq!(events.len(), 2);
1539+
matches!(events[0], Event::PaymentSent { .. });
1540+
matches!(events[1], Event::PaymentClaimable { .. });
1541+
let pending_payments = nodes[0].node.list_recent_payments();
1542+
assert_eq!(pending_payments.len(), 1);
1543+
matches!(pending_payments[0], RecentPaymentDetails::Fulfilled { .. });
1544+
}
1545+
15231546
#[test]
15241547
fn claimed_send_payment_idempotent() {
15251548
// Tests that `send_payment` (and friends) are (reasonably) idempotent.

0 commit comments

Comments
 (0)