Several changes.

- Pin `futures_codec` to version 0.3.3 as later versions require
at least bytes-0.5 which he have not upgraded to yet.
- Replace `futures::executor::block_on` with `async_std::task::block_on`
where `async-std` is already a dependency to work around an issue with
`park`/`unpark` behaviour.
- Use the published version of `quicksink`.
This commit is contained in:
Toralf Wittner
2019-12-18 16:31:31 +01:00
parent 34a3e5c30c
commit f293594144
15 changed files with 20 additions and 20 deletions

View File

@ -358,7 +358,7 @@ mod tests {
#[test] #[test]
fn incoming_event() { fn incoming_event() {
futures::executor::block_on(async move { async_std::task::block_on(async move {
let mem_transport = transport::MemoryTransport::default(); let mem_transport = transport::MemoryTransport::default();
let mut listeners = ListenersStream::new(mem_transport); let mut listeners = ListenersStream::new(mem_transport);

View File

@ -113,7 +113,7 @@ fn deny_incoming_connec() {
swarm1.listen_on("/ip4/127.0.0.1/tcp/0".parse().unwrap()).unwrap(); swarm1.listen_on("/ip4/127.0.0.1/tcp/0".parse().unwrap()).unwrap();
let address = futures::executor::block_on(future::poll_fn(|cx| { let address = async_std::task::block_on(future::poll_fn(|cx| {
if let Poll::Ready(NetworkEvent::NewListenerAddress { listen_addr, .. }) = swarm1.poll(cx) { if let Poll::Ready(NetworkEvent::NewListenerAddress { listen_addr, .. }) = swarm1.poll(cx) {
Poll::Ready(listen_addr) Poll::Ready(listen_addr)
} else { } else {
@ -126,7 +126,7 @@ fn deny_incoming_connec() {
.into_not_connected().unwrap() .into_not_connected().unwrap()
.connect(address.clone(), TestHandler::default().into_node_handler_builder()); .connect(address.clone(), TestHandler::default().into_node_handler_builder());
futures::executor::block_on(future::poll_fn(|cx| -> Poll<Result<(), io::Error>> { async_std::task::block_on(future::poll_fn(|cx| -> Poll<Result<(), io::Error>> {
match swarm1.poll(cx) { match swarm1.poll(cx) {
Poll::Ready(NetworkEvent::IncomingConnection(inc)) => drop(inc), Poll::Ready(NetworkEvent::IncomingConnection(inc)) => drop(inc),
Poll::Ready(_) => unreachable!(), Poll::Ready(_) => unreachable!(),
@ -182,7 +182,7 @@ fn dial_self() {
swarm.listen_on("/ip4/127.0.0.1/tcp/0".parse().unwrap()).unwrap(); swarm.listen_on("/ip4/127.0.0.1/tcp/0".parse().unwrap()).unwrap();
let (address, mut swarm) = futures::executor::block_on( let (address, mut swarm) = async_std::task::block_on(
future::lazy(move |cx| { future::lazy(move |cx| {
if let Poll::Ready(NetworkEvent::NewListenerAddress { listen_addr, .. }) = swarm.poll(cx) { if let Poll::Ready(NetworkEvent::NewListenerAddress { listen_addr, .. }) = swarm.poll(cx) {
Ok::<_, void::Void>((listen_addr, swarm)) Ok::<_, void::Void>((listen_addr, swarm))
@ -196,7 +196,7 @@ fn dial_self() {
let mut got_dial_err = false; let mut got_dial_err = false;
let mut got_inc_err = false; let mut got_inc_err = false;
futures::executor::block_on(future::poll_fn(|cx| -> Poll<Result<(), io::Error>> { async_std::task::block_on(future::poll_fn(|cx| -> Poll<Result<(), io::Error>> {
loop { loop {
match swarm.poll(cx) { match swarm.poll(cx) {
Poll::Ready(NetworkEvent::UnknownPeerDialError { Poll::Ready(NetworkEvent::UnknownPeerDialError {
@ -284,7 +284,7 @@ fn multiple_addresses_err() {
.connect_iter(addresses.clone(), TestHandler::default().into_node_handler_builder()) .connect_iter(addresses.clone(), TestHandler::default().into_node_handler_builder())
.unwrap(); .unwrap();
futures::executor::block_on(future::poll_fn(|cx| -> Poll<Result<(), io::Error>> { async_std::task::block_on(future::poll_fn(|cx| -> Poll<Result<(), io::Error>> {
loop { loop {
match swarm.poll(cx) { match swarm.poll(cx) {
Poll::Ready(NetworkEvent::DialError { Poll::Ready(NetworkEvent::DialError {

View File

@ -280,7 +280,7 @@ fn raw_swarm_simultaneous_connect() {
} }
}); });
if futures::executor::block_on(future) { if async_std::task::block_on(future) {
// The test exercised what we wanted to exercise: a simultaneous connect. // The test exercised what we wanted to exercise: a simultaneous connect.
break break
} }

View File

@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"]
bytes = "0.4.5" bytes = "0.4.5"
fnv = "1.0" fnv = "1.0"
futures = "0.3.1" futures = "0.3.1"
futures_codec = "0.3.1" futures_codec = "= 0.3.3"
libp2p-core = { version = "0.13.0", path = "../../core" } libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4" log = "0.4"
parking_lot = "0.9" parking_lot = "0.9"

View File

@ -11,7 +11,7 @@ categories = ["network-programming", "asynchronous"]
[dependencies] [dependencies]
bytes = "0.4" bytes = "0.4"
futures_codec = "0.3.1" futures_codec = "= 0.3.3"
futures = "0.3.1" futures = "0.3.1"
libp2p-core = { version = "0.13.0", path = "../../core" } libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" } libp2p-swarm = { version = "0.3.0", path = "../../swarm" }

View File

@ -315,7 +315,7 @@ mod tests {
// it will permit the connection to be closed, as defined by // it will permit the connection to be closed, as defined by
// `IdentifyHandler::connection_keep_alive`. Hence the test succeeds if // `IdentifyHandler::connection_keep_alive`. Hence the test succeeds if
// either `Identified` event arrives correctly. // either `Identified` event arrives correctly.
futures::executor::block_on(async move { async_std::task::block_on(async move {
loop { loop {
match future::select(swarm1.next(), swarm2.next()).await.factor_second().0 { match future::select(swarm1.next(), swarm2.next()).await.factor_second().0 {
future::Either::Left(Some(Ok(IdentifyEvent::Received { info, .. }))) => { future::Either::Left(Some(Ok(IdentifyEvent::Received { info, .. }))) => {

View File

@ -14,7 +14,7 @@ arrayvec = "0.5.1"
bytes = "0.4" bytes = "0.4"
either = "1.5" either = "1.5"
fnv = "1.0" fnv = "1.0"
futures_codec = "0.3.1" futures_codec = "= 0.3.3"
futures = "0.3.1" futures = "0.3.1"
log = "0.4" log = "0.4"
libp2p-core = { version = "0.13.0", path = "../../core" } libp2p-core = { version = "0.13.0", path = "../../core" }

View File

@ -282,7 +282,7 @@ mod tests {
fn tick(h: &mut PingHandler<TcpStream>) fn tick(h: &mut PingHandler<TcpStream>)
-> ProtocolsHandlerEvent<protocol::Ping, (), PingResult, PingFailure> -> ProtocolsHandlerEvent<protocol::Ping, (), PingResult, PingFailure>
{ {
futures::executor::block_on(future::poll_fn(|cx| h.poll(cx) )) async_std::task::block_on(future::poll_fn(|cx| h.poll(cx) ))
} }
#[test] #[test]

View File

@ -84,7 +84,7 @@ fn ping() {
}; };
let result = future::select(Box::pin(peer1), Box::pin(peer2)); let result = future::select(Box::pin(peer1), Box::pin(peer2));
let ((p1, p2, rtt), _) = futures::executor::block_on(result).factor_first(); let ((p1, p2, rtt), _) = async_std::task::block_on(result).factor_first();
assert!(p1 == peer1_id && p2 == peer2_id || p1 == peer2_id && p2 == peer1_id); assert!(p1 == peer1_id && p2 == peer2_id || p1 == peer2_id && p2 == peer1_id);
assert!(rtt < Duration::from_millis(50)); assert!(rtt < Duration::from_millis(50));
} }

View File

@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"]
[dependencies] [dependencies]
bytes = "0.4.12" bytes = "0.4.12"
futures = "0.3.1" futures = "0.3.1"
futures_codec = "0.3.1" futures_codec = "= 0.3.3"
libp2p-core = { version = "0.13.0", path = "../../core" } libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.8" log = "0.4.8"
protobuf = "2.8.1" protobuf = "2.8.1"

View File

@ -19,7 +19,7 @@ lazy_static = "1.2.0"
libp2p-core = { version = "0.13.0", path = "../../core" } libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.6" log = "0.4.6"
protobuf = "2.8" protobuf = "2.8"
quicksink = { git = "https://github.com/paritytech/quicksink.git" } quicksink = "0.1"
rand = "0.7" rand = "0.7"
rw-stream-sink = { version = "0.1.1", path = "../../misc/rw-stream-sink" } rw-stream-sink = { version = "0.1.1", path = "../../misc/rw-stream-sink" }
sha2 = "0.8.0" sha2 = "0.8.0"

View File

@ -156,7 +156,7 @@ mod tests {
); );
let data = b"hello world"; let data = b"hello world";
futures::executor::block_on(async move { async_std::task::block_on(async move {
encoder.send(data.to_vec()).await.unwrap(); encoder.send(data.to_vec()).await.unwrap();
let rx = decoder.next().await.unwrap().unwrap(); let rx = decoder.next().await.unwrap().unwrap();
assert_eq!(rx, data); assert_eq!(rx, data);
@ -209,7 +209,7 @@ mod tests {
codec.send(data.to_vec().into()).await.unwrap(); codec.send(data.to_vec().into()).await.unwrap();
}; };
futures::executor::block_on(future::join(client, server)); async_std::task::block_on(future::join(client, server));
} }
#[test] #[test]

View File

@ -419,7 +419,7 @@ mod tests {
} }
}); });
futures::executor::block_on(async move { async_std::task::block_on(async move {
let listen_addr = l_a_rx.await.unwrap(); let listen_addr = l_a_rx.await.unwrap();
let connec = async_std::net::TcpStream::connect(&listen_addr).await.unwrap(); let connec = async_std::net::TcpStream::connect(&listen_addr).await.unwrap();
let mut codec = handshake(connec, key2).await.unwrap().0; let mut codec = handshake(connec, key2).await.unwrap().0;

View File

@ -486,7 +486,7 @@ mod tests {
.for_each(|_| futures::future::ready(())); .for_each(|_| futures::future::ready(()));
let client = TcpConfig::new().dial(addr).expect("dialer"); let client = TcpConfig::new().dial(addr).expect("dialer");
futures::executor::block_on(futures::future::join(server, client)).1.unwrap(); async_std::task::block_on(futures::future::join(server, client)).1.unwrap();
} }
#[test] #[test]

View File

@ -16,7 +16,7 @@ either = "1.5.3"
futures = "0.3.1" futures = "0.3.1"
libp2p-core = { version = "0.13.0", path = "../../core" } libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.8" log = "0.4.8"
quicksink = { git = "https://github.com/paritytech/quicksink.git" } quicksink = "0.1"
rustls = "0.16" rustls = "0.16"
rw-stream-sink = { version = "0.1.1", path = "../../misc/rw-stream-sink" } rw-stream-sink = { version = "0.1.1", path = "../../misc/rw-stream-sink" }
soketto = { git = "https://github.com/paritytech/soketto.git", branch = "develop", features = ["deflate"] } soketto = { git = "https://github.com/paritytech/soketto.git", branch = "develop", features = ["deflate"] }