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 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: """