@@ -250,12 +250,8 @@ fn one_unblinded_hop() {
250
250
let nodes = create_nodes ( 2 ) ;
251
251
let test_msg = TestCustomMessage :: Response ;
252
252
253
- let path = OnionMessagePath {
254
- intermediate_nodes : vec ! [ ] ,
255
- destination : Destination :: Node ( nodes[ 1 ] . node_id ) ,
256
- first_node_addresses : None ,
257
- } ;
258
- nodes[ 0 ] . messenger . send_onion_message_using_path ( path, test_msg, None ) . unwrap ( ) ;
253
+ let destination = Destination :: Node ( nodes[ 1 ] . node_id ) ;
254
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap ( ) ;
259
255
nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Response ) ;
260
256
pass_along_path ( & nodes) ;
261
257
}
@@ -270,6 +266,7 @@ fn two_unblinded_hops() {
270
266
destination : Destination :: Node ( nodes[ 2 ] . node_id ) ,
271
267
first_node_addresses : None ,
272
268
} ;
269
+
273
270
nodes[ 0 ] . messenger . send_onion_message_using_path ( path, test_msg, None ) . unwrap ( ) ;
274
271
nodes[ 2 ] . custom_message_handler . expect_message ( TestCustomMessage :: Response ) ;
275
272
pass_along_path ( & nodes) ;
@@ -282,12 +279,8 @@ fn one_blinded_hop() {
282
279
283
280
let secp_ctx = Secp256k1 :: new ( ) ;
284
281
let blinded_path = BlindedPath :: new_for_message ( & [ nodes[ 1 ] . node_id ] , & * nodes[ 1 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
285
- let path = OnionMessagePath {
286
- intermediate_nodes : vec ! [ ] ,
287
- destination : Destination :: BlindedPath ( blinded_path) ,
288
- first_node_addresses : None ,
289
- } ;
290
- nodes[ 0 ] . messenger . send_onion_message_using_path ( path, test_msg, None ) . unwrap ( ) ;
282
+ let destination = Destination :: BlindedPath ( blinded_path) ;
283
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap ( ) ;
291
284
nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Response ) ;
292
285
pass_along_path ( & nodes) ;
293
286
}
@@ -317,13 +310,9 @@ fn three_blinded_hops() {
317
310
318
311
let secp_ctx = Secp256k1 :: new ( ) ;
319
312
let blinded_path = BlindedPath :: new_for_message ( & [ nodes[ 1 ] . node_id , nodes[ 2 ] . node_id , nodes[ 3 ] . node_id ] , & * nodes[ 3 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
320
- let path = OnionMessagePath {
321
- intermediate_nodes : vec ! [ ] ,
322
- destination : Destination :: BlindedPath ( blinded_path) ,
323
- first_node_addresses : None ,
324
- } ;
313
+ let destination = Destination :: BlindedPath ( blinded_path) ;
325
314
326
- nodes[ 0 ] . messenger . send_onion_message_using_path ( path , test_msg , None ) . unwrap ( ) ;
315
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg , destination , None ) . unwrap ( ) ;
327
316
nodes[ 3 ] . custom_message_handler . expect_message ( TestCustomMessage :: Response ) ;
328
317
pass_along_path ( & nodes) ;
329
318
}
@@ -354,24 +343,16 @@ fn we_are_intro_node() {
354
343
355
344
let secp_ctx = Secp256k1 :: new ( ) ;
356
345
let blinded_path = BlindedPath :: new_for_message ( & [ nodes[ 0 ] . node_id , nodes[ 1 ] . node_id , nodes[ 2 ] . node_id ] , & * nodes[ 2 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
357
- let path = OnionMessagePath {
358
- intermediate_nodes : vec ! [ ] ,
359
- destination : Destination :: BlindedPath ( blinded_path) ,
360
- first_node_addresses : None ,
361
- } ;
346
+ let destination = Destination :: BlindedPath ( blinded_path) ;
362
347
363
- nodes[ 0 ] . messenger . send_onion_message_using_path ( path , test_msg. clone ( ) , None ) . unwrap ( ) ;
348
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg. clone ( ) , destination , None ) . unwrap ( ) ;
364
349
nodes[ 2 ] . custom_message_handler . expect_message ( TestCustomMessage :: Response ) ;
365
350
pass_along_path ( & nodes) ;
366
351
367
352
// Try with a two-hop blinded path where we are the introduction node.
368
353
let blinded_path = BlindedPath :: new_for_message ( & [ nodes[ 0 ] . node_id , nodes[ 1 ] . node_id ] , & * nodes[ 1 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
369
- let path = OnionMessagePath {
370
- intermediate_nodes : vec ! [ ] ,
371
- destination : Destination :: BlindedPath ( blinded_path) ,
372
- first_node_addresses : None ,
373
- } ;
374
- nodes[ 0 ] . messenger . send_onion_message_using_path ( path, test_msg, None ) . unwrap ( ) ;
354
+ let destination = Destination :: BlindedPath ( blinded_path) ;
355
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap ( ) ;
375
356
nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Response ) ;
376
357
nodes. remove ( 2 ) ;
377
358
pass_along_path ( & nodes) ;
@@ -387,12 +368,8 @@ fn invalid_blinded_path_error() {
387
368
let secp_ctx = Secp256k1 :: new ( ) ;
388
369
let mut blinded_path = BlindedPath :: new_for_message ( & [ nodes[ 1 ] . node_id , nodes[ 2 ] . node_id ] , & * nodes[ 2 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
389
370
blinded_path. blinded_hops . clear ( ) ;
390
- let path = OnionMessagePath {
391
- intermediate_nodes : vec ! [ ] ,
392
- destination : Destination :: BlindedPath ( blinded_path) ,
393
- first_node_addresses : None ,
394
- } ;
395
- let err = nodes[ 0 ] . messenger . send_onion_message_using_path ( path, test_msg. clone ( ) , None ) . unwrap_err ( ) ;
371
+ let destination = Destination :: BlindedPath ( blinded_path) ;
372
+ let err = nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap_err ( ) ;
396
373
assert_eq ! ( err, SendError :: TooFewBlindedHops ) ;
397
374
}
398
375
@@ -419,14 +396,10 @@ fn reply_path() {
419
396
420
397
// Destination::BlindedPath
421
398
let blinded_path = BlindedPath :: new_for_message ( & [ nodes[ 1 ] . node_id , nodes[ 2 ] . node_id , nodes[ 3 ] . node_id ] , & * nodes[ 3 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
422
- let path = OnionMessagePath {
423
- intermediate_nodes : vec ! [ ] ,
424
- destination : Destination :: BlindedPath ( blinded_path) ,
425
- first_node_addresses : None ,
426
- } ;
399
+ let destination = Destination :: BlindedPath ( blinded_path) ;
427
400
let reply_path = BlindedPath :: new_for_message ( & [ nodes[ 2 ] . node_id , nodes[ 1 ] . node_id , nodes[ 0 ] . node_id ] , & * nodes[ 0 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
428
401
429
- nodes[ 0 ] . messenger . send_onion_message_using_path ( path , test_msg , Some ( reply_path) ) . unwrap ( ) ;
402
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg , destination , Some ( reply_path) ) . unwrap ( ) ;
430
403
nodes[ 3 ] . custom_message_handler . expect_message ( TestCustomMessage :: Request ) ;
431
404
pass_along_path ( & nodes) ;
432
405
@@ -454,28 +427,20 @@ fn invalid_custom_message_type() {
454
427
}
455
428
456
429
let test_msg = InvalidCustomMessage { } ;
457
- let path = OnionMessagePath {
458
- intermediate_nodes : vec ! [ ] ,
459
- destination : Destination :: Node ( nodes[ 1 ] . node_id ) ,
460
- first_node_addresses : None ,
461
- } ;
462
- let err = nodes[ 0 ] . messenger . send_onion_message_using_path ( path, test_msg, None ) . unwrap_err ( ) ;
430
+ let destination = Destination :: Node ( nodes[ 1 ] . node_id ) ;
431
+ let err = nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap_err ( ) ;
463
432
assert_eq ! ( err, SendError :: InvalidMessage ) ;
464
433
}
465
434
466
435
#[ test]
467
436
fn peer_buffer_full ( ) {
468
437
let nodes = create_nodes ( 2 ) ;
469
438
let test_msg = TestCustomMessage :: Request ;
470
- let path = OnionMessagePath {
471
- intermediate_nodes : vec ! [ ] ,
472
- destination : Destination :: Node ( nodes[ 1 ] . node_id ) ,
473
- first_node_addresses : None ,
474
- } ;
439
+ let destination = Destination :: Node ( nodes[ 1 ] . node_id ) ;
475
440
for _ in 0 ..188 { // Based on MAX_PER_PEER_BUFFER_SIZE in OnionMessenger
476
- nodes[ 0 ] . messenger . send_onion_message_using_path ( path . clone ( ) , test_msg . clone ( ) , None ) . unwrap ( ) ;
441
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg . clone ( ) , destination . clone ( ) , None ) . unwrap ( ) ;
477
442
}
478
- let err = nodes[ 0 ] . messenger . send_onion_message_using_path ( path , test_msg , None ) . unwrap_err ( ) ;
443
+ let err = nodes[ 0 ] . messenger . send_onion_message ( test_msg , destination , None ) . unwrap_err ( ) ;
479
444
assert_eq ! ( err, SendError :: BufferFull ) ;
480
445
}
481
446
0 commit comments