aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-14 01:25:10 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-14 01:25:10 +0200
commitaab4bc98a3361d9f23e048a52705baa2f4a4a078 (patch)
treec769f904af6341fddbb5f9e6ed51925596cc8760 /packages/meshbay-node
parent3e9c94a420b6c427eff4ee13aac80cb1430d7a7c (diff)
downloadmeshbay-aab4bc98a3361d9f23e048a52705baa2f4a4a078.tar.gz
test(node): allocate daemon test ports instead of hardcoding 28000
test_daemon.py started the real admin UI on a fixed port, so every test file that also brought up a node collided with it. Each file passed on its own and the full node suite failed with EADDRINUSE on test_daemon_creates_chat_store — which reads as a flaky regression rather than a test-isolation bug. Confirmed against a clean worktree at HEAD before touching anything: the failure predates the invite work. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node')
-rw-r--r--packages/meshbay-node/tests/test_daemon.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/packages/meshbay-node/tests/test_daemon.py b/packages/meshbay-node/tests/test_daemon.py
index 0698104..60ef11f 100644
--- a/packages/meshbay-node/tests/test_daemon.py
+++ b/packages/meshbay-node/tests/test_daemon.py
@@ -34,6 +34,20 @@ def _mock_keystore_keys(sk_ed):
mock_keys.pk_x25519_b64 = base64.b64encode(pk_x_raw).decode()
return mock_keys
+def _free_port() -> int:
+ """
+ A port nobody else in the session is on.
+
+ These tests start the real admin UI server. Hardcoding 28000 made them fail
+ with EADDRINUSE whenever another test file had a node running — which is why
+ the full suite failed while each file passed on its own.
+ """
+ import socket
+ with socket.socket() as s:
+ s.bind(("127.0.0.1", 0))
+ return s.getsockname()[1]
+
+
@pytest.fixture
def sk_hub():
return Ed25519PrivateKey.generate()
@@ -59,7 +73,7 @@ def shared_dir(tmp_path):
def node_config(tmp_path, shared_dir):
return Config(
hub=HubConfig(url="http://localhost:9999", username="testuser"),
- node=NodeConfig(quic_port=29010, ui_port=28000),
+ node=NodeConfig(quic_port=_free_port(), ui_port=_free_port()),
groups=[GroupConfig(
id="g" * 32,
name="test-group",
@@ -190,7 +204,7 @@ async def test_daemon_index_change_pushes_to_peers(tmp_path, shared_dir, gek, hu
"""Index change callback pushes updated index to WebRTC peers."""
config = Config(
hub=HubConfig(url="http://localhost:9999", username="testuser"),
- node=NodeConfig(quic_port=29010, ui_port=28000),
+ node=NodeConfig(quic_port=_free_port(), ui_port=_free_port()),
groups=[GroupConfig(
id="a" * 32,
name="test-group",
@@ -241,7 +255,7 @@ async def test_daemon_index_change_registers_swarm_for_public_group(
"""Public groups still register content hashes with the hub swarm (H7)."""
config = Config(
hub=HubConfig(url="http://localhost:9999", username="testuser"),
- node=NodeConfig(quic_port=29010, ui_port=28000),
+ node=NodeConfig(quic_port=_free_port(), ui_port=_free_port()),
groups=[GroupConfig(
id="a" * 32,
name="public-group",