aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_streamed_download_reliability.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_streamed_download_reliability.py')
-rw-r--r--packages/meshbay-hub/tests/test_streamed_download_reliability.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/packages/meshbay-hub/tests/test_streamed_download_reliability.py b/packages/meshbay-hub/tests/test_streamed_download_reliability.py
index fa346cb..45138b4 100644
--- a/packages/meshbay-hub/tests/test_streamed_download_reliability.py
+++ b/packages/meshbay-hub/tests/test_streamed_download_reliability.py
@@ -168,8 +168,13 @@ def test_a_missed_claim_does_not_poison_the_page(tmp_path):
def test_a_success_is_reused_rather_than_re_registered(tmp_path):
"""The other half: once controlled, it must not re-register per download."""
r = _run(tmp_path, """
- out.a = await M.openStreamedDownload('a.bin', 10, FAST) !== null;
- out.b = await M.openStreamedDownload('b.bin', 10, FAST) !== null;
+ // Closed, like a real caller: an open target holds a keep-alive interval
+ // for the worker, and a test that leaks one never lets Node exit.
+ for (const name of ['a.bin', 'b.bin']) {
+ const t = await M.openStreamedDownload(name, 10, FAST);
+ out[name[0]] = t !== null;
+ if (t) await t.writable.close();
+ }
""")
assert r["a"] and r["b"]
assert r["log"]["registers"] <= 1, "re-registered on a page already controlled"
@@ -187,8 +192,10 @@ def test_control_arriving_late_is_still_used(tmp_path):
"""
r = _run(tmp_path, """
const t0 = Date.now();
- out.ok = await M.openStreamedDownload('film.mkv', 20e9, FAST) !== null;
+ const target = await M.openStreamedDownload('film.mkv', 20e9, FAST);
+ out.ok = target !== null;
out.waitedMs = Date.now() - t0;
+ if (target) await target.writable.close();
""", control_after_ms=1200, control_budget_ms=6000)
assert r["ok"] is True, "gave up on a claim that arrived late"
assert r["waitedMs"] >= 1100, "did not actually wait for the claim"
@@ -214,7 +221,9 @@ def test_a_missed_navigation_is_retried(tmp_path):
floor. It gets a second go, with a fresh id and a fresh iframe.
"""
r = _run(tmp_path, """
- out.ok = await M.openStreamedDownload('film.mkv', 20e9, FAST) !== null;
+ const t = await M.openStreamedDownload('film.mkv', 20e9, FAST);
+ out.ok = t !== null;
+ if (t) await t.writable.close();
""", serve="second")
assert r["ok"] is True, "one missed navigation ended the download"
assert r["log"]["navigations"] == 2