aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_playlist_store.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-16 17:47:00 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-16 17:47:00 +0200
commitc35f3a73eb68cdd7c4179cded3d1ead63ec5a033 (patch)
treeeabf5919a19646d5410adfe0e184cc608e1a9c48 /packages/meshbay-hub/tests/test_playlist_store.py
parent3d4080e9a1b79e99428a80391e224ea73cf4274d (diff)
downloadmeshbay-c35f3a73eb68cdd7c4179cded3d1ead63ec5a033.tar.gz
playlists: refuse a body no frame can carry, and say which one
A DataChannel send() throws above the max-message-size the node advertises (aiortc: 65536), so the 1 MB body cap was unreachable and each body push swallowed the difference in a bare catch. Cap at 62 KB after sealing, name the playlist in the sync result, keep syncing the rest. Measured: 1000 tracks seal to 53 276 bytes, so the ceiling is ~1200. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/tests/test_playlist_store.py')
-rw-r--r--packages/meshbay-hub/tests/test_playlist_store.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_playlist_store.py b/packages/meshbay-hub/tests/test_playlist_store.py
index 59afaee..ce094c4 100644
--- a/packages/meshbay-hub/tests/test_playlist_store.py
+++ b/packages/meshbay-hub/tests/test_playlist_store.py
@@ -280,3 +280,40 @@ def test_a_session_from_before_the_hkdf_handle_degrades_rather_than_failing(step
r = steps["a session from before the HKDF handle"]["result"]
assert r["ok"] is False and r["reason"] == "no_key"
assert r["pushed"] == 0
+
+
+def test_what_a_playlist_costs_sealed_is_measured_not_quoted(steps):
+ """The ceiling the UI promises comes from here, not from the design doc.
+
+ ยง4 measured ~270 bytes a track *raw* and ~60 *sealed*; the raw figure was
+ then read for the sealed one and "about 225 tracks" written down, which is
+ five times too strict. So the number is measured where it is used.
+ """
+ sizes = steps["what a playlist costs sealed"]["sizes"]
+ per_track = (sizes["1000"] - sizes["100"]) / 900
+ assert 30 < per_track < 90, f"a track now costs {per_track:.0f} sealed bytes"
+ # The sentence shown to a reader is "playlists of about 1000 tracks". If
+ # compression regresses, or a field is added to what is stored, that
+ # sentence becomes false โ€” and this is what says so.
+ assert sizes["1000"] < 62 * 1024, (
+ f"a thousand tracks no longer fit in one frame: {sizes['1000']} bytes")
+
+
+def test_a_playlist_too_large_for_a_frame_is_named(steps):
+ # Not "a sync failed": which playlist, so the reader can act. A bare
+ # `catch {}` per body is what let this stop leaving the browser in silence.
+ s = steps["a playlist too large for one frame"]
+ assert s["result"]["tooLarge"] == ["Trop longue"]
+ kinds = [e["kind"] for e in s["stored"]]
+ assert s["bigKind"] not in kinds, "the oversized body was handed to send() anyway"
+
+
+def test_one_oversized_playlist_does_not_break_the_rest_of_the_sync(steps):
+ s = steps["a playlist too large for one frame"]
+ assert s["result"]["ok"] is True
+ assert s["result"]["failed"] == []
+ kinds = [e["kind"] for e in s["stored"]]
+ # The manifest last, and the other bodies before it: one playlist that
+ # cannot be sent must not hold back the four that can.
+ assert "playlists" in kinds
+ assert len([k for k in kinds if k.startswith("playlist:")]) >= 4