diff --git a/Cargo.toml b/Cargo.toml index 0d95e231..50ac9e40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ bigint = "4.2" env_logger = "0.5.4" rand = "0.4" structopt = "0.2" -tokio-current-thread = "0.1" +tokio = "0.1" tokio-io = "0.1" tokio-stdin = "0.1" diff --git a/core/Cargo.toml b/core/Cargo.toml index 048c464e..ba64ec2d 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -29,7 +29,6 @@ libp2p-mplex = { path = "../muxers/mplex" } rand = "0.5" tokio = "0.1" tokio-codec = "0.1" -tokio-current-thread = "0.1" tokio-timer = "0.2" assert_matches = "1.3" tokio-mock-task = "0.1" diff --git a/core/src/lib.rs b/core/src/lib.rs index 798405bb..82ee1a82 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -129,11 +129,12 @@ //! extern crate libp2p_ping; //! extern crate libp2p_core; //! extern crate libp2p_tcp_transport; -//! extern crate tokio_current_thread; +//! extern crate tokio; //! //! use futures::{Future, Stream}; //! use libp2p_ping::{Ping, PingOutput}; //! use libp2p_core::Transport; +//! use tokio::runtime::current_thread::Runtime; //! //! # fn main() { //! let ping_finished_future = libp2p_tcp_transport::TcpConfig::new() @@ -154,7 +155,8 @@ //! }); //! //! // Runs until the ping arrives. -//! tokio_current_thread::block_on_all(ping_finished_future).unwrap(); +//! let mut rt = Runtime::new().unwrap(); +//! let _ = rt.block_on(ping_finished_future).unwrap(); //! # } //! ``` //! @@ -191,8 +193,6 @@ extern crate tokio; #[cfg(test)] extern crate tokio_codec; #[cfg(test)] -extern crate tokio_current_thread; -#[cfg(test)] extern crate tokio_timer; #[cfg(test)] #[macro_use] diff --git a/misc/multistream-select/Cargo.toml b/misc/multistream-select/Cargo.toml index 0be9b8c7..fadd6812 100644 --- a/misc/multistream-select/Cargo.toml +++ b/misc/multistream-select/Cargo.toml @@ -14,5 +14,5 @@ tokio-io = "0.1" unsigned-varint = { version = "0.2.1", features = ["codec"] } [dev-dependencies] -tokio-current-thread = "0.1" +tokio = "0.1" tokio-tcp = "0.1" diff --git a/misc/multistream-select/src/lib.rs b/misc/multistream-select/src/lib.rs index 1e1c0dff..102dc37a 100644 --- a/misc/multistream-select/src/lib.rs +++ b/misc/multistream-select/src/lib.rs @@ -45,7 +45,7 @@ //! extern crate bytes; //! extern crate futures; //! extern crate multistream_select; -//! extern crate tokio_current_thread; +//! extern crate tokio; //! extern crate tokio_tcp; //! //! # fn main() { @@ -53,6 +53,7 @@ //! use multistream_select::dialer_select_proto; //! use futures::{Future, Sink, Stream}; //! use tokio_tcp::TcpStream; +//! use tokio::runtime::current_thread::Runtime; //! //! #[derive(Debug, Copy, Clone)] //! enum MyProto { Echo, Hello } @@ -68,7 +69,8 @@ //! dialer_select_proto(connec, protos).map(|r| r.0) //! }); //! -//! let negotiated_protocol: MyProto = tokio_current_thread::block_on_all(client) +//! let mut rt = Runtime::new().unwrap(); +//! let negotiated_protocol: MyProto = rt.block_on(client) //! .expect("failed to find a protocol"); //! println!("negotiated: {:?}", negotiated_protocol); //! # } @@ -80,7 +82,7 @@ //! extern crate bytes; //! extern crate futures; //! extern crate multistream_select; -//! extern crate tokio_current_thread; +//! extern crate tokio; //! extern crate tokio_tcp; //! //! # fn main() { @@ -88,6 +90,7 @@ //! use multistream_select::listener_select_proto; //! use futures::{Future, Sink, Stream}; //! use tokio_tcp::TcpListener; +//! use tokio::runtime::current_thread::Runtime; //! //! #[derive(Debug, Copy, Clone)] //! enum MyProto { Echo, Hello } @@ -108,7 +111,8 @@ //! Ok(()) //! }); //! -//! tokio_current_thread::block_on_all(server).expect("failed to run server"); +//! let mut rt = Runtime::new().unwrap(); +//! let _ = rt.block_on(server).expect("failed to run server"); //! # } //! ``` diff --git a/misc/multistream-select/src/protocol/dialer.rs b/misc/multistream-select/src/protocol/dialer.rs index 21c884fb..996b6447 100644 --- a/misc/multistream-select/src/protocol/dialer.rs +++ b/misc/multistream-select/src/protocol/dialer.rs @@ -183,8 +183,9 @@ impl Future for DialerFuture { #[cfg(test)] mod tests { - extern crate tokio_current_thread; + extern crate tokio; extern crate tokio_tcp; + use self::tokio::runtime::current_thread::Runtime; use self::tokio_tcp::{TcpListener, TcpStream}; use bytes::Bytes; use futures::Future; @@ -210,7 +211,8 @@ mod tests { dialer.send(DialerToListenerMessage::ProtocolRequest { name: p }) }); - match tokio_current_thread::block_on_all(server.join(client)) { + let mut rt = Runtime::new().unwrap(); + match rt.block_on(server.join(client)) { Err(MultistreamSelectError::WrongProtocolName) => (), _ => panic!(), } diff --git a/misc/multistream-select/src/protocol/listener.rs b/misc/multistream-select/src/protocol/listener.rs index d39fe86e..e20f3a50 100644 --- a/misc/multistream-select/src/protocol/listener.rs +++ b/misc/multistream-select/src/protocol/listener.rs @@ -225,8 +225,9 @@ impl Future for ListenerFuture { #[cfg(test)] mod tests { - extern crate tokio_current_thread; + extern crate tokio; extern crate tokio_tcp; + use self::tokio::runtime::current_thread::Runtime; use self::tokio_tcp::{TcpListener, TcpStream}; use bytes::Bytes; use futures::Future; @@ -252,7 +253,8 @@ mod tests { .from_err() .and_then(move |stream| Dialer::new(stream)); - match tokio_current_thread::block_on_all(server.join(client)) { + let mut rt = Runtime::new().unwrap(); + match rt.block_on(server.join(client)) { Err(MultistreamSelectError::WrongProtocolName) => (), _ => panic!(), } diff --git a/misc/multistream-select/src/tests.rs b/misc/multistream-select/src/tests.rs index b9bd569d..6120bea6 100644 --- a/misc/multistream-select/src/tests.rs +++ b/misc/multistream-select/src/tests.rs @@ -22,9 +22,10 @@ #![cfg(test)] -extern crate tokio_current_thread; +extern crate tokio; extern crate tokio_tcp; +use self::tokio::runtime::current_thread::Runtime; use self::tokio_tcp::{TcpListener, TcpStream}; use bytes::Bytes; use dialer_select::{dialer_select_proto_parallel, dialer_select_proto_serial}; @@ -69,8 +70,8 @@ fn negotiate_with_self_succeeds() { assert_eq!(proto, "/hello/1.0.0"); Ok(()) }); - - tokio_current_thread::block_on_all(server.join(client)).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(server.join(client)).unwrap(); } #[test] @@ -100,9 +101,9 @@ fn select_proto_basic() { ].into_iter(); dialer_select_proto(connec, protos).map(|r| r.0) }); - + let mut rt = Runtime::new().unwrap(); let (dialer_chosen, listener_chosen) = - tokio_current_thread::block_on_all(client.join(server)).unwrap(); + rt.block_on(client.join(server)).unwrap(); assert_eq!(dialer_chosen, 3); assert_eq!(listener_chosen, 1); } @@ -134,8 +135,8 @@ fn no_protocol_found() { ].into_iter(); dialer_select_proto(connec, protos).map(|r| r.0) }); - - match tokio_current_thread::block_on_all(client.join(server)) { + let mut rt = Runtime::new().unwrap(); + match rt.block_on(client.join(server)) { Err(ProtocolChoiceError::NoProtocolFound) => (), _ => panic!(), } @@ -169,8 +170,9 @@ fn select_proto_parallel() { dialer_select_proto_parallel(connec, protos).map(|r| r.0) }); + let mut rt = Runtime::new().unwrap(); let (dialer_chosen, listener_chosen) = - tokio_current_thread::block_on_all(client.join(server)).unwrap(); + rt.block_on(client.join(server)).unwrap(); assert_eq!(dialer_chosen, 3); assert_eq!(listener_chosen, 1); } @@ -200,8 +202,9 @@ fn select_proto_serial() { dialer_select_proto_serial(connec, protos).map(|r| r.0) }); + let mut rt = Runtime::new().unwrap(); let (dialer_chosen, listener_chosen) = - tokio_current_thread::block_on_all(client.join(server)).unwrap(); + rt.block_on(client.join(server)).unwrap(); assert_eq!(dialer_chosen, 3); assert_eq!(listener_chosen, 1); } diff --git a/muxers/mplex/Cargo.toml b/muxers/mplex/Cargo.toml index 0f2fbf82..20fe408c 100644 --- a/muxers/mplex/Cargo.toml +++ b/muxers/mplex/Cargo.toml @@ -17,4 +17,4 @@ unsigned-varint = { version = "0.2.1", features = ["codec"] } [dev-dependencies] libp2p-tcp-transport = { path = "../../transports/tcp" } -tokio-current-thread = "0.1" +tokio = "0.1" diff --git a/muxers/mplex/tests/two_peers.rs b/muxers/mplex/tests/two_peers.rs index 26fd1507..caf081a2 100644 --- a/muxers/mplex/tests/two_peers.rs +++ b/muxers/mplex/tests/two_peers.rs @@ -23,7 +23,7 @@ extern crate futures; extern crate libp2p_mplex as multiplex; extern crate libp2p_core as swarm; extern crate libp2p_tcp_transport as tcp; -extern crate tokio_current_thread; +extern crate tokio; extern crate tokio_io; use futures::future::Future; @@ -33,6 +33,7 @@ use std::thread; use swarm::{muxing, Transport}; use tcp::TcpConfig; use tokio_io::codec::length_delimited::Framed; +use tokio::runtime::current_thread::Runtime; #[test] fn client_to_server_outbound() { @@ -67,7 +68,8 @@ fn client_to_server_outbound() { Ok(()) }); - tokio_current_thread::block_on_all(future).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(future).unwrap(); }); let transport = TcpConfig::new().with_upgrade(multiplex::MplexConfig::new()); @@ -80,7 +82,8 @@ fn client_to_server_outbound() { .and_then(|server| server.send("hello world".into())) .map(|_| ()); - tokio_current_thread::block_on_all(future).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(future).unwrap(); bg_thread.join().unwrap(); } @@ -117,7 +120,8 @@ fn client_to_server_inbound() { Ok(()) }); - tokio_current_thread::block_on_all(future).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(future).unwrap(); }); let transport = TcpConfig::new().with_upgrade(multiplex::MplexConfig::new()); @@ -130,6 +134,7 @@ fn client_to_server_inbound() { .and_then(|server| server.send("hello world".into())) .map(|_| ()); - tokio_current_thread::block_on_all(future).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(future).unwrap(); bg_thread.join().unwrap(); } diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index e055733e..b2170f56 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -22,4 +22,4 @@ void = "1.0" [dev-dependencies] libp2p-tcp-transport = { path = "../../transports/tcp" } -tokio-current-thread = "0.1" +tokio = "0.1" diff --git a/protocols/identify/src/protocol.rs b/protocols/identify/src/protocol.rs index 671dbc6b..44e19873 100644 --- a/protocols/identify/src/protocol.rs +++ b/protocols/identify/src/protocol.rs @@ -211,8 +211,9 @@ fn parse_proto_msg(msg: BytesMut) -> Result<(IdentifyInfo, Multiaddr), IoError> #[cfg(test)] mod tests { extern crate libp2p_tcp_transport; - extern crate tokio_current_thread; + extern crate tokio; + use self::tokio::runtime::current_thread::Runtime; use self::libp2p_tcp_transport::TcpConfig; use futures::{Future, Stream}; use libp2p_core::{PublicKey, Transport}; @@ -255,8 +256,8 @@ mod tests { ), _ => panic!(), }); - - let _ = tokio_current_thread::block_on_all(future).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(future).unwrap(); }); let transport = TcpConfig::new().with_upgrade(IdentifyProtocolConfig); @@ -291,8 +292,8 @@ mod tests { } _ => panic!(), }); - - let _ = tokio_current_thread::block_on_all(future).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(future).unwrap(); bg_thread.join().unwrap(); } } diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 12a85722..1bf93426 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -30,4 +30,4 @@ unsigned-varint = { version = "0.2.1", features = ["codec"] } [dev-dependencies] libp2p-tcp-transport = { path = "../../transports/tcp" } rand = "0.4.2" -tokio-current-thread = "0.1" +tokio = "0.1" diff --git a/protocols/kad/src/protocol.rs b/protocols/kad/src/protocol.rs index 3ef81648..2ba18e5e 100644 --- a/protocols/kad/src/protocol.rs +++ b/protocols/kad/src/protocol.rs @@ -409,7 +409,7 @@ fn proto_to_msg(mut message: protobuf_structs::dht::Message) -> Result unreachable!(), }) .map(|_| ()); - - tokio_current_thread::block_on_all(server.select(client).map_err(|_| panic!())).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(server.select(client).map_err(|_| panic!())).unwrap(); } #[test] @@ -489,7 +492,7 @@ mod tests { }, _ => unreachable!(), }); - - tokio_current_thread::block_on_all(server.select(client)).unwrap_or_else(|_| panic!()); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(server.select(client)).unwrap_or_else(|_| panic!()); } } diff --git a/protocols/secio/Cargo.toml b/protocols/secio/Cargo.toml index 3a156ba9..09511aff 100644 --- a/protocols/secio/Cargo.toml +++ b/protocols/secio/Cargo.toml @@ -40,5 +40,5 @@ aes-all = ["aesni", "lazy_static"] [dev-dependencies] libp2p-tcp-transport = { path = "../../transports/tcp" } -tokio-current-thread = "0.1" +tokio = "0.1" tokio-tcp = "0.1" diff --git a/protocols/secio/src/codec/mod.rs b/protocols/secio/src/codec/mod.rs index 5394a33e..a15d3c86 100644 --- a/protocols/secio/src/codec/mod.rs +++ b/protocols/secio/src/codec/mod.rs @@ -119,8 +119,9 @@ where #[cfg(test)] mod tests { - extern crate tokio_current_thread; + extern crate tokio; extern crate tokio_tcp; + use self::tokio::runtime::current_thread::Runtime; use self::tokio_tcp::TcpListener; use self::tokio_tcp::TcpStream; use stream_cipher::{ctr, Cipher}; @@ -164,8 +165,9 @@ mod tests { let data_sent = encoder.send(BytesMut::from(data.to_vec())).from_err(); let data_received = decoder.into_future().map(|(n, _)| n).map_err(|(e, _)| e); + let mut rt = Runtime::new().unwrap(); - let (_, decoded) = tokio_current_thread::block_on_all(data_sent.join(data_received)) + let (_, decoded) = rt.block_on(data_sent.join(data_received)) .map_err(|_| ()) .unwrap(); assert_eq!(&decoded.unwrap()[..], &data[..]); @@ -223,7 +225,8 @@ mod tests { .and_then(|server| server.into_future().map_err(|(e, _)| e.into())) .map(|recved| recved.0.unwrap().to_vec()); - let received = tokio_current_thread::block_on_all(fin).unwrap(); + let mut rt = Runtime::new().unwrap(); + let received = rt.block_on(fin).unwrap(); assert_eq!(received, data); } diff --git a/protocols/secio/src/handshake.rs b/protocols/secio/src/handshake.rs index 5c575658..18e2de7f 100644 --- a/protocols/secio/src/handshake.rs +++ b/protocols/secio/src/handshake.rs @@ -646,8 +646,9 @@ where ::hmac::Hmac: Clone { #[cfg(test)] mod tests { - extern crate tokio_current_thread; + extern crate tokio; extern crate tokio_tcp; + use self::tokio::runtime::current_thread::Runtime; use self::tokio_tcp::TcpListener; use self::tokio_tcp::TcpStream; use super::handshake; @@ -712,8 +713,8 @@ mod tests { let client = TcpStream::connect(&listener_addr) .map_err(|e| e.into()) .and_then(move |stream| handshake(stream, key2)); - - tokio_current_thread::block_on_all(server.join(client)).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(server.join(client)).unwrap(); } #[test] diff --git a/protocols/secio/src/lib.rs b/protocols/secio/src/lib.rs index 8ec9991a..8ccc2310 100644 --- a/protocols/secio/src/lib.rs +++ b/protocols/secio/src/lib.rs @@ -30,7 +30,7 @@ //! //! ```no_run //! extern crate futures; -//! extern crate tokio_current_thread; +//! extern crate tokio; //! extern crate tokio_io; //! extern crate libp2p_core; //! extern crate libp2p_secio; @@ -42,6 +42,7 @@ //! use libp2p_core::{Multiaddr, Transport, upgrade}; //! use libp2p_tcp_transport::TcpConfig; //! use tokio_io::io::write_all; +//! use tokio::runtime::current_thread::Runtime; //! //! let transport = TcpConfig::new() //! .with_upgrade({ @@ -63,7 +64,8 @@ //! write_all(connection, "hello world") //! }); //! -//! tokio_current_thread::block_on_all(future).unwrap(); +//! let mut rt = Runtime::new().unwrap(); +//! let _ = rt.block_on(future).unwrap(); //! # } //! ``` //! diff --git a/transports/dns/Cargo.toml b/transports/dns/Cargo.toml index c67135c9..5f73b959 100644 --- a/transports/dns/Cargo.toml +++ b/transports/dns/Cargo.toml @@ -14,3 +14,4 @@ tokio-io = "0.1" [dev-dependencies] libp2p-tcp-transport = { path = "../../transports/tcp" } +tokio = "0.1" \ No newline at end of file diff --git a/transports/tcp/Cargo.toml b/transports/tcp/Cargo.toml index 51ea0a96..4111e10e 100644 --- a/transports/tcp/Cargo.toml +++ b/transports/tcp/Cargo.toml @@ -14,4 +14,4 @@ tokio-io = "0.1" tokio-tcp = "0.1" [dev-dependencies] -tokio-current-thread = "0.1" +tokio = "0.1" diff --git a/transports/tcp/src/lib.rs b/transports/tcp/src/lib.rs index 2064003e..e0b7ab42 100644 --- a/transports/tcp/src/lib.rs +++ b/transports/tcp/src/lib.rs @@ -47,9 +47,6 @@ extern crate tk_listen; extern crate tokio_io; extern crate tokio_tcp; -#[cfg(test)] -extern crate tokio_current_thread; - use futures::{future, future::FutureResult, prelude::*, Async, Poll}; use multiaddr::{Protocol, Multiaddr, ToMultiaddr}; use std::fmt; @@ -394,6 +391,8 @@ impl Drop for TcpTransStream { #[cfg(test)] mod tests { + extern crate tokio; + use self::tokio::runtime::current_thread::Runtime; use super::{multiaddr_to_socketaddr, TcpConfig}; use futures::stream::Stream; use futures::Future; @@ -401,7 +400,6 @@ mod tests { use std; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use swarm::Transport; - use tokio_current_thread; use tokio_io; #[test] @@ -460,6 +458,8 @@ mod tests { std::thread::spawn(move || { let addr = "/ip4/127.0.0.1/tcp/12345".parse::().unwrap(); let tcp = TcpConfig::new(); + let mut rt = Runtime::new().unwrap(); + let handle = rt.handle(); let listener = tcp.listen_on(addr).unwrap().0.for_each(|(sock, _)| { sock.and_then(|sock| { // Define what to do with the socket that just connected to us @@ -469,13 +469,14 @@ mod tests { .map_err(|err| panic!("IO error {:?}", err)); // Spawn the future as a concurrent task - tokio_current_thread::spawn(handle_conn); + handle.spawn(handle_conn).unwrap(); Ok(()) }) }); - tokio_current_thread::block_on_all(listener).unwrap(); + rt.block_on(listener).unwrap(); + rt.run().unwrap(); }); std::thread::sleep(std::time::Duration::from_millis(100)); let addr = "/ip4/127.0.0.1/tcp/12345".parse::().unwrap(); @@ -488,8 +489,8 @@ mod tests { Ok(()) }); // Execute the future in our event loop - tokio_current_thread::block_on_all(action).unwrap(); - std::thread::sleep(std::time::Duration::from_millis(100)); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(action).unwrap(); } #[test] diff --git a/transports/uds/Cargo.toml b/transports/uds/Cargo.toml index 0b84a62a..132aa3a8 100644 --- a/transports/uds/Cargo.toml +++ b/transports/uds/Cargo.toml @@ -13,5 +13,5 @@ tokio-uds = "0.2" [target.'cfg(all(unix, not(target_os = "emscripten")))'.dev-dependencies] tempfile = "3.0" -tokio-current-thread = "0.1" +tokio = "0.1" tokio-io = "0.1" diff --git a/transports/uds/src/lib.rs b/transports/uds/src/lib.rs index c326fa9f..9f6cb8f7 100644 --- a/transports/uds/src/lib.rs +++ b/transports/uds/src/lib.rs @@ -56,9 +56,9 @@ extern crate tokio_uds; #[cfg(test)] extern crate tempfile; #[cfg(test)] -extern crate tokio_current_thread; -#[cfg(test)] extern crate tokio_io; +#[cfg(test)] +extern crate tokio; use futures::future::{self, Future, FutureResult}; use futures::stream::Stream; @@ -164,6 +164,7 @@ fn multiaddr_to_path(addr: &Multiaddr) -> Result { #[cfg(test)] mod tests { + use tokio::runtime::current_thread::Runtime; use super::{multiaddr_to_path, UdsConfig}; use futures::stream::Stream; use futures::Future; @@ -171,7 +172,6 @@ mod tests { use std::{self, borrow::Cow, path::Path}; use libp2p_core::Transport; use tempfile; - use tokio_current_thread; use tokio_io; #[test] @@ -194,7 +194,6 @@ mod tests { #[test] fn communicating_between_dialer_and_listener() { use std::io::Write; - let temp_dir = tempfile::tempdir().unwrap(); let socket = temp_dir.path().join("socket"); let addr = Multiaddr::from(Protocol::Unix(Cow::Owned(socket.to_string_lossy().into_owned()))); @@ -202,6 +201,9 @@ mod tests { std::thread::spawn(move || { let tcp = UdsConfig::new(); + + let mut rt = Runtime::new().unwrap(); + let handle = rt.handle(); let listener = tcp.listen_on(addr2).unwrap().0.for_each(|(sock, _)| { sock.and_then(|sock| { // Define what to do with the socket that just connected to us @@ -211,13 +213,13 @@ mod tests { .map_err(|err| panic!("IO error {:?}", err)); // Spawn the future as a concurrent task - tokio_current_thread::spawn(handle_conn); - + handle.spawn(handle_conn).unwrap(); Ok(()) }) }); - tokio_current_thread::block_on_all(listener).unwrap(); + rt.block_on(listener).unwrap(); + rt.run().unwrap(); }); std::thread::sleep(std::time::Duration::from_millis(100)); let tcp = UdsConfig::new(); @@ -229,8 +231,8 @@ mod tests { Ok(()) }); // Execute the future in our event loop - tokio_current_thread::block_on_all(action).unwrap(); - std::thread::sleep(std::time::Duration::from_millis(100)); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(action).unwrap(); } #[test] diff --git a/transports/websocket/Cargo.toml b/transports/websocket/Cargo.toml index 1a24209d..addbb90c 100644 --- a/transports/websocket/Cargo.toml +++ b/transports/websocket/Cargo.toml @@ -22,4 +22,4 @@ stdweb = { version = "0.1.3", default-features = false } [target.'cfg(not(target_os = "emscripten"))'.dev-dependencies] libp2p-tcp-transport = { path = "../tcp" } -tokio-current-thread = "0.1" +tokio = "0.1" diff --git a/transports/websocket/src/desktop.rs b/transports/websocket/src/desktop.rs index 14275074..5c347fd9 100644 --- a/transports/websocket/src/desktop.rs +++ b/transports/websocket/src/desktop.rs @@ -259,7 +259,8 @@ fn client_addr_to_ws(client_addr: &Multiaddr, is_wss: bool) -> String { #[cfg(test)] mod tests { extern crate libp2p_tcp_transport as tcp; - extern crate tokio_current_thread; + extern crate tokio; + use self::tokio::runtime::current_thread::Runtime; use futures::{Future, Stream}; use multiaddr::Multiaddr; use swarm::Transport; @@ -285,7 +286,8 @@ mod tests { .select(dialer) .map_err(|(e, _)| e) .and_then(|(_, n)| n); - tokio_current_thread::block_on_all(future).unwrap(); + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(future).unwrap(); } #[test] @@ -308,7 +310,9 @@ mod tests { .select(dialer) .map_err(|(e, _)| e) .and_then(|(_, n)| n); - tokio_current_thread::block_on_all(future).unwrap(); + + let mut rt = Runtime::new().unwrap(); + let _ = rt.block_on(future).unwrap(); } #[test]