Skip to content

Commit

Permalink
More robust local_addr test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith authored and djc committed Nov 16, 2019
1 parent ec57604 commit da08f06
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions quinn/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,13 @@ fn close_endpoint() {

#[test]
fn local_addr() {
let port = 56987;
let (_, ep, _) = Endpoint::builder()
.bind(&SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port))
.expect("Could not bind to localhost");
let socket = UdpSocket::bind("[::1]:0").unwrap();
let addr = socket.local_addr().unwrap();
let (_, ep, _) = Endpoint::builder().with_socket(socket).unwrap();
assert_eq!(
port,
addr,
ep.local_addr()
.expect("Could not obtain our local endpoint")
.port()
);
}

Expand Down

0 comments on commit da08f06

Please sign in to comment.