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