diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-15 02:22:05 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-15 02:22:05 +0200 |
| commit | adda9613fad48a68239e2dbd93321818a835c286 (patch) | |
| tree | 8835fd2ac3e203d3f3110bc45617c79eb982cd0d /packages/meshbay-cli/tests/test_e2e_local.py | |
| parent | 419af660eeb8a4403e37a63c54a15586d04d5a8e (diff) | |
| download | meshbay-adda9613fad48a68239e2dbd93321818a835c286.tar.gz | |
feat(cli): chat --follow
chat GROUP --follow prints the last messages, then each one the node pushes,
until Ctrl+C (exit 130). The connection is pinged every half minute; one
that closes, fails or stops answering is opened again, and what was said
meanwhile is read from the history. Each message is printed once, by its
(device, nonce) pair, which the node stores once. With --json, one object
per line. The man page lists it, with an example, and its FILES now names
the device keys kept for the Tier 2 check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 |