@@ -345,7 +345,8 @@ fn one_unblinded_hop() {
345
345
let test_msg = TestCustomMessage :: Pong ;
346
346
347
347
let destination = Destination :: Node ( nodes[ 1 ] . node_id ) ;
348
- nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap ( ) ;
348
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
349
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions) . unwrap ( ) ;
349
350
nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
350
351
pass_along_path ( & nodes) ;
351
352
}
@@ -375,7 +376,8 @@ fn one_blinded_hop() {
375
376
let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
376
377
let blinded_path = BlindedMessagePath :: new ( & [ ] , nodes[ 1 ] . node_id , context, & * nodes[ 1 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
377
378
let destination = Destination :: BlindedPath ( blinded_path) ;
378
- nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap ( ) ;
379
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
380
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions) . unwrap ( ) ;
379
381
nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
380
382
pass_along_path ( & nodes) ;
381
383
}
@@ -413,8 +415,9 @@ fn three_blinded_hops() {
413
415
let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
414
416
let blinded_path = BlindedMessagePath :: new ( & intermediate_nodes, nodes[ 3 ] . node_id , context, & * nodes[ 3 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
415
417
let destination = Destination :: BlindedPath ( blinded_path) ;
418
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
416
419
417
- nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination , None ) . unwrap ( ) ;
420
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions ) . unwrap ( ) ;
418
421
nodes[ 3 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
419
422
pass_along_path ( & nodes) ;
420
423
}
@@ -447,7 +450,7 @@ fn async_response_over_one_blinded_hop() {
447
450
let ( msg, instructions) = response_instruction. unwrap ( ) ;
448
451
assert_eq ! (
449
452
nodes[ 0 ] . messenger. handle_onion_message_response( msg, instructions) ,
450
- Ok ( Some ( SendSuccess :: Buffered ) ) ,
453
+ Ok ( SendSuccess :: Buffered ) ,
451
454
) ;
452
455
453
456
bob. custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
@@ -481,7 +484,7 @@ fn async_response_with_reply_path_succeeds() {
481
484
let ( msg, instructions) = response_instruction. unwrap ( ) ;
482
485
assert_eq ! (
483
486
alice. messenger. handle_onion_message_response( msg, instructions) ,
484
- Ok ( Some ( SendSuccess :: Buffered ) ) ,
487
+ Ok ( SendSuccess :: Buffered ) ,
485
488
) ;
486
489
487
490
// Set Bob's expectation and pass the Onion Message along the path.
@@ -557,8 +560,9 @@ fn we_are_intro_node() {
557
560
let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
558
561
let blinded_path = BlindedMessagePath :: new ( & intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 2 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
559
562
let destination = Destination :: BlindedPath ( blinded_path) ;
563
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
560
564
561
- nodes[ 0 ] . messenger . send_onion_message ( test_msg. clone ( ) , destination , None ) . unwrap ( ) ;
565
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg. clone ( ) , instructions ) . unwrap ( ) ;
562
566
nodes[ 2 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
563
567
pass_along_path ( & nodes) ;
564
568
@@ -567,7 +571,9 @@ fn we_are_intro_node() {
567
571
let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
568
572
let blinded_path = BlindedMessagePath :: new ( & intermediate_nodes, nodes[ 1 ] . node_id , context, & * nodes[ 1 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
569
573
let destination = Destination :: BlindedPath ( blinded_path) ;
570
- nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap ( ) ;
574
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
575
+
576
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions) . unwrap ( ) ;
571
577
nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
572
578
nodes. remove ( 2 ) ;
573
579
pass_along_path ( & nodes) ;
@@ -585,7 +591,9 @@ fn invalid_blinded_path_error() {
585
591
let mut blinded_path = BlindedMessagePath :: new ( & intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 2 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
586
592
blinded_path. clear_blinded_hops ( ) ;
587
593
let destination = Destination :: BlindedPath ( blinded_path) ;
588
- let err = nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap_err ( ) ;
594
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
595
+
596
+ let err = nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions) . unwrap_err ( ) ;
589
597
assert_eq ! ( err, SendError :: TooFewBlindedHops ) ;
590
598
}
591
599
@@ -629,8 +637,9 @@ fn reply_path() {
629
637
] ;
630
638
let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
631
639
let reply_path = BlindedMessagePath :: new ( & intermediate_nodes, nodes[ 0 ] . node_id , context, & * nodes[ 0 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
640
+ let instructions = MessageSendInstructions :: WithSpecifiedReplyPath { destination, reply_path } ;
632
641
633
- nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination , Some ( reply_path ) ) . unwrap ( ) ;
642
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions ) . unwrap ( ) ;
634
643
nodes[ 3 ] . custom_message_handler . expect_message ( TestCustomMessage :: Ping ) ;
635
644
pass_along_path ( & nodes) ;
636
645
@@ -662,7 +671,9 @@ fn invalid_custom_message_type() {
662
671
663
672
let test_msg = InvalidCustomMessage { } ;
664
673
let destination = Destination :: Node ( nodes[ 1 ] . node_id ) ;
665
- let err = nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination, None ) . unwrap_err ( ) ;
674
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
675
+
676
+ let err = nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions) . unwrap_err ( ) ;
666
677
assert_eq ! ( err, SendError :: InvalidMessage ) ;
667
678
}
668
679
@@ -671,10 +682,12 @@ fn peer_buffer_full() {
671
682
let nodes = create_nodes ( 2 ) ;
672
683
let test_msg = TestCustomMessage :: Ping ;
673
684
let destination = Destination :: Node ( nodes[ 1 ] . node_id ) ;
685
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
686
+
674
687
for _ in 0 ..188 { // Based on MAX_PER_PEER_BUFFER_SIZE in OnionMessenger
675
- nodes[ 0 ] . messenger . send_onion_message ( test_msg. clone ( ) , destination . clone ( ) , None ) . unwrap ( ) ;
688
+ nodes[ 0 ] . messenger . send_onion_message ( test_msg. clone ( ) , instructions . clone ( ) ) . unwrap ( ) ;
676
689
}
677
- let err = nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination , None ) . unwrap_err ( ) ;
690
+ let err = nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions . clone ( ) ) . unwrap_err ( ) ;
678
691
assert_eq ! ( err, SendError :: BufferFull ) ;
679
692
}
680
693
@@ -714,17 +727,18 @@ fn requests_peer_connection_for_buffered_messages() {
714
727
& intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 0 ] . entropy_source , & secp_ctx
715
728
) . unwrap ( ) ;
716
729
let destination = Destination :: BlindedPath ( blinded_path) ;
730
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
717
731
718
732
// Buffer an onion message for a connected peer
719
- nodes[ 0 ] . messenger . send_onion_message ( message. clone ( ) , destination . clone ( ) , None ) . unwrap ( ) ;
733
+ nodes[ 0 ] . messenger . send_onion_message ( message. clone ( ) , instructions . clone ( ) ) . unwrap ( ) ;
720
734
assert ! ( release_events( & nodes[ 0 ] ) . is_empty( ) ) ;
721
735
assert ! ( nodes[ 0 ] . messenger. next_onion_message_for_peer( nodes[ 1 ] . node_id) . is_some( ) ) ;
722
736
assert ! ( nodes[ 0 ] . messenger. next_onion_message_for_peer( nodes[ 1 ] . node_id) . is_none( ) ) ;
723
737
724
738
// Buffer an onion message for a disconnected peer
725
739
disconnect_peers ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
726
740
assert ! ( nodes[ 0 ] . messenger. next_onion_message_for_peer( nodes[ 1 ] . node_id) . is_none( ) ) ;
727
- nodes[ 0 ] . messenger . send_onion_message ( message, destination , None ) . unwrap ( ) ;
741
+ nodes[ 0 ] . messenger . send_onion_message ( message, instructions ) . unwrap ( ) ;
728
742
729
743
// Check that a ConnectionNeeded event for the peer is provided
730
744
let events = release_events ( & nodes[ 0 ] ) ;
@@ -753,10 +767,11 @@ fn drops_buffered_messages_waiting_for_peer_connection() {
753
767
& intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 0 ] . entropy_source , & secp_ctx
754
768
) . unwrap ( ) ;
755
769
let destination = Destination :: BlindedPath ( blinded_path) ;
770
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
756
771
757
772
// Buffer an onion message for a disconnected peer
758
773
disconnect_peers ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
759
- nodes[ 0 ] . messenger . send_onion_message ( message, destination , None ) . unwrap ( ) ;
774
+ nodes[ 0 ] . messenger . send_onion_message ( message, instructions ) . unwrap ( ) ;
760
775
761
776
// Release the event so the timer can start ticking
762
777
let events = release_events ( & nodes[ 0 ] ) ;
@@ -804,10 +819,11 @@ fn intercept_offline_peer_oms() {
804
819
& intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 2 ] . entropy_source , & secp_ctx
805
820
) . unwrap ( ) ;
806
821
let destination = Destination :: BlindedPath ( blinded_path) ;
822
+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
807
823
808
824
// Disconnect the peers to ensure we intercept the OM.
809
825
disconnect_peers ( & nodes[ 1 ] , & nodes[ 2 ] ) ;
810
- nodes[ 0 ] . messenger . send_onion_message ( message, destination , None ) . unwrap ( ) ;
826
+ nodes[ 0 ] . messenger . send_onion_message ( message, instructions ) . unwrap ( ) ;
811
827
let mut final_node_vec = nodes. split_off ( 2 ) ;
812
828
pass_along_path ( & nodes) ;
813
829
0 commit comments