Skip to content

Commit 56d65c2

Browse files
committed
Test removing abandoned AwaitingInvoice payments
1 parent 4f43627 commit 56d65c2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lightning/src/ln/outbound_payment.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,4 +1807,26 @@ mod tests {
18071807

18081808
assert!(outbound_payments.add_new_awaiting_invoice(payment_id).is_err());
18091809
}
1810+
1811+
#[test]
1812+
fn removes_abandoned_awaiting_invoice() {
1813+
let pending_events = Mutex::new(VecDeque::new());
1814+
let outbound_payments = OutboundPayments::new();
1815+
let payment_id = PaymentId([0; 32]);
1816+
1817+
assert!(!outbound_payments.has_pending_payments());
1818+
assert!(outbound_payments.add_new_awaiting_invoice(payment_id).is_ok());
1819+
assert!(outbound_payments.has_pending_payments());
1820+
1821+
outbound_payments.abandon_payment(
1822+
payment_id, PaymentFailureReason::UserAbandoned, &pending_events
1823+
);
1824+
assert!(!outbound_payments.has_pending_payments());
1825+
assert!(!pending_events.lock().unwrap().is_empty());
1826+
assert_eq!(
1827+
pending_events.lock().unwrap().pop_front(),
1828+
Some((Event::InvoiceRequestFailed { payment_id }, None)),
1829+
);
1830+
assert!(pending_events.lock().unwrap().is_empty());
1831+
}
18101832
}

0 commit comments

Comments
 (0)