diff --git a/src/bin/mwixnet.rs b/src/bin/mwixnet.rs index 66092d6..1f70f53 100644 --- a/src/bin/mwixnet.rs +++ b/src/bin/mwixnet.rs @@ -161,14 +161,17 @@ fn real_main() -> Result<(), Box> { let rt = tokio::runtime::Builder::new_multi_thread() .enable_all() .build()?; - if let Err(e) = rt.block_on(node.async_get_chain_tip()) { + + let rt_handle = rt.handle().clone(); + + if let Err(e) = rt_handle.block_on(node.async_get_chain_tip()) { eprintln!("Node communication failure. Is node listening?"); return Err(e.into()); }; // Open wallet let wallet_pass = prompt_wallet_password(&args.value_of("wallet_pass")); - let wallet = rt.block_on(HttpWallet::async_open_wallet( + let wallet = rt_handle.block_on(HttpWallet::async_open_wallet( &server_config.wallet_owner_url, &server_config.wallet_owner_api_secret(), &wallet_pass, @@ -181,8 +184,14 @@ fn real_main() -> Result<(), Box> { } }; - let tor_instance = rt.block_on(tor::async_init_tor( - PreferredRuntime::current().unwrap(), + let tor_runtime = if let Ok(r) = PreferredRuntime::create() { + r + } else { + return Err("No runtime found".into()); + }; + + let tor_instance = rt_handle.block_on(tor::async_init_tor( + tor_runtime, &config::get_grin_path(&chain_type).to_str().unwrap(), &server_config, ))?; @@ -192,7 +201,7 @@ fn real_main() -> Result<(), Box> { let stop_state = Arc::new(StopState::new()); let stop_state_clone = stop_state.clone(); - rt.spawn(async move { + rt_handle.spawn(async move { futures::executor::block_on(build_signals_fut()); tor_clone.lock().stop(); stop_state_clone.stop(); @@ -215,7 +224,7 @@ fn real_main() -> Result<(), Box> { ); let (_, http_server) = servers::mix_rpc::listen( - rt.handle(), + &rt_handle, server_config, next_mixer, Arc::new(wallet), diff --git a/tests/common/node.rs b/tests/common/node.rs index a554920..596dc85 100644 --- a/tests/common/node.rs +++ b/tests/common/node.rs @@ -70,7 +70,7 @@ impl IntegrationGrinNode { } pub fn to_client(&self) -> Arc { - Arc::new(HttpGrinNode::new(&self.api_address(), &None)) + Arc::new(HttpGrinNode::new(&self.api_address().to_string(), &None)) } } diff --git a/tests/common/server.rs b/tests/common/server.rs index ec20f1a..54c90a5 100644 --- a/tests/common/server.rs +++ b/tests/common/server.rs @@ -63,9 +63,9 @@ where .unwrap() .local_addr() .unwrap(), - grin_node_url: node.lock().api_address(), + grin_node_url: node.lock().api_address().to_string(), grin_node_secret_path: None, - wallet_owner_url: wallet.lock().owner_address(), + wallet_owner_url: wallet.lock().owner_address().to_string(), wallet_owner_secret_path: None, prev_server: None, next_server: match next_server { @@ -128,9 +128,9 @@ where .unwrap() .local_addr() .unwrap(), - grin_node_url: node.lock().api_address(), + grin_node_url: node.lock().api_address().to_string(), grin_node_secret_path: None, - wallet_owner_url: wallet.lock().owner_address(), + wallet_owner_url: wallet.lock().owner_address().to_string(), wallet_owner_secret_path: None, prev_server: Some(prev_server), next_server: match next_server { diff --git a/tests/common/wallet.rs b/tests/common/wallet.rs index 642514d..cf717a8 100644 --- a/tests/common/wallet.rs +++ b/tests/common/wallet.rs @@ -108,7 +108,7 @@ impl IntegrationGrinWallet { let owner_api = Arc::new(Owner::new(wallet.clone(), None)); let address_str = format!("127.0.0.1:{}", api_listen_port); - let owner_addr: SocketAddr = address_str.parse().unwrap(); + let address_str_2 = format!("127.0.0.1:{}", api_listen_port); let thr_wallet = wallet.clone(); let _thread_handle = thread::spawn(move || { controller::owner_listener( @@ -125,7 +125,7 @@ impl IntegrationGrinWallet { }); let http_client = Arc::new( - HttpWallet::async_open_wallet(&owner_addr, &None, &ZeroingString::from("pass")) + HttpWallet::async_open_wallet(&address_str_2, &None, &ZeroingString::from("pass")) .await .unwrap(), );