From 70eae619abf7f317a64c51cdb483e23463effdd9 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 7 Jul 2025 08:47:55 +0200 Subject: [PATCH 1/2] chore: run IPv6 compliance tests in CI Other IPv6 tests in the suite run so we should be able to run the compliance tests. --- test/compliance.spec.ts | 55 +++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/test/compliance.spec.ts b/test/compliance.spec.ts index e07793d..faf50cf 100644 --- a/test/compliance.spec.ts +++ b/test/compliance.spec.ts @@ -33,36 +33,33 @@ describe('Interface compliance tests (IPv4)', () => { }) }) -// IPv6 isn't always available in CI -if (!process.env.CI) { - describe('Interface compliance tests (IPv6)', function () { - transportCompliance({ - async setup () { - const dialer = { - transports: [ - quic() - ], - connectionMonitor: { - enabled: false - } +describe('Interface compliance tests (IPv6)', function () { + transportCompliance({ + async setup () { + const dialer = { + transports: [ + quic() + ], + connectionMonitor: { + enabled: false } + } - return { - dialer, - listener: { - addresses: { - listen: [ - '/ip6/::/udp/0/quic-v1', - '/ip6/::/udp/0/quic-v1' - ] - }, - ...dialer + return { + dialer, + listener: { + addresses: { + listen: [ + '/ip6/::/udp/0/quic-v1', + '/ip6/::/udp/0/quic-v1' + ] }, - dialMultiaddrMatcher: QUICV1, - listenMultiaddrMatcher: QUICV1 - } - }, - async teardown () {} - }) + ...dialer + }, + dialMultiaddrMatcher: QUICV1, + listenMultiaddrMatcher: QUICV1 + } + }, + async teardown () {} }) -} +}) From 498b8ee6ba0db3614f25046f9bf940d5fd93db63 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 7 Jul 2025 15:05:35 +0200 Subject: [PATCH 2/2] chore: detect ipv6 --- test/compliance.spec.ts | 6 ++++++ test/util.ts | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/test/compliance.spec.ts b/test/compliance.spec.ts index faf50cf..a0fb25d 100644 --- a/test/compliance.spec.ts +++ b/test/compliance.spec.ts @@ -1,6 +1,7 @@ import transportCompliance from '@libp2p/interface-compliance-tests/transport' import { QUICV1 } from '@multiformats/multiaddr-matcher' import { quic } from '../src/index.js' +import { hostSupportsIpv6 } from './util.ts' describe('Interface compliance tests (IPv4)', () => { transportCompliance({ @@ -34,6 +35,11 @@ describe('Interface compliance tests (IPv4)', () => { }) describe('Interface compliance tests (IPv6)', function () { + if (!hostSupportsIpv6()) { + it.skip('Host does not support IPv6', () => {}) + return + } + transportCompliance({ async setup () { const dialer = { diff --git a/test/util.ts b/test/util.ts index 0afdf85..cc2817b 100644 --- a/test/util.ts +++ b/test/util.ts @@ -1,6 +1,8 @@ import { generateKeyPair } from '@libp2p/crypto/keys' import { defaultLogger } from '@libp2p/logger' import type { QuicComponents } from '../src/index.js' +import { isIPv6 } from '@chainsafe/is-ip' +import os from 'node:os' export async function createComponents (): Promise { return { @@ -8,3 +10,19 @@ export async function createComponents (): Promise { logger: defaultLogger() } } + +export function hostSupportsIpv6 (): boolean { + for (const interfaces of Object.values(os.networkInterfaces())) { + if (interfaces == null) { + continue + } + + for (const info of interfaces) { + if (isIPv6(info.address)) { + return true + } + } + } + + return false +}