Skip to content

Commit 9197654

Browse files
committed
Add test
1 parent 37a5edf commit 9197654

File tree

1 file changed

+3
-2
lines changed
  • fortanix-vme/tests/incoming_connection/src

1 file changed

+3
-2
lines changed

fortanix-vme/tests/incoming_connection/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
use std::net::{Shutdown, TcpListener};
1+
use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpListener};
22
use std::io::{Read, Write};
33

44
fn main() {
55
println!("Bind to socket to 3400");
66
let listener = TcpListener::bind("127.0.0.1:3400").expect("Bind failed");
7-
// println!("# Listening on: {}", listener.local_addr().unwrap().port());
7+
assert_eq!(listener.local_addr().unwrap(), SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 3400));
88

99
println!("Listening for incoming connections...");
1010
for id in 1..3 {
1111
println!("Waiting for connection {}", id);
1212
match listener.accept() {
1313
Ok((mut stream, addr)) => {
1414
println!("# addr = {:?}", addr);
15+
assert_eq!(stream.peer_addr().unwrap().ip(), Ipv4Addr::new(127, 0, 0, 1));
1516
println!("Connection {}: Connected", id);
1617
let mut buff_in = [0u8; 4192];
1718
let n = stream.read(&mut buff_in).unwrap();

0 commit comments

Comments
 (0)