@@ -652,19 +652,19 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
652
652
/// Checks that an offer can be paid through a one-hop blinded path and that ephemeral pubkeys are
653
653
/// used rather than exposing a node's pubkey. However, the node's pubkey is still used as the
654
654
/// introduction node of the blinded path.
655
- #[ test]
656
- fn creates_and_pays_for_offer_using_one_hop_blinded_path ( ) {
657
- let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
658
- let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
659
- let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
660
- let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
655
+ fn do_creates_and_pays_for_offer_using_one_hop_blinded_path ( with_message_retry : bool ) {
656
+ let chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
657
+ let node_cfgs = create_node_cfgs ( 3 , & chanmon_cfgs) ;
658
+ let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
659
+ let nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
661
660
662
661
create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
663
662
664
663
let alice = & nodes[ 0 ] ;
665
664
let alice_id = alice. node . get_our_node_id ( ) ;
666
665
let bob = & nodes[ 1 ] ;
667
666
let bob_id = bob. node . get_our_node_id ( ) ;
667
+ let charlie = & nodes[ 2 ] ;
668
668
669
669
let offer = alice. node
670
670
. create_offer_builder ( None ) . unwrap ( )
@@ -680,7 +680,15 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
680
680
bob. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None ) . unwrap ( ) ;
681
681
expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
682
682
683
- let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
683
+ let mut onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
684
+
685
+ // Simulating a scenario where the original onion_message is lost before reaching Alice.
686
+ // However, the we receive a message from another peer ensuring regeneration of the onion_message.
687
+ if with_message_retry {
688
+ disconnect_peers ( bob, & [ charlie] ) ;
689
+ onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
690
+ }
691
+
684
692
alice. onion_messenger . handle_onion_message ( & bob_id, & onion_message) ;
685
693
686
694
let ( invoice_request, reply_path) = extract_invoice_request ( alice, & onion_message) ;
@@ -699,6 +707,18 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
699
707
let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
700
708
bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
701
709
710
+ if with_message_retry {
711
+ // We expect no more OffersMessage to be enqueued by this point, even if we receive
712
+ // some other unrelated message from another peer.
713
+ connect_peers ( bob, charlie) ;
714
+
715
+ let result = bob. onion_messenger . next_onion_message_for_peer ( alice_id) ;
716
+ match result {
717
+ Some ( _) => panic ! ( "Unexpected message enqueued after retry tick." ) ,
718
+ None => assert ! ( true ) ,
719
+ }
720
+ }
721
+
702
722
let invoice = extract_invoice ( bob, & onion_message) ;
703
723
assert_eq ! ( invoice. amount_msats( ) , 10_000_000 ) ;
704
724
assert_ne ! ( invoice. signing_pubkey( ) , alice_id) ;
@@ -714,6 +734,15 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
714
734
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
715
735
}
716
736
737
+ /// Checks that an offer can be paid through a one-hop blinded path and that ephemeral pubkeys are
738
+ /// used rather than exposing a node's pubkey. However, the node's pubkey is still used as the
739
+ /// introduction node of the blinded path.
740
+ #[ test]
741
+ fn creates_and_pays_for_offer_using_one_hop_blinded_path ( ) {
742
+ do_creates_and_pays_for_offer_using_one_hop_blinded_path ( false ) ;
743
+ do_creates_and_pays_for_offer_using_one_hop_blinded_path ( true ) ;
744
+ }
745
+
717
746
/// Checks that a refund can be paid through a one-hop blinded path and that ephemeral pubkeys are
718
747
/// used rather than exposing a node's pubkey. However, the node's pubkey is still used as the
719
748
/// introduction node of the blinded path.
0 commit comments