diff options
Diffstat (limited to 'packages/meshbay-cli/tests/test_e2e_local.py')
| -rw-r--r-- | packages/meshbay-cli/tests/test_e2e_local.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/meshbay-cli/tests/test_e2e_local.py b/packages/meshbay-cli/tests/test_e2e_local.py index cf6a3b9..359ab06 100644 --- a/packages/meshbay-cli/tests/test_e2e_local.py +++ b/packages/meshbay-cli/tests/test_e2e_local.py @@ -1068,3 +1068,31 @@ async def test_the_interactive_chat_against_the_real_node(world, monkeypatch, tm r = await asyncio.to_thread(cli, world, "chat", "-1", group, home="cli-chat") assert r.stdout.strip().endswith(f"{USERNAME}: typed in the room"), r.stdout + + +def test_chat_follow_against_the_real_node(world): + """`chat --follow` in its own process: messages posted from another run + arrive as the node pushes them, across more than one liveness ping, and + Ctrl+C ends it. Runs on the machine the chat tests above linked.""" + import signal + group = _handle() + env = {**os.environ, "MESHBAY_CLI_HOME": str(world["root"] / "cli-chat"), + "PYTHON_KEYRING_BACKEND": "keyring.backends.fail.Keyring"} + exe = os.environ.get("MESHBAY_CLI_E2E_BIN") or str(BIN / "meshbay-cli") + follower = subprocess.Popen([exe, "--json", "chat", "-1", group, "--follow"], env=env, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + try: + first = json.loads(follower.stdout.readline()) # the last one, at once + assert first["text"] + for text, wait in (("followed one", 0), ("followed two, after a ping", 36)): + time.sleep(wait) + r = cli(world, "chat", group, "-m", text, home="cli-chat") + assert r.returncode == 0, r.stderr + got = json.loads(follower.stdout.readline()) + assert got["text"] == text and got["sender"] == USERNAME, got + assert got["trust"] in ("pinned", "first", "linked") + finally: + follower.send_signal(signal.SIGINT) + _, err = follower.communicate(timeout=20) + assert follower.returncode == 130 + assert "reconnecting" not in err, err |