|
1 | 1 | use anyhow::{Context as _, Result, anyhow}; |
2 | 2 | use core::future::Future; |
3 | | -use futures::try_join; |
4 | 3 | use test_programs::p3::wasi::sockets::ip_name_lookup::resolve_addresses; |
5 | 4 | use test_programs::p3::wasi::sockets::types::{IpAddress, IpSocketAddress, TcpSocket}; |
6 | 5 | use test_programs::p3::wasi::tls::client::Connector; |
@@ -31,32 +30,23 @@ async fn test_tls_sample_application(domain: &str, ip: IpAddress) -> Result<()> |
31 | 30 | let (tls_tx, tls_tx_err_fut) = conn.send(data_rx); |
32 | 31 | let sock_tx_fut = sock.send(tls_tx); |
33 | 32 |
|
34 | | - try_join!( |
35 | | - async { |
36 | | - Connector::connect(conn, domain.into()) |
37 | | - .await |
38 | | - .context("handshake failed") |
39 | | - }, |
40 | | - async { |
41 | | - let buf = data_tx.write_all(request.into()).await; |
42 | | - assert!(buf.is_empty()); |
43 | | - drop(data_tx); |
44 | | - Ok(()) |
45 | | - }, |
46 | | - async { |
47 | | - let response = tls_rx.collect().await; |
48 | | - let response = String::from_utf8(response)?; |
49 | | - if response.contains("HTTP/1.1 200 OK") { |
50 | | - Ok(()) |
51 | | - } else { |
52 | | - Err(anyhow!("server did not respond with 200 OK: {response}")) |
53 | | - } |
54 | | - }, |
55 | | - async { sock_rx_fut.await.context("failed to receive ciphertext") }, |
56 | | - async { sock_tx_fut.await.context("failed to send ciphertext") }, |
57 | | - async { tls_rx_fut.await.context("failed to receive plaintext") }, |
58 | | - async { tls_tx_err_fut.await.context("failed to send plaintext") }, |
59 | | - )?; |
| 33 | + Connector::connect(conn, domain.into()) |
| 34 | + .await |
| 35 | + .context("tls handshake failed")?; |
| 36 | + let buf = data_tx.write_all(request.into()).await; |
| 37 | + assert!(buf.is_empty()); |
| 38 | + |
| 39 | + let response = tls_rx.collect().await; |
| 40 | + let response = String::from_utf8(response)?; |
| 41 | + if !response.contains("HTTP/1.1 200 OK") { |
| 42 | + return Err(anyhow!("server did not respond with 200 OK: {response}")); |
| 43 | + } |
| 44 | + drop(data_tx); |
| 45 | + sock_rx_fut.await.context("tcp recv")?; |
| 46 | + sock_tx_fut.await.context("tcp send")?; |
| 47 | + tls_rx_fut.await.context("tls recv")?; |
| 48 | + tls_tx_err_fut.await.context("tls send")?; |
| 49 | + |
60 | 50 | Ok(()) |
61 | 51 | } |
62 | 52 |
|
|
0 commit comments