fix(work): import hashlib and wire heal subparser into main CLI

This commit is contained in:
operator
2026-10-09 23:13:43 +00:00
parent c3b4b1cd28
commit f75977ca6e
202 changed files with 4185 additions and 4142 deletions
+20 -3
View File
@@ -17,6 +17,23 @@ from invite_handler import InviteCodeInfo, InviteHandler, RedemptionResult, salv
from settings_rpa import NodeUsage, SettingsRPA
def _fast_clock():
"""Fake time.time advancing 1s per call.
redeem_code_dom polls on `deadline = time.time() + 2.5` loops; patching
only time.sleep leaves 2.5s of real time per loop. With +1s/call each
loop runs exactly 2 iterations then expires (deadline math holds for
every loop uniformly, no per-loop alignment needed).
"""
state = {"t": 1000.0}
def fake_time():
state["t"] += 1.0
return state["t"]
return fake_time
class TestInviteCodeValidation(unittest.TestCase):
def test_normalize_valid_codes(self):
self.assertEqual(invite.normalize_code("REDCJ7"), "REDCJ7")
@@ -212,7 +229,7 @@ class TestInviteHandlerMocked(unittest.TestCase):
h = InviteHandler("dev")
h.ws = MagicMock()
with patch.object(h, "connect"), patch("time.sleep", return_value=None):
with patch.object(h, "connect"), patch("time.sleep", return_value=None), patch("time.time", side_effect=_fast_clock()):
with patch("invite_handler.cdp_evaluate", return_value={"found": False, "text": "General"}):
with patch.object(h, "redeem_code_api") as mock_api:
mock_api.return_value = RedemptionResult(
@@ -239,7 +256,7 @@ class TestInviteHandlerMocked(unittest.TestCase):
h = InviteHandler("646")
h.ws = MagicMock()
with patch.object(h, "connect"), patch("time.sleep", return_value=None):
with patch.object(h, "connect"), patch("time.sleep", return_value=None), patch("time.time", side_effect=_fast_clock()):
with patch("invite_handler.cdp_evaluate", return_value={"found": False, "has_additional": True, "text": "Additional tokens"}):
with patch.object(h, "redeem_code_api") as mock_api:
mock_api.return_value = RedemptionResult(
@@ -274,7 +291,7 @@ class TestInviteHandlerMocked(unittest.TestCase):
return {"found_input": False}
return True
with patch.object(h, "connect"), patch("time.sleep", return_value=None):
with patch.object(h, "connect"), patch("time.sleep", return_value=None), patch("time.time", side_effect=_fast_clock()):
with patch("invite_handler.cdp_evaluate", side_effect=mock_eval), patch("invite_handler.cdp_send_escape"):
with patch.object(h, "redeem_code_api") as mock_api:
mock_api.return_value = RedemptionResult(