Skip to content

Commit a248367

Browse files
shaavanTheBlueMatt
authored andcommitted
Introduce idempotency check in tests
1 parent d5f149d commit a248367

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lightning/src/ln/offers_tests.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,14 @@ fn pays_bolt12_invoice_asynchronously() {
11851185
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
11861186
bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
11871187

1188-
let (invoice, context) = match get_event!(bob, Event::InvoiceReceived) {
1188+
// Re-process the same onion message to ensure idempotency —
1189+
// we should not generate a duplicate `InvoiceReceived` event.
1190+
bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
1191+
1192+
let mut events = bob.node.get_and_clear_pending_events();
1193+
assert_eq!(events.len(), 1);
1194+
1195+
let (invoice, context) = match events.pop().unwrap() {
11891196
Event::InvoiceReceived { payment_id: actual_payment_id, invoice, context, .. } => {
11901197
assert_eq!(actual_payment_id, payment_id);
11911198
(invoice, context)

0 commit comments

Comments
 (0)