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