@@ -211,3 +211,88 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
211211 claim_bolt12_payment ( bob, & [ alice] ) ;
212212 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
213213}
214+
215+ /// Checks that an invoice for an offer without any blinded paths can be requested. Note that while
216+ /// the requested is sent directly using the node's pubkey, the response and the payment still use
217+ /// blinded paths as required by the spec.
218+ #[ test]
219+ fn pays_for_offer_without_blinded_paths ( ) {
220+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
221+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
222+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
223+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
224+
225+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
226+
227+ let alice = & nodes[ 0 ] ;
228+ let alice_id = alice. node . get_our_node_id ( ) ;
229+ let bob = & nodes[ 1 ] ;
230+ let bob_id = bob. node . get_our_node_id ( ) ;
231+
232+ let offer = alice. node
233+ . create_offer_builder ( "coffee" . to_string ( ) ) . unwrap ( )
234+ . clear_paths ( )
235+ . amount_msats ( 10_000_000 )
236+ . build ( ) . unwrap ( ) ;
237+ assert_eq ! ( offer. signing_pubkey( ) , alice_id) ;
238+ assert ! ( offer. paths( ) . is_empty( ) ) ;
239+
240+ let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
241+ bob. node . pay_for_offer ( & offer, None , None , None , payment_id, Retry :: Attempts ( 0 ) , None ) . unwrap ( ) ;
242+ expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
243+
244+ let onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ;
245+ alice. onion_messenger . handle_onion_message ( & bob_id, & onion_message) ;
246+
247+ let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
248+ bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
249+
250+ let invoice = extract_invoice ( bob, & onion_message) ;
251+ route_bolt12_payment ( bob, & [ alice] , & invoice) ;
252+ expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
253+
254+ claim_bolt12_payment ( bob, & [ alice] ) ;
255+ expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
256+ }
257+
258+ /// Checks that a refund without any blinded paths can be paid. Note that while the invoice is sent
259+ /// directly using the node's pubkey, the payment still use blinded paths as required by the spec.
260+ #[ test]
261+ fn pays_for_refund_without_blinded_paths ( ) {
262+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
263+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
264+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
265+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
266+
267+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
268+
269+ let alice = & nodes[ 0 ] ;
270+ let alice_id = alice. node . get_our_node_id ( ) ;
271+ let bob = & nodes[ 1 ] ;
272+ let bob_id = bob. node . get_our_node_id ( ) ;
273+
274+ let absolute_expiry = Duration :: from_secs ( u64:: MAX ) ;
275+ let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
276+ let refund = bob. node
277+ . create_refund_builder (
278+ "refund" . to_string ( ) , 10_000_000 , absolute_expiry, payment_id, Retry :: Attempts ( 0 ) , None
279+ )
280+ . unwrap ( )
281+ . clear_paths ( )
282+ . build ( ) . unwrap ( ) ;
283+ assert_eq ! ( refund. payer_id( ) , bob_id) ;
284+ assert ! ( refund. paths( ) . is_empty( ) ) ;
285+ expect_recent_payment ! ( bob, RecentPaymentDetails :: AwaitingInvoice , payment_id) ;
286+
287+ alice. node . request_refund_payment ( & refund) . unwrap ( ) ;
288+
289+ let onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ;
290+ bob. onion_messenger . handle_onion_message ( & alice_id, & onion_message) ;
291+
292+ let invoice = extract_invoice ( bob, & onion_message) ;
293+ route_bolt12_payment ( bob, & [ alice] , & invoice) ;
294+ expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
295+
296+ claim_bolt12_payment ( bob, & [ alice] ) ;
297+ expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
298+ }
0 commit comments