Skip to content

Commit f8a00a6

Browse files
committed
Fix bind(&s, &"127.0.0.1:0".parse().unwrap()) in tests.
1 parent 8554139 commit f8a00a6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/net/sockopt.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,13 @@ fn test_sockopts_ipv6() {
513513
#[cfg(linux_kernel)]
514514
#[test]
515515
fn test_socketopts_ip_mtu() {
516+
use std::net::SocketAddrV4;
517+
516518
crate::init();
517519

518520
let s = rustix::net::socket(AddressFamily::INET, SocketType::DGRAM, None).unwrap();
519-
rustix::net::bind(&s, &"127.0.0.1:0".parse().unwrap()).unwrap();
520-
rustix::net::connect(&s, &"127.0.0.1:0".parse().unwrap()).unwrap();
521+
rustix::net::bind(&s, &SocketAddrV4::new(Ipv4Addr::LOCALHOST, 0)).unwrap();
522+
rustix::net::connect(&s, &SocketAddrV4::new(Ipv4Addr::LOCALHOST, 0)).unwrap();
521523
match sockopt::ip_mtu(&s) {
522524
Ok(mtu) => {
523525
assert!(mtu > 0);
@@ -532,11 +534,13 @@ fn test_socketopts_ip_mtu() {
532534
#[cfg(linux_kernel)]
533535
#[test]
534536
fn test_socketopts_ipv6_mtu() {
537+
use std::net::{Ipv6Addr, SocketAddrV6};
538+
535539
crate::init();
536540

537541
let s = rustix::net::socket(AddressFamily::INET6, SocketType::DGRAM, None).unwrap();
538-
rustix::net::bind(&s, &"[::1]:0".parse().unwrap()).unwrap();
539-
rustix::net::connect(&s, &"[::1]:0".parse().unwrap()).unwrap();
542+
rustix::net::bind(&s, &SocketAddrV6::new(Ipv6Addr::LOCALHOST, 0, 0, 0)).unwrap();
543+
rustix::net::connect(&s, &SocketAddrV6::new(Ipv6Addr::LOCALHOST, 0, 0, 0)).unwrap();
540544

541545
match sockopt::ipv6_mtu(&s) {
542546
Ok(mtu) => {

0 commit comments

Comments
 (0)