@@ -60,7 +60,7 @@ use crate::offers::invoice_error::InvoiceError;
60
60
use crate :: offers:: invoice_request:: { InvoiceRequest , InvoiceRequestFields } ;
61
61
use crate :: offers:: nonce:: Nonce ;
62
62
use crate :: offers:: parse:: Bolt12SemanticError ;
63
- use crate :: onion_message:: messenger:: { Destination , PeeledOnion , MessageSendInstructions } ;
63
+ use crate :: onion_message:: messenger:: { Destination , MessageSendInstructions , NullMessageRouter , PeeledOnion } ;
64
64
use crate :: onion_message:: offers:: OffersMessage ;
65
65
use crate :: routing:: gossip:: { NodeAlias , NodeId } ;
66
66
use crate :: routing:: router:: { PaymentParameters , RouteParameters , RouteParametersConfig } ;
@@ -265,6 +265,55 @@ fn extract_invoice_error<'a, 'b, 'c>(
265
265
}
266
266
}
267
267
268
+ /// Checks that an offer can be created with no blinded paths.
269
+ #[ test]
270
+ fn create_offer_with_no_blinded_path ( ) {
271
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
272
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
273
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
274
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
275
+
276
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
277
+
278
+ let alice = & nodes[ 0 ] ;
279
+ let alice_id = alice. node . get_our_node_id ( ) ;
280
+
281
+ let router = NullMessageRouter { } ;
282
+ let offer = alice. node
283
+ . create_offer_builder_using_router ( & router) . unwrap ( )
284
+ . amount_msats ( 10_000_000 )
285
+ . build ( ) . unwrap ( ) ;
286
+ assert_eq ! ( offer. issuer_signing_pubkey( ) , Some ( alice_id) ) ;
287
+ assert ! ( offer. paths( ) . is_empty( ) ) ;
288
+ }
289
+
290
+ /// Checks that a refund can be created with no blinded paths.
291
+ #[ test]
292
+ fn create_refund_with_no_blinded_path ( ) {
293
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
294
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
295
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
296
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
297
+
298
+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 10_000_000 , 1_000_000_000 ) ;
299
+
300
+ let alice = & nodes[ 0 ] ;
301
+ let alice_id = alice. node . get_our_node_id ( ) ;
302
+
303
+ let absolute_expiry = Duration :: from_secs ( u64:: MAX ) ;
304
+ let payment_id = PaymentId ( [ 1 ; 32 ] ) ;
305
+
306
+ let router = NullMessageRouter { } ;
307
+ let refund = alice. node
308
+ . create_refund_builder_using_router ( & router, 10_000_000 , absolute_expiry, payment_id, Retry :: Attempts ( 0 ) , RouteParametersConfig :: default ( ) )
309
+ . unwrap ( )
310
+ . build ( ) . unwrap ( ) ;
311
+ assert_eq ! ( refund. amount_msats( ) , 10_000_000 ) ;
312
+ assert_eq ! ( refund. absolute_expiry( ) , Some ( absolute_expiry) ) ;
313
+ assert_eq ! ( refund. payer_signing_pubkey( ) , alice_id) ;
314
+ assert ! ( refund. paths( ) . is_empty( ) ) ;
315
+ }
316
+
268
317
/// Checks that blinded paths without Tor-only nodes are preferred when constructing an offer.
269
318
#[ test]
270
319
fn prefers_non_tor_nodes_in_blinded_paths ( ) {
0 commit comments