Skip to content

Commit

Permalink
fix(tests): migrate tests from async-std to tokio in transports/quic
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyasmohd committed Feb 2, 2025
1 parent fef298b commit 593c70a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions transports/quic/tests/stream_compliance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ use libp2p_core::{
};
use libp2p_quic as quic;

#[async_std::test]
#[cfg(feature = "tokio")]
#[tokio::test]
async fn close_implies_flush() {
let (alice, bob) = connected_peers().await;

libp2p_muxer_test_harness::close_implies_flush(alice, bob).await;
}

#[async_std::test]
#[cfg(feature = "tokio")]
#[tokio::test]
async fn read_after_close() {
let (alice, bob) = connected_peers().await;

Expand All @@ -36,10 +38,10 @@ async fn connected_peers() -> (quic::Connection, quic::Connection) {
let (dialer_conn_sender, dialer_conn_receiver) = oneshot::channel();
let (listener_conn_sender, listener_conn_receiver) = oneshot::channel();

async_std::task::spawn(async move {
tokio::spawn(async move {
let (upgrade, _) = listener.next().await.unwrap().into_incoming().unwrap();

async_std::task::spawn(async move {
tokio::spawn(async move {
let (_, connection) = upgrade.await.unwrap();

let _ = listener_conn_sender.send(connection);
Expand All @@ -58,13 +60,13 @@ async fn connected_peers() -> (quic::Connection, quic::Connection) {
},
)
.unwrap();
async_std::task::spawn(async move {
tokio::spawn(async move {
let connection = dial_fut.await.unwrap().1;

let _ = dialer_conn_sender.send(connection);
});

async_std::task::spawn(async move {
tokio::spawn(async move {
loop {
dialer.next().await;
}
Expand All @@ -75,10 +77,10 @@ async fn connected_peers() -> (quic::Connection, quic::Connection) {
.unwrap()
}

fn new_transport() -> quic::async_std::Transport {
fn new_transport() -> quic::tokio::Transport {
let keypair = libp2p_identity::Keypair::generate_ed25519();
let mut config = quic::Config::new(&keypair);
config.handshake_timeout = Duration::from_secs(1);

quic::async_std::Transport::new(config)
quic::tokio::Transport::new(config)
}

0 comments on commit 593c70a

Please sign in to comment.