diff options
Diffstat (limited to 'packages/meshbay-hub/tests/test_playlist_store.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_playlist_store.py | 37 |
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 |