Skip to content

Commit c57fe69

Browse files
committed
Extend tests outgoing connection
1 parent 224866d commit c57fe69

File tree

1 file changed

+5
-1
lines changed
  • fortanix-vme/tests/outgoing_connection/src

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
use std::net::TcpStream;
1+
use std::net::{Ipv4Addr, TcpStream};
22
use std::io::{Read, Write};
33

44
fn main() {
55
let mut socket = TcpStream::connect(format!("google.com:80")).unwrap();
6+
// `socket.local_addr()` may return the actual local IP address, not 127.0.0.1
7+
assert!(socket.local_addr().unwrap().port() != 80);
8+
assert!(socket.peer_addr().unwrap().ip() != Ipv4Addr::new(127, 0, 0, 1));
9+
assert_eq!(socket.peer_addr().unwrap().port(), 80);
610
socket.write(b"GET / HTTP/1.1\n\n").unwrap();
711
socket.flush().unwrap();
812
let mut page = [0; 4192];

0 commit comments

Comments
 (0)