Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 7 additions & 23 deletions crates/test-programs/src/bin/cli_no_tcp.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
//! This test assumes that it will be run without tcp support enabled
use test_programs::wasi::sockets::{
network::IpAddress,
tcp::{ErrorCode, IpAddressFamily, IpSocketAddress, Network, TcpSocket},
};

fn main() {
let net = Network::default();
let family = IpAddressFamily::Ipv4;
let remote1 = IpSocketAddress::new(IpAddress::new_loopback(family), 4321);
let sock = TcpSocket::new(family).unwrap();

let bind = sock.blocking_bind(&net, remote1);
eprintln!("Result of binding: {bind:?}");
assert!(matches!(bind, Err(ErrorCode::AccessDenied)));
#![deny(warnings)]

let listen = sock.blocking_listen();
eprintln!("Result of listen: {listen:?}");
assert!(matches!(listen, Err(ErrorCode::AccessDenied)));
use test_programs::wasi::sockets::tcp::{ErrorCode, IpAddressFamily, TcpSocket};

let connect = sock.blocking_connect(&net, remote1);
eprintln!("Result of connect: {connect:?}");
assert!(matches!(connect, Err(ErrorCode::AccessDenied)));

let accept = sock.blocking_accept();
eprintln!("Result of accept: {accept:?}");
assert!(matches!(accept, Err(ErrorCode::AccessDenied)));
fn main() {
assert!(matches!(
TcpSocket::new(IpAddressFamily::Ipv4),
Err(ErrorCode::AccessDenied)
));
}
2 changes: 1 addition & 1 deletion crates/wasi/src/p2/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ mod async_io {
// Configure all other resources to be concrete types defined in
// this crate
"wasi:sockets/network/network": crate::p2::network::Network,
"wasi:sockets/tcp/tcp-socket": crate::p2::tcp::TcpSocket,
"wasi:sockets/tcp/tcp-socket": crate::sockets::TcpSocket,
"wasi:sockets/udp/udp-socket": crate::sockets::UdpSocket,
"wasi:sockets/udp/incoming-datagram-stream": crate::p2::udp::IncomingDatagramStream,
"wasi:sockets/udp/outgoing-datagram-stream": crate::p2::udp::OutgoingDatagramStream,
Expand Down
Loading