Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions connectd/connectd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,14 @@ static void try_connect_one_addr(struct connecting *connect)
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_UNSPEC;
hints.ai_protocol = 0;
/* AI_ADDRCONFIG speeds up connects on single-stack hosts by
* pruning unreachable address families. Skip on macOS/BSD
* where it opens temporary probe sockets that confuse our
* fd-leak checker. */
#ifndef __APPLE__
hints.ai_flags = AI_ADDRCONFIG;
#endif

gai_err = getaddrinfo((char *)addr->u.wireaddr.wireaddr.addr,
tal_fmt(tmpctx, "%d",
addr->u.wireaddr.wireaddr.port),
Expand Down
7 changes: 7 additions & 0 deletions tests/test_gossip.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ def test_announce_and_connect_via_dns(node_factory, bitcoind):
- --disable-dns is needed so the first node does not announce 127.0.0.1 itself.
- 'dev-allow-localhost' must not be set, so it does not resolve localhost anyway.
"""
# localhost.localdomain is not present in /etc/hosts on macOS by default.
# See https://github.com/ElementsProject/lightning/issues/9012
try:
socket.getaddrinfo('localhost.localdomain', 12345, 0, socket.SOCK_STREAM)
except socket.gaierror:
pytest.skip("localhost.localdomain not resolvable; add '127.0.0.1 localhost.localdomain' to /etc/hosts")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of skipping the test, I think we might be able to use "test.localhost," as mac allows subdomains on localhost. If that doesn't work I wonder if just setting it to "localhost" would satisfy what the test is trying to do.

If none of those work and we have to skip the test -- we should skip the test with a clause for Mac, probably something like:

@unittest.skipIf(sys.platform == "darwin")

Doing it explicitly this way will make it easy to keep track of which tests we're skipping

opts1 = {'disable-dns': None,
'announce-addr': ['dns:localhost.localdomain:12345'], # announce dns
'bind-addr': ['127.0.0.1:12345', '[::1]:12345']} # and bind local IPs
Expand Down
Loading