Skip to content

Commit b889d2b

Browse files
Copilotachamayou
andauthored
Fix common_ipv6 test failures on runners without IPv6 support (#7732)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
1 parent 1a727ae commit b889d2b

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/node/node_state.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,8 +2184,7 @@ namespace ccf
21842184
// numeric, but at least the final component (TLD) must not be
21852185
// all-numeric. So this distinguishes "1.2.3.4" (an IP address) from
21862186
// "1.2.3.c4m" (a DNS name). "1.2.3." is invalid for either, and will
2187-
// throw. Attempts to handle IPv6 by also splitting on ':', but this is
2188-
// untested.
2187+
// throw. Handles IPv6 by splitting on ':' after splitting on '.'.
21892188
const auto final_component =
21902189
ccf::nonstd::split(ccf::nonstd::split(hostname, ".").back(), ":")
21912190
.back();
@@ -2216,6 +2215,11 @@ namespace ccf
22162215
for (const auto& [_, interface] : config.network.rpc_interfaces)
22172216
{
22182217
auto host = split_net_address(interface.published_address).first;
2218+
// Strip brackets from IPv6 addresses (e.g. "[::1]" -> "::1")
2219+
if (host.size() >= 2 && host.front() == '[' && host.back() == ']')
2220+
{
2221+
host = host.substr(1, host.size() - 2);
2222+
}
22192223
sans.push_back({host, is_ip(host)});
22202224
}
22212225
return sans;

tests/e2e_common_endpoints.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the Apache 2.0 License.
33
import infra.network
4+
import infra.interfaces
45
from ccf.ledger import NodeStatus
56
import http
67
import random
8+
import socket
79
import suite.test_requirements as reqs
810

911

@@ -341,6 +343,15 @@ def run(args):
341343

342344

343345
def run_ipv6(args):
346+
# Check if IPv6 loopback is available before attempting to start nodes.
347+
# Some CI environments disable IPv6, in which case this test is skipped.
348+
try:
349+
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
350+
s.bind(("::1", 0))
351+
except (OSError, socket.error):
352+
LOG.warning("IPv6 loopback (::1) is not available, skipping IPv6 test")
353+
return
354+
344355
# Set each RPC interface host to the IPv6 loopback address directly,
345356
# so the setting is isolated to this test (no environment variable).
346357
# Ports are dynamically assigned, so sharing ::1 across nodes is fine.

0 commit comments

Comments
 (0)