Created
May 31, 2021 02:14
-
-
Save bltavares/39b4ad5c76a413bcaaf1f5da5acdee2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This concludes immediatlly, as expected | |
#[async_std::test] | |
async fn test_listerner_client() { | |
let addr = next_test_ip4(); | |
// setup listener | |
let listener = UtpListener::bind(addr).await.unwrap(); | |
// spawn a background task waiting for the connection | |
task::spawn(async move { listener.accept().await.unwrap() }); | |
// Connect to the server | |
let client = task::spawn(async move { | |
UtpSocket::connect(addr).await.unwrap(); | |
}); | |
// await tasks to conclude | |
client.await; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This takes over 60s to run, but eventually concludes | |
#[async_std::test] | |
async fn test_listerner_client() { | |
let addr = next_test_ip4(); | |
// setup listener | |
let listener = UtpListener::bind(addr).await.unwrap(); | |
// spawn a background task waiting for the connection | |
let server = task::spawn(async move { listener.accept().await.unwrap() }); | |
// Connect to the server | |
let client = task::spawn(async move { | |
UtpSocket::connect(addr).await.unwrap(); | |
}); | |
// await tasks to conclude | |
client.await; | |
server.await; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment