From 02d6b0bb28f6c964477a2362860e37a27d13d8d9 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 30 Nov 2024 13:36:34 -0500 Subject: tests: convert TCPv6 transport test to NUTS (and consolidate with v4) --- src/testing/marry.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/testing/marry.c') diff --git a/src/testing/marry.c b/src/testing/marry.c index 7441468f..8cc94473 100644 --- a/src/testing/marry.c +++ b/src/testing/marry.c @@ -48,16 +48,19 @@ nuts_scratch_addr(const char *scheme, size_t sz, char *addr) if ((strncmp(scheme, "tcp", 3) == 0) || (strncmp(scheme, "tls", 3) == 0) || (strncmp(scheme, "udp", 3) == 0)) { + const char *ip = + strchr(scheme, '6') != NULL ? "[::1]" : "127.0.0.1"; (void) snprintf( - addr, sz, "%s://127.0.0.1:%u", scheme, nuts_next_port()); + addr, sz, "%s://%s:%u", scheme, ip, nuts_next_port()); return; } if (strncmp(scheme, "ws", 2) == 0) { - (void) snprintf(addr, sz, - "%s://127.0.0.1:%u/nuts%04x%04x%04x%04x", scheme, - nuts_next_port(), nng_random(), nng_random(), nng_random(), - nng_random()); + const char *ip = + strchr(scheme, '6') != NULL ? "[::1]" : "127.0.0.1"; + (void) snprintf(addr, sz, "%s://%s:%u/nuts%04x%04x%04x%04x", + scheme, ip, nuts_next_port(), nng_random(), nng_random(), + nng_random(), nng_random()); return; } -- cgit v1.2.3-70-g09d2