aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_login_retry_is_resilient.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/tests/test_login_retry_is_resilient.py')
-rw-r--r--packages/meshbay-node/tests/test_login_retry_is_resilient.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/packages/meshbay-node/tests/test_login_retry_is_resilient.py b/packages/meshbay-node/tests/test_login_retry_is_resilient.py
index e37a413..39358bb 100644
--- a/packages/meshbay-node/tests/test_login_retry_is_resilient.py
+++ b/packages/meshbay-node/tests/test_login_retry_is_resilient.py
@@ -14,8 +14,7 @@ import asyncio
import httpx
import pytest
-from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
-from meshbay_node.config import Config, GroupConfig, HubConfig, KeystoreConfig, NodeConfig
+from meshbay_node.config import Config, HubConfig, KeystoreConfig, NodeConfig
from meshbay_node.daemon import NodeDaemon
@@ -96,6 +95,23 @@ async def test_a_401_still_retries_and_stays_alive(tmp_path, monkeypatch):
assert daemon._state.get("status") in ("waiting_for_node_key", "waiting_for_account")
+def test_a_node_waiting_for_its_link_stays_under_the_hubs_sign_in_limit():
+ """At 5s a node waiting for its key made 12 attempts a minute against a
+ limit of 10: it put itself in 429 back-off within a minute, every minute,
+ and the desktop app did not recognise that state as a node at all."""
+ import re
+ from pathlib import Path
+
+ from meshbay_node.daemon import NodeDaemon
+
+ nodes_py = (Path(__file__).resolve().parents[2] / "meshbay-hub" / "src" / "meshbay_hub"
+ / "api" / "nodes.py").read_text(encoding="utf-8")
+ m = re.search(r'@router\.post\("/auth"\)\s*@limiter\.limit\("(\d+)/minute"\)', nodes_py)
+ assert m, "the hub's node sign-in limit moved; update this test"
+ per_minute = int(m.group(1))
+ assert 60 / NodeDaemon.LINK_WAIT_S < per_minute
+
+
@pytest.mark.asyncio
async def test_a_genuine_client_error_still_raises(tmp_path, monkeypatch):
"""A 400/422 is a bug, not a transient state — it must not be swallowed."""