diff --git a/tests/unit/libstore/filetransfer.cc b/tests/unit/libstore/filetransfer.cc index 5885a8059..15c378391 100644 --- a/tests/unit/libstore/filetransfer.cc +++ b/tests/unit/libstore/filetransfer.cc @@ -37,7 +37,7 @@ namespace nix { static std::tuple serveHTTP(std::vector replies) { - AutoCloseFD listener(::socket(AF_INET6, SOCK_STREAM, 0)); + AutoCloseFD listener(::socket(AF_INET, SOCK_STREAM, 0)); if (!listener) { throw SysError(errno, "socket() failed"); } @@ -46,7 +46,7 @@ serveHTTP(std::vector replies) trigger.create(); sockaddr_in6 addr = { - .sin6_family = AF_INET6, + .sin6_family = AF_INET, .sin6_addr = IN6ADDR_LOOPBACK_INIT, }; socklen_t len = sizeof(addr); @@ -155,7 +155,7 @@ TEST(FileTransfer, exceptionAbortsRead) auto [port, srv] = serveHTTP("200 ok", "content-length: 0\r\n", [] { return ""; }); auto ft = makeFileTransfer(); char buf[10] = ""; - ASSERT_THROW(ft->download(fmt("http://[::1]:%d/index", port)).second->read(buf, 10), EndOfFile); + ASSERT_THROW(ft->download(fmt("http://127.0.0.1:%d/index", port)).second->read(buf, 10), EndOfFile); } TEST(FileTransfer, NOT_ON_DARWIN(reportsSetupErrors)) @@ -163,7 +163,7 @@ TEST(FileTransfer, NOT_ON_DARWIN(reportsSetupErrors)) auto [port, srv] = serveHTTP("404 not found", "", [] { return ""; }); auto ft = makeFileTransfer(); ASSERT_THROW( - ft->download(fmt("http://[::1]:%d/index", port)), + ft->download(fmt("http://127.0.0.1:%d/index", port)), FileTransferError ); } @@ -179,7 +179,7 @@ TEST(FileTransfer, NOT_ON_DARWIN(defersFailures)) return std::string(1024 * 1024, ' '); }); auto ft = makeFileTransfer(0); - auto src = ft->download(fmt("http://[::1]:%d/index", port)).second; + auto src = ft->download(fmt("http://127.0.0.1:%d/index", port)).second; ASSERT_THROW(src->drain(), FileTransferError); } @@ -192,7 +192,7 @@ TEST(FileTransfer, NOT_ON_DARWIN(handlesContentEncoding)) auto ft = makeFileTransfer(); StringSink sink; - ft->download(fmt("http://[::1]:%d/index", port)).second->drainInto(sink); + ft->download(fmt("http://127.0.0.1:%d/index", port)).second->drainInto(sink); EXPECT_EQ(sink.s, original); } @@ -215,7 +215,7 @@ TEST(FileTransfer, usesIntermediateLinkHeaders) {"200 ok", "content-length: 1\r\n", [] { return "a"; }}, }); auto ft = makeFileTransfer(0); - auto [result, _data] = ft->download(fmt("http://[::1]:%d/first", port)); + auto [result, _data] = ft->download(fmt("http://127.0.0.1:%d/first", port)); ASSERT_EQ(result.immutableUrl, "http://foo"); }