Skip to content

Commit 553652e

Browse files
committed
Test removing abandoned AwaitingInvoice payments
1 parent 137aa8e commit 553652e

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

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

0 commit comments

Comments
 (0)