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