Skip to content

Commit cbeaeb7

Browse files
committed
Test removing abandoned AwaitingInvoice payments
1 parent fe2244e commit cbeaeb7

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
@@ -1813,4 +1813,26 @@ mod tests {
18131813

18141814
assert!(outbound_payments.add_new_awaiting_invoice(payment_id).is_err());
18151815
}
1816+
1817+
#[test]
1818+
fn removes_abandoned_awaiting_invoice() {
1819+
let pending_events = Mutex::new(VecDeque::new());
1820+
let outbound_payments = OutboundPayments::new();
1821+
let payment_id = PaymentId([0; 32]);
1822+
1823+
assert!(!outbound_payments.has_pending_payments());
1824+
assert!(outbound_payments.add_new_awaiting_invoice(payment_id).is_ok());
1825+
assert!(outbound_payments.has_pending_payments());
1826+
1827+
outbound_payments.abandon_payment(
1828+
payment_id, PaymentFailureReason::UserAbandoned, &pending_events
1829+
);
1830+
assert!(!outbound_payments.has_pending_payments());
1831+
assert!(!pending_events.lock().unwrap().is_empty());
1832+
assert_eq!(
1833+
pending_events.lock().unwrap().pop_front(),
1834+
Some((Event::InvoiceRequestFailed { payment_id }, None)),
1835+
);
1836+
assert!(pending_events.lock().unwrap().is_empty());
1837+
}
18161838
}

0 commit comments

Comments
 (0)