@@ -650,11 +650,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
650
650
expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
651
651
}
652
652
653
- /// Checks that an offer can be paid through a one-hop blinded path and that ephemeral pubkeys are
654
- /// used rather than exposing a node's pubkey. However, the node's pubkey is still used as the
655
- /// introduction node of the blinded path.
656
- #[ test]
657
- fn creates_and_pays_for_offer_using_one_hop_blinded_path ( ) {
653
+ fn do_creates_and_pays_for_offer_using_one_hop_blinded_path ( with_message_retry : bool ) {
658
654
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
659
655
let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
660
656
let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
@@ -676,12 +672,20 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
676
672
for path in offer. paths ( ) {
677
673
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
678
674
}
679
-
680
675
let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
681
676
bob. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None ) . unwrap ( ) ;
682
677
expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
683
678
684
- let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
679
+ let mut onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
680
+
681
+ // Simulate a scenario where the original onion_message is lost before reaching Alice.
682
+ // Use handle_message_received to regenerate the message.
683
+ // If with_message_retry is true, ensure handle_message_received executes successfully.
684
+ if with_message_retry {
685
+ bob. node . handle_message_received ( ) ;
686
+ onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
687
+ }
688
+
685
689
alice. onion_messenger . handle_onion_message ( & bob_id, & onion_message) ;
686
690
687
691
let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
@@ -696,25 +700,43 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
696
700
assert_eq ! ( invoice_request. amount_msats( ) , None ) ;
697
701
assert_ne ! ( invoice_request. payer_id( ) , bob_id) ;
698
702
assert_eq ! ( reply_path. introduction_node, IntroductionNode :: NodeId ( bob_id) ) ;
699
-
700
703
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
701
704
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
702
705
706
+ if with_message_retry {
707
+ // Expect no more OffersMessage to be enqueued by this point, even after calling
708
+ // handle_message_received.
709
+ bob. node . handle_message_received ( ) ;
710
+
711
+ let result = bob. onion_messenger . next_onion_message_for_peer ( alice_id) ;
712
+ match result {
713
+ Some ( _) => panic ! ( "Unexpected message enqueued after retry tick." ) ,
714
+ None => assert ! ( true ) ,
715
+ }
716
+ }
717
+
703
718
let invoice = extract_invoice ( bob, & onion_message) ;
704
719
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
705
720
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
706
721
assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ;
707
722
for ( _, path) in invoice. payment_paths ( ) {
708
723
assert_eq ! ( path. introduction_node, IntroductionNode :: NodeId ( alice_id) ) ;
709
724
}
710
-
711
725
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
712
726
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
713
-
714
727
claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
715
728
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
716
729
}
717
730
731
+ /// Checks that an offer can be paid through a one-hop blinded path and that ephemeral pubkeys are
732
+ /// used rather than exposing a node's pubkey. However, the node's pubkey is still used as the
733
+ /// introduction node of the blinded path.
734
+ #[ test]
735
+ fn creates_and_pays_for_offer_using_one_hop_blinded_path ( ) {
736
+ do_creates_and_pays_for_offer_using_one_hop_blinded_path ( false ) ;
737
+ do_creates_and_pays_for_offer_using_one_hop_blinded_path ( true ) ;
738
+ }
739
+
718
740
/// Checks that a refund can be paid through a one-hop blinded path and that ephemeral pubkeys are
719
741
/// used rather than exposing a node's pubkey. However, the node's pubkey is still used as the
720
742
/// introduction node of the blinded path.
0 commit comments