mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-13 21:27:41 +02:00
[eric] browser: re-broadcast ws commands lost in dead-socket gaps, refetch layout on reconnect
This commit is contained in:
@@ -58,6 +58,28 @@ async def test_navigate_gets_the_longer_leash(monkeypatch):
|
||||
assert elapsed > 0.5, "navigate should use its longer bound, not the default"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_lost_first_delivery_heals_via_rebroadcast(monkeypatch):
|
||||
# a silently-dead socket eats the first broadcast; the re-send after the
|
||||
# rebroadcast interval must reach the (reconnected) client and succeed
|
||||
monkeypatch.setattr(wsm, "_BROWSER_CMD_TIMEOUT_DEFAULT", 5.0)
|
||||
monkeypatch.setattr(wsm, "_BROWSER_CMD_REBROADCAST_S", 0.1)
|
||||
m = _mgr()
|
||||
sends = []
|
||||
|
||||
class _CountingSock:
|
||||
async def send_text(self, payload):
|
||||
sends.append(payload)
|
||||
if len(sends) >= 2: # first delivery "lost", second lands
|
||||
rid = next(iter(m.browser_futures))
|
||||
m.resolve_browser_command(rid, {"text": "ok"})
|
||||
|
||||
m.global_connections = [_CountingSock()]
|
||||
res = await m.send_browser_command("rid4", "get_text", "b1", {})
|
||||
assert res == {"text": "ok"}
|
||||
assert len(sends) >= 2, "command must be re-broadcast until a client answers"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_resolved_command_returns_immediately(monkeypatch):
|
||||
# a healthy command returns the moment the renderer resolves it, not at the bound
|
||||
|
||||
Reference in New Issue
Block a user