This PR adds a test to check that a node will not try to connect to an anchor from an unreachable network when initializing. It kills and can be tested with the following mutant:
diff --git a/src/net.cpp b/src/net.cpp
index 6b79e913e8..cd8aa4c502 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2774,7 +2774,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect, std
if (anchor && !m_anchors.empty()) {
const CAddress addr = m_anchors.back();
m_anchors.pop_back();
- if (!addr.IsValid() || IsLocal(addr) || !g_reachable_nets.Contains(addr) ||
+ if (!addr.IsValid() || IsLocal(addr) ||
!m_msgproc->HasAllDesirableServiceFlags(addr.nServices) ||
outbound_ipv46_peer_netgroups.contains(m_netgroupman.GetGroup(addr))) continue;
addrConnect = addr;
Also, it fixes a bug in assert_debug_log which has a timing asymmetry between expected and unexpected message
checking. When all expected messages were found early, the function would return immediately without waiting for the full timeout period. This created a race condition where unexpected messages appearing after the expected messages (but before the timeout) would not be detected.