@@ -523,11 +523,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
523
523
expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
524
524
}
525
525
526
- /// Checks that an offer can be paid through a one-hop blinded path and that ephemeral pubkeys are
527
- /// used rather than exposing a node's pubkey. However, the node's pubkey is still used as the
528
- /// introduction node of the blinded path.
529
- #[ test]
530
- fn creates_and_pays_for_offer_using_one_hop_blinded_path ( ) {
526
+ fn do_creates_and_pays_for_offer_using_one_hop_blinded_path ( with_retry_tick_occurred : bool ) {
531
527
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
532
528
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
533
529
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
@@ -554,7 +550,14 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
554
550
bob. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None ) . unwrap ( ) ;
555
551
expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
556
552
557
- let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
553
+ let mut onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
554
+
555
+ // Simulating a scenario where the original onion_message is lost before reaching Alice.
556
+ // However, the retry_timer_tick mechanism ensures regeneration of the onion_message.
557
+ if with_retry_tick_occurred {
558
+ bob. node . timer_tick_occurred ( ) ;
559
+ onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
560
+ }
558
561
alice. onion_messenger . handle_onion_message ( & bob_id, & onion_message) ;
559
562
560
563
let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
@@ -573,6 +576,15 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
573
576
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
574
577
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
575
578
579
+ if with_retry_tick_occurred {
580
+ // We expect no more OffersMessage to be enqueued by this point, after the retry tick has occurred.
581
+ bob. node . timer_tick_occurred ( ) ;
582
+ let result = bob. onion_messenger . next_onion_message_for_peer ( alice_id) ;
583
+ match result {
584
+ Some ( _) => panic ! ( "Unexpected message enqueued after retry tick." ) ,
585
+ None => assert ! ( true ) ,
586
+ }
587
+ }
576
588
let invoice = extract_invoice ( bob, & onion_message) ;
577
589
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
578
590
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
@@ -588,6 +600,16 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
588
600
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
589
601
}
590
602
603
+
604
+ /// Checks that an offer can be paid through a one-hop blinded path and that ephemeral pubkeys are
605
+ /// used rather than exposing a node's pubkey. However, the node's pubkey is still used as the
606
+ /// introduction node of the blinded path.
607
+ #[ test]
608
+ fn creates_and_pays_for_offer_using_one_hop_blinded_path ( ) {
609
+ do_creates_and_pays_for_offer_using_one_hop_blinded_path ( false ) ;
610
+ do_creates_and_pays_for_offer_using_one_hop_blinded_path ( true ) ;
611
+ }
612
+
591
613
/// Checks that a refund can be paid through a one-hop blinded path and that ephemeral pubkeys are
592
614
/// used rather than exposing a node's pubkey. However, the node's pubkey is still used as the
593
615
/// introduction node of the blinded path.
0 commit comments