@@ -345,7 +345,8 @@ fn one_unblinded_hop() {
345345 let test_msg = TestCustomMessage :: Pong ;
346346
347347 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 ( ) ;
349350 nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
350351 pass_along_path ( & nodes) ;
351352}
@@ -375,7 +376,8 @@ fn one_blinded_hop() {
375376 let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
376377 let blinded_path = BlindedMessagePath :: new ( & [ ] , nodes[ 1 ] . node_id , context, & * nodes[ 1 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
377378 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 ( ) ;
379381 nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
380382 pass_along_path ( & nodes) ;
381383}
@@ -413,8 +415,9 @@ fn three_blinded_hops() {
413415 let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
414416 let blinded_path = BlindedMessagePath :: new ( & intermediate_nodes, nodes[ 3 ] . node_id , context, & * nodes[ 3 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
415417 let destination = Destination :: BlindedPath ( blinded_path) ;
418+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
416419
417- nodes[ 0 ] . messenger . send_onion_message ( test_msg, destination , None ) . unwrap ( ) ;
420+ nodes[ 0 ] . messenger . send_onion_message ( test_msg, instructions ) . unwrap ( ) ;
418421 nodes[ 3 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
419422 pass_along_path ( & nodes) ;
420423}
@@ -447,7 +450,7 @@ fn async_response_over_one_blinded_hop() {
447450 let ( msg, instructions) = response_instruction. unwrap ( ) ;
448451 assert_eq ! (
449452 nodes[ 0 ] . messenger. handle_onion_message_response( msg, instructions) ,
450- Ok ( Some ( SendSuccess :: Buffered ) ) ,
453+ Ok ( SendSuccess :: Buffered ) ,
451454 ) ;
452455
453456 bob. custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
@@ -481,7 +484,7 @@ fn async_response_with_reply_path_succeeds() {
481484 let ( msg, instructions) = response_instruction. unwrap ( ) ;
482485 assert_eq ! (
483486 alice. messenger. handle_onion_message_response( msg, instructions) ,
484- Ok ( Some ( SendSuccess :: Buffered ) ) ,
487+ Ok ( SendSuccess :: Buffered ) ,
485488 ) ;
486489
487490 // Set Bob's expectation and pass the Onion Message along the path.
@@ -557,8 +560,9 @@ fn we_are_intro_node() {
557560 let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
558561 let blinded_path = BlindedMessagePath :: new ( & intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 2 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
559562 let destination = Destination :: BlindedPath ( blinded_path) ;
563+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
560564
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 ( ) ;
562566 nodes[ 2 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
563567 pass_along_path ( & nodes) ;
564568
@@ -567,7 +571,9 @@ fn we_are_intro_node() {
567571 let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
568572 let blinded_path = BlindedMessagePath :: new ( & intermediate_nodes, nodes[ 1 ] . node_id , context, & * nodes[ 1 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
569573 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 ( ) ;
571577 nodes[ 1 ] . custom_message_handler . expect_message ( TestCustomMessage :: Pong ) ;
572578 nodes. remove ( 2 ) ;
573579 pass_along_path ( & nodes) ;
@@ -585,7 +591,9 @@ fn invalid_blinded_path_error() {
585591 let mut blinded_path = BlindedMessagePath :: new ( & intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 2 ] . entropy_source , & secp_ctx) . unwrap ( ) ;
586592 blinded_path. clear_blinded_hops ( ) ;
587593 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 ( ) ;
589597 assert_eq ! ( err, SendError :: TooFewBlindedHops ) ;
590598}
591599
@@ -629,8 +637,9 @@ fn reply_path() {
629637 ] ;
630638 let context = MessageContext :: Custom ( Vec :: new ( ) ) ;
631639 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 } ;
632641
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 ( ) ;
634643 nodes[ 3 ] . custom_message_handler . expect_message ( TestCustomMessage :: Ping ) ;
635644 pass_along_path ( & nodes) ;
636645
@@ -662,7 +671,9 @@ fn invalid_custom_message_type() {
662671
663672 let test_msg = InvalidCustomMessage { } ;
664673 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 ( ) ;
666677 assert_eq ! ( err, SendError :: InvalidMessage ) ;
667678}
668679
@@ -671,10 +682,12 @@ fn peer_buffer_full() {
671682 let nodes = create_nodes ( 2 ) ;
672683 let test_msg = TestCustomMessage :: Ping ;
673684 let destination = Destination :: Node ( nodes[ 1 ] . node_id ) ;
685+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
686+
674687 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 ( ) ;
676689 }
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 ( ) ;
678691 assert_eq ! ( err, SendError :: BufferFull ) ;
679692}
680693
@@ -714,17 +727,18 @@ fn requests_peer_connection_for_buffered_messages() {
714727 & intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 0 ] . entropy_source , & secp_ctx
715728 ) . unwrap ( ) ;
716729 let destination = Destination :: BlindedPath ( blinded_path) ;
730+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
717731
718732 // 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 ( ) ;
720734 assert ! ( release_events( & nodes[ 0 ] ) . is_empty( ) ) ;
721735 assert ! ( nodes[ 0 ] . messenger. next_onion_message_for_peer( nodes[ 1 ] . node_id) . is_some( ) ) ;
722736 assert ! ( nodes[ 0 ] . messenger. next_onion_message_for_peer( nodes[ 1 ] . node_id) . is_none( ) ) ;
723737
724738 // Buffer an onion message for a disconnected peer
725739 disconnect_peers ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
726740 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 ( ) ;
728742
729743 // Check that a ConnectionNeeded event for the peer is provided
730744 let events = release_events ( & nodes[ 0 ] ) ;
@@ -753,10 +767,11 @@ fn drops_buffered_messages_waiting_for_peer_connection() {
753767 & intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 0 ] . entropy_source , & secp_ctx
754768 ) . unwrap ( ) ;
755769 let destination = Destination :: BlindedPath ( blinded_path) ;
770+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
756771
757772 // Buffer an onion message for a disconnected peer
758773 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 ( ) ;
760775
761776 // Release the event so the timer can start ticking
762777 let events = release_events ( & nodes[ 0 ] ) ;
@@ -804,10 +819,11 @@ fn intercept_offline_peer_oms() {
804819 & intermediate_nodes, nodes[ 2 ] . node_id , context, & * nodes[ 2 ] . entropy_source , & secp_ctx
805820 ) . unwrap ( ) ;
806821 let destination = Destination :: BlindedPath ( blinded_path) ;
822+ let instructions = MessageSendInstructions :: WithoutReplyPath { destination } ;
807823
808824 // Disconnect the peers to ensure we intercept the OM.
809825 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 ( ) ;
811827 let mut final_node_vec = nodes. split_off ( 2 ) ;
812828 pass_along_path ( & nodes) ;
813829
0 commit comments