From 2718347a708c03ad10de37ba35c83c46984c4b4b Mon Sep 17 00:00:00 2001 From: Quinten Stokkink Date: Wed, 10 Jan 2024 12:17:14 +0100 Subject: [PATCH 1/2] Fixed mocked IPv6 address generation --- ipv8/test/mocking/endpoint.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ipv8/test/mocking/endpoint.py b/ipv8/test/mocking/endpoint.py index 063bdbf0a..2ca398045 100644 --- a/ipv8/test/mocking/endpoint.py +++ b/ipv8/test/mocking/endpoint.py @@ -1,5 +1,6 @@ from __future__ import annotations +import ipaddress import os import random from asyncio import get_running_loop @@ -173,7 +174,10 @@ def _generate_address(self) -> UDPv4Address | UDPv6Address: b7 = random.randint(0, 65535) port = random.randint(0, 65535) - return UDPv6Address(f"{b0:02x}:{b1:02x}:{b2:02x}:{b3:02x}:{b4:02x}:{b5:02x}:{b6:02x}:{b7:02x}", port) + exploded_ip = f"{b0:02x}:{b1:02x}:{b2:02x}:{b3:02x}:{b4:02x}:{b5:02x}:{b6:02x}:{b7:02x}" + # Our tests assume that the valid (exploded) ip is formatted using `ip_address`. + # You will get random failures if you fail to normalize (see https://github.com/Tribler/py-ipv8/issues/1243). + return UDPv6Address(str(ipaddress.ip_address(exploded_ip)), port) def _is_lan(self, address: Address) -> bool: """ From d2d31ee52610765a756ad6a8140cac7cf694c19d Mon Sep 17 00:00:00 2001 From: Quinten Stokkink Date: Wed, 10 Jan 2024 12:17:36 +0100 Subject: [PATCH 2/2] Re-enabled IPv6 validation tests --- .github/workflows/pr-comment-validate.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr-comment-validate.yml b/.github/workflows/pr-comment-validate.yml index ee89f0fb4..ff46e10e3 100644 --- a/.github/workflows/pr-comment-validate.yml +++ b/.github/workflows/pr-comment-validate.yml @@ -22,3 +22,8 @@ jobs: python-version: ${{ matrix.version }} - run: python -m pip install -r requirements.txt - run: python run_all_tests.py -a + env: + TEST_IPV8_WITH_IPV6: 0 + - run: python run_all_tests.py -a + env: + TEST_IPV8_WITH_IPV6: 1