Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9dd98fb

Browse files
committedMar 18, 2025·
Introduce idempotency check in tests
1 parent bf6c3e6 commit 9dd98fb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎lightning/src/ln/offers_tests.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,14 @@ fn pays_bolt12_invoice_asynchronously() {
11861186
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
11871187
bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
11881188

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

0 commit comments

Comments
 (0)
Please sign in to comment.