diff --git a/.travis.yml b/.travis.yml index 52ea19af..166cab99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,13 @@ branches: only: - master +before_install: + # Add an IPv6 config - see the corresponding Travis issue + # https://github.com/travis-ci/travis-ci/issues/8361 + - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then + sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'; + fi + cache: cargo matrix: diff --git a/libp2p-tcp-transport/src/lib.rs b/libp2p-tcp-transport/src/lib.rs index 1f926b1f..c20dbf7c 100644 --- a/libp2p-tcp-transport/src/lib.rs +++ b/libp2p-tcp-transport/src/lib.rs @@ -258,7 +258,7 @@ mod tests { } #[test] - fn replace_port_0_in_returned_multiaddr() { + fn replace_port_0_in_returned_multiaddr_ipv4() { let core = Core::new().unwrap(); let tcp = TcpConfig::new(core.handle()); @@ -269,6 +269,18 @@ mod tests { assert!(!new_addr.to_string().contains("tcp/0")); } + #[test] + fn replace_port_0_in_returned_multiaddr_ipv6() { + let core = Core::new().unwrap(); + let tcp = TcpConfig::new(core.handle()); + + let addr = Multiaddr::new("/ip6/::1/tcp/0").unwrap(); + assert!(addr.to_string().contains("tcp/0")); + + let (_, new_addr) = tcp.listen_on(addr).unwrap(); + assert!(!new_addr.to_string().contains("tcp/0")); + } + #[test] fn larger_addr_denied() { let core = Core::new().unwrap();