@@ -58,7 +58,7 @@ use crate::offers::invoice_error::InvoiceError;
5858use crate :: offers:: invoice_request:: { InvoiceRequest , InvoiceRequestFields } ;
5959use crate :: offers:: nonce:: Nonce ;
6060use crate :: offers:: parse:: Bolt12SemanticError ;
61- use crate :: onion_message:: messenger:: { DefaultMessageRouter , Destination , MessageSendInstructions , PeeledOnion } ;
61+ use crate :: onion_message:: messenger:: { DefaultMessageRouter , Destination , MessageSendInstructions , NullMessageRouter , PeeledOnion } ;
6262use crate :: onion_message:: offers:: OffersMessage ;
6363use crate :: onion_message:: packet:: ParsedOnionMessageContents ;
6464use crate :: routing:: gossip:: { NodeAlias , NodeId } ;
@@ -254,6 +254,55 @@ fn extract_invoice_error<'a, 'b, 'c>(
254254 }
255255}
256256
257+ /// Checks that an offer can be created with no blinded paths.
258+ #[ test]
259+ fn create_offer_with_no_blinded_path ( ) {
260+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
261+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
262+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
263+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
264+
265+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
266+
267+ let alice = & nodes[ 0 ] ;
268+ let alice_id = alice. node . get_our_node_id ( ) ;
269+
270+ let router = NullMessageRouter { } ;
271+ let offer = alice. offers_handler
272+ . create_offer_builder_using_router ( router) . unwrap ( )
273+ . amount_msats ( 10_000_000 )
274+ . build ( ) . unwrap ( ) ;
275+ assert_eq ! ( offer. issuer_signing_pubkey( ) , Some ( alice_id) ) ;
276+ assert ! ( offer. paths( ) . is_empty( ) ) ;
277+ }
278+
279+ /// Checks that a refund can be created with no blinded paths.
280+ #[ test]
281+ fn create_refund_with_no_blinded_path ( ) {
282+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
283+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
284+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
285+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
286+
287+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
288+
289+ let alice = & nodes[ 0 ] ;
290+ let alice_id = alice. node . get_our_node_id ( ) ;
291+
292+ let absolute_expiry = Duration :: from_secs ( u64:: MAX ) ;
293+ let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
294+
295+ let router = NullMessageRouter { } ;
296+ let refund = alice. offers_handler
297+ . create_refund_builder_using_router ( router, 10_000_000 , absolute_expiry, payment_id, Retry :: Attempts ( 0 ) , None )
298+ . unwrap ( )
299+ . build ( ) . unwrap ( ) ;
300+ assert_eq ! ( refund. amount_msats( ) , 10_000_000 ) ;
301+ assert_eq ! ( refund. absolute_expiry( ) , Some ( absolute_expiry) ) ;
302+ assert_eq ! ( refund. payer_signing_pubkey( ) , alice_id) ;
303+ assert ! ( refund. paths( ) . is_empty( ) ) ;
304+ }
305+
257306/// Checks that blinded paths without Tor-only nodes are preferred when constructing an offer.
258307#[ test]
259308fn prefers_non_tor_nodes_in_blinded_paths ( ) {
0 commit comments