@@ -497,7 +497,7 @@ impl Neighborhood {
497497 fn handle_route_query_message ( & mut self , msg : RouteQueryMessage ) -> Option < RouteQueryResponse > {
498498 let debug_msg_opt = self . logger . debug_enabled ( ) . then ( || format ! ( "{:?}" , msg) ) ;
499499 let route_result = if self . mode == NeighborhoodModeLight :: ZeroHop {
500- Ok ( self . zero_hop_route_response ( ) )
500+ Ok ( self . zero_hop_route_response ( msg . hostname_opt ) )
501501 } else {
502502 self . make_round_trip_route ( msg)
503503 } ;
@@ -977,7 +977,7 @@ impl Neighborhood {
977977 . expect ( "route creation error" )
978978 }
979979
980- fn zero_hop_route_response ( & mut self ) -> RouteQueryResponse {
980+ fn zero_hop_route_response ( & mut self , hostname_opt : Option < String > ) -> RouteQueryResponse {
981981 let route = Route :: round_trip (
982982 RouteSegment :: new (
983983 vec ! [ self . cryptde. public_key( ) , self . cryptde. public_key( ) ] ,
@@ -998,7 +998,7 @@ impl Neighborhood {
998998 vec ! [ ExpectedService :: Nothing , ExpectedService :: Nothing ] ,
999999 vec ! [ ExpectedService :: Nothing , ExpectedService :: Nothing ] ,
10001000 ) ,
1001- hostname_opt : None ,
1001+ hostname_opt,
10021002 }
10031003 }
10041004
@@ -2174,6 +2174,15 @@ mod tests {
21742174 use actix:: Recipient ;
21752175 use actix:: System ;
21762176 use itertools:: Itertools ;
2177+ use masq_lib:: constants:: { DEFAULT_CHAIN , TLS_PORT } ;
2178+ use masq_lib:: messages:: {
2179+ CountryGroups , ToMessageBody , UiConnectionChangeBroadcast , UiConnectionStage ,
2180+ } ;
2181+ use masq_lib:: test_utils:: utils:: { ensure_node_home_directory_exists, TEST_DEFAULT_CHAIN } ;
2182+ use masq_lib:: ui_gateway:: MessageBody ;
2183+ use masq_lib:: ui_gateway:: MessagePath :: Conversation ;
2184+ use masq_lib:: ui_gateway:: MessageTarget ;
2185+ use masq_lib:: utils:: running_test;
21772186 use serde_cbor;
21782187 use std:: any:: TypeId ;
21792188 use std:: cell:: RefCell ;
@@ -2187,16 +2196,7 @@ mod tests {
21872196 use std:: time:: Duration ;
21882197 use std:: time:: Instant ;
21892198 use tokio:: prelude:: Future ;
2190-
2191- use masq_lib:: constants:: { DEFAULT_CHAIN , TLS_PORT } ;
2192- use masq_lib:: messages:: {
2193- CountryGroups , ToMessageBody , UiConnectionChangeBroadcast , UiConnectionStage ,
2194- } ;
2195- use masq_lib:: test_utils:: utils:: { ensure_node_home_directory_exists, TEST_DEFAULT_CHAIN } ;
2196- use masq_lib:: ui_gateway:: MessageBody ;
2197- use masq_lib:: ui_gateway:: MessagePath :: Conversation ;
2198- use masq_lib:: ui_gateway:: MessageTarget ;
2199- use masq_lib:: utils:: running_test;
2199+ use ExpectedService :: Exit ;
22002200
22012201 use crate :: db_config:: persistent_configuration:: PersistentConfigError ;
22022202 use crate :: neighborhood:: gossip:: Gossip_0v1 ;
@@ -2248,6 +2248,8 @@ mod tests {
22482248 use crate :: neighborhood:: overall_connection_status:: {
22492249 ConnectionProgress , ConnectionStage , OverallConnectionStage ,
22502250 } ;
2251+ use crate :: sub_lib:: neighborhood:: ExpectedService :: { Nothing , Routing } ;
2252+ use crate :: sub_lib:: neighborhood:: ExpectedServices :: RoundTrip ;
22512253 use crate :: test_utils:: unshared_test_utils:: notify_handlers:: NotifyLaterHandleMock ;
22522254 use masq_lib:: test_utils:: logging:: { init_test_logging, TestLogHandler } ;
22532255
@@ -3378,14 +3380,14 @@ mod tests {
33783380 expected_services : ExpectedServices :: RoundTrip (
33793381 vec ! [
33803382 ExpectedService :: Nothing ,
3381- ExpectedService :: Exit (
3383+ Exit (
33823384 desirable_exit_node. public_key( ) . clone( ) ,
33833385 desirable_exit_node. earning_wallet( ) ,
33843386 rate_pack( 2345 ) ,
33853387 ) ,
33863388 ] ,
33873389 vec ! [
3388- ExpectedService :: Exit (
3390+ Exit (
33893391 desirable_exit_node. public_key( ) . clone( ) ,
33903392 desirable_exit_node. earning_wallet( ) ,
33913393 rate_pack( 2345 ) ,
@@ -3426,7 +3428,8 @@ mod tests {
34263428 let sub: Recipient < RouteQueryMessage > = addr. recipient :: < RouteQueryMessage > ( ) ;
34273429
34283430 let future = sub. send ( RouteQueryMessage :: data_indefinite_route_request (
3429- None , 12345 ,
3431+ Some ( "google.com" . to_string ( ) ) ,
3432+ 12345 ,
34303433 ) ) ;
34313434
34323435 System :: current ( ) . stop_with_code ( 0 ) ;
@@ -3451,7 +3454,7 @@ mod tests {
34513454 vec ! [ ExpectedService :: Nothing , ExpectedService :: Nothing ] ,
34523455 vec ! [ ExpectedService :: Nothing , ExpectedService :: Nothing ] ,
34533456 ) ,
3454- hostname_opt : None ,
3457+ hostname_opt : Some ( "google.com" . to_string ( ) ) ,
34553458 } ;
34563459 assert_eq ! ( result, expected_response) ;
34573460 }
@@ -3525,18 +3528,10 @@ mod tests {
35253528 q. earning_wallet( ) ,
35263529 rate_pack( 3456 ) ,
35273530 ) ,
3528- ExpectedService :: Exit (
3529- r. public_key( ) . clone( ) ,
3530- r. earning_wallet( ) ,
3531- rate_pack( 4567 ) ,
3532- ) ,
3531+ Exit ( r. public_key( ) . clone( ) , r. earning_wallet( ) , rate_pack( 4567 ) ) ,
35333532 ] ,
35343533 vec ! [
3535- ExpectedService :: Exit (
3536- r. public_key( ) . clone( ) ,
3537- r. earning_wallet( ) ,
3538- rate_pack( 4567 ) ,
3539- ) ,
3534+ Exit ( r. public_key( ) . clone( ) , r. earning_wallet( ) , rate_pack( 4567 ) ) ,
35403535 ExpectedService :: Routing (
35413536 q. public_key( ) . clone( ) ,
35423537 q. earning_wallet( ) ,
@@ -6934,14 +6929,14 @@ mod tests {
69346929 target_component : Component :: ProxyClient ,
69356930 return_component_opt : Some ( Component :: ProxyServer ) ,
69366931 payload_size : 10000 ,
6937- hostname_opt : None ,
6932+ hostname_opt : Some ( "host.name" . to_string ( ) ) ,
69386933 } ) ;
69396934
69406935 let next_door_neighbor_cryptde =
69416936 CryptDENull :: from ( & next_door_neighbor. public_key ( ) , TEST_DEFAULT_CHAIN ) ;
69426937 let exit_node_cryptde = CryptDENull :: from ( & exit_node. public_key ( ) , TEST_DEFAULT_CHAIN ) ;
6943-
6944- let hops = result . clone ( ) . unwrap ( ) . route . hops ;
6938+ let response = result . clone ( ) . unwrap ( ) ;
6939+ let hops = & response . route . hops ;
69456940 let actual_keys: Vec < PublicKey > = match hops. as_slice ( ) {
69466941 [ hop, exit, hop_back, origin, empty] => vec ! [
69476942 decodex:: <LiveHop >( main_cryptde( ) , hop)
@@ -6974,6 +6969,38 @@ mod tests {
69746969 PublicKey :: new( b"" ) ,
69756970 ] ;
69766971 assert_eq ! ( expected_public_keys, actual_keys) ;
6972+ assert_eq ! (
6973+ response. expected_services,
6974+ RoundTrip (
6975+ vec![
6976+ Nothing ,
6977+ Routing (
6978+ next_door_neighbor. public_key( ) . clone( ) ,
6979+ next_door_neighbor. earning_wallet( ) ,
6980+ next_door_neighbor. rate_pack( ) . clone( )
6981+ ) ,
6982+ Exit (
6983+ exit_node. public_key( ) . clone( ) ,
6984+ exit_node. earning_wallet( ) ,
6985+ exit_node. rate_pack( ) . clone( )
6986+ ) ,
6987+ ] ,
6988+ vec![
6989+ Exit (
6990+ exit_node. public_key( ) . clone( ) ,
6991+ exit_node. earning_wallet( ) ,
6992+ exit_node. rate_pack( ) . clone( )
6993+ ) ,
6994+ Routing (
6995+ next_door_neighbor. public_key( ) . clone( ) ,
6996+ next_door_neighbor. earning_wallet( ) ,
6997+ next_door_neighbor. rate_pack( ) . clone( )
6998+ ) ,
6999+ Nothing ,
7000+ ]
7001+ )
7002+ ) ;
7003+ assert_eq ! ( response. hostname_opt, Some ( "host.name" . to_string( ) ) ) ;
69777004 }
69787005
69797006 fn assert_route_query_message ( min_hops : Hops ) {
0 commit comments