connectd/tests: fix test_announce_and_connect_via_dns on macOS
What changed, and why it matters
This commit is a test-only fix for macOS. It skips a test that fails because macOS lacks a specific local hostname entry, and it adds a code comment explaining a networking flag. There is no security issue or vulnerability here.
No security action needed. This is a test maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change skips test_announce_and_connect_via_dns on Darwin/macOS because localhost.localdomain is not in /etc/hosts by default, causing DNS resolution to fail. It also adds an explanatory comment for AI_ADDRCONFIG in connectd.c. No functional behavior is changed, no bug is fixed, and no vulnerability is addressed.
Changed components
tests/test_gossip.pyconnectd/connectd.cInspect captured patch +6 / −0
diff --git a/connectd/connectd.c b/connectd/connectd.c
index 54ac0891..61759f7a 100644
--- a/connectd/connectd.c
+++ b/connectd/connectd.c
@@ -1134,7 +1134,10 @@ 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. */
hints.ai_flags = AI_ADDRCONFIG;
+
gai_err = getaddrinfo((char *)addr->u.wireaddr.wireaddr.addr,
tal_fmt(tmpctx, "%d",
addr->u.wireaddr.wireaddr.port),
diff --git a/tests/test_gossip.py b/tests/test_gossip.py
index 326a4391..e39df294 100644
--- a/tests/test_gossip.py
+++ b/tests/test_gossip.py
@@ -16,6 +16,7 @@ import os
import pytest
import struct
import subprocess
+import sys
import time
import unittest
import shutil
@@ -186,6 +187,8 @@ def test_announce_dns_suppressed(node_factory, bitcoind):
assert addresses[0]['port'] == 1236
+@unittest.skipIf(sys.platform == "darwin",
+ "localhost.localdomain not in /etc/hosts on macOS by default")
def test_announce_and_connect_via_dns(node_factory, bitcoind):
""" Test that DNS announcements propagate and can be used when connecting.
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.