aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-android/app/src/test/kotlin/org/meshbay
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-03 10:30:05 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-03 14:24:54 +0200
commit025b0e0289b7884c4ead980d91b2e659632e1808 (patch)
tree5a37f6741c397ae8f483c563a4a10289d348a8b7 /packages/meshbay-android/app/src/test/kotlin/org/meshbay
parentf73476d71f9b7268650c257db0eed3ab49b94849 (diff)
downloadmeshbay-025b0e0289b7884c4ead980d91b2e659632e1808.tar.gz
fix(android): cast relay serves a clean header and restarts on its ports
The init is what precedes the first moof; ports are reused like Node's; the SDK is read on the main thread; a cast that fails says why on screen, and success waits until the receiver actually plays. Never a VPN's address. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-android/app/src/test/kotlin/org/meshbay')
-rw-r--r--packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt
index 9fe1cfd..e11c8c0 100644
--- a/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt
+++ b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt
@@ -92,6 +92,19 @@ class CastRelayTest {
assertArrayEquals(init + fragment(1) + fragment(2), reply.body)
}
+ @Test fun `a first chunk that carries film is served as its header only`() {
+ // As the page delivers it from a real film: a 64 KB slice holding the
+ // header, the first moof and the start of its mdat — pushed as well.
+ val header = box("ftyp", 20) + box("moov", 1200)
+ val stream = header + fragment(1) + fragment(2)
+ val firstChunk = stream.copyOfRange(0, header.size + 300)
+ val started = relay.start(firstChunk, null)
+ var at = 0
+ while (at < stream.size) { val n = minOf(300, stream.size - at); relay.push(stream, at, n); at += n }
+ val reply = get(started.getString("url"), readBytes = stream.size)
+ assertArrayEquals("header, then each fragment once", stream, reply.body)
+ }
+
@Test fun `the token is required and unguessable`() {
val url = relay.start(null, null).getString("url")
val token = url.substringAfter("t=")
@@ -142,6 +155,17 @@ class CastRelayTest {
assertTrue(relay.backlogBytes() >= CastRelay.RING_MAX_BYTES - big.size)
}
+ @Test fun `seek after seek, the relay restarts on its ports`() {
+ // A seek restarts the relay, and a receiver was connected each time:
+ // the ports it closed sit in TIME_WAIT.
+ repeat(8) {
+ val url = relay.start(null, null).getString("url")
+ relay.push(fragment(it))
+ get(url, readBytes = fragment(it).size)
+ relay.stop()
+ }
+ }
+
@Test fun `stopping closes the port`() {
val url = relay.start(null, null).getString("url")
relay.stop()