Receive-side mesh state machine (the bit that decides which peer gets
which tile) was buried inside an anonymous pc.ontrack callback inside
sfuSubscribe(). Extracted into a named top-level function
handleRemoteSfuTrack so tests can drive it directly with synthetic
RTCTrackEvents — no real RTCPeerConnection, no real SFU.
test/multi-peer-mesh.test.js pins fox's stated invariant:
'whatever one device shares all should see, and when unshared none
should see.'
Eight scenarios across 2-3 fake browser sandboxes, each holding the
shipped handleRemoteSfuTrack + renderVideoTile + removeVideoTile +
watchVideoTrackForRemoval + the maps they own:
- one peer publishes camera -> every other peer ends with that pubHex
in cameraStreams + a tile entry
- one peer unshares (track ended) -> every other peer drops that pubHex
- one peer unshares mid-flow (mute past window) -> drops correctly
- hiccup supplant (same pubkey, new track) -> tile preserved AND
pointed at the new stream object (this is the MSID-supplant fix from
d5e9e4e — fresh MediaStream per track means the video element binds
to the new RTP cleanly)
- hiccup supplant + the OLD track's stream-identity guard prevents the
NEW tile from being reaped
- supplant + sustained mute past window on the NEW track -> reaped
correctly
- echo guard: a peer's own publish never enters their own cameraStreams
- three publishers fan-out: A B C all publish, every peer ends with
exactly the other two
Wired into Makefile as test-mesh + added to test-all. Pure Node, no
browser or proxy server needed. Will catch the regressions where one
peer's publish/unpublish silently desyncs another peer's view.
117 lines
4.3 KiB
Makefile
117 lines
4.3 KiB
Makefile
CC = gcc
|
|
CFLAGS = -Wall -Wextra -O2 -Iinclude $(shell pkg-config --cflags libpulse)
|
|
LDFLAGS = $(shell pkg-config --libs libpulse) -lrt -lpthread
|
|
|
|
PULSE = src/pulse.c
|
|
|
|
.PHONY: all clean serve blog test test-all test-web test-zebra-spaces stamp zebrad
|
|
|
|
# stamp each web page with today's date + its own md5/sha256 (run before deploy)
|
|
stamp:
|
|
@node web/stamp.js web/chat.html web/zebra-audio.html web/zebra-spaces.html web/how-it-works.html web/host-your-own.html
|
|
|
|
all: tx rx chat bt carrier zebrad
|
|
|
|
test: test/unit
|
|
@./test/unit
|
|
|
|
# web modem/protocol tests — pure Node, no browser or second device needed
|
|
test-web:
|
|
@node test/web-protocol.test.js
|
|
|
|
# zebra-spaces state-machine tests — pure unit tests for the FSM framework
|
|
# + each machine spec (publish / subscribe / call / remote-tile). Extracts
|
|
# the live code from web/zebra-spaces.html so the tests track the page.
|
|
test-fsm:
|
|
@node test/zebra-fsm.test.js
|
|
|
|
# Receive-side stream lifecycle (watchVideoTrackForRemoval) — fake-clock
|
|
# state-machine tests covering 'when is it safe to remove a tile'. Catches
|
|
# the regressions where transient mutes (NACK gaps, network blips, mobile
|
|
# handoffs, hard-refresh renegotiation churn) would otherwise kill live
|
|
# tiles. Extracts the function from the page and the shipped mute window
|
|
# so the assertions track what's live.
|
|
test-video-removal:
|
|
@node test/video-track-removal.test.js
|
|
|
|
# Mesh state-sync invariant tests — pins the contract fox stated as
|
|
# "whatever one device shares all should see, and when unshared none
|
|
# should see." Runs the shipped handleRemoteSfuTrack + renderVideoTile +
|
|
# removeVideoTile + watchVideoTrackForRemoval against multi-peer
|
|
# scenarios with synthetic ontrack/mute/unmute/ended events. Catches
|
|
# regressions where one peer's publish/unpublish leaves another peer
|
|
# out of sync.
|
|
test-mesh:
|
|
@node test/multi-peer-mesh.test.js
|
|
|
|
# zebra-spaces JS↔Go protocol parity + vault + ed25519 + (optionally) a live
|
|
# server flow. The live-server tier auto-runs when proxy.unturf.com sits
|
|
# alongside this checkout AND has a Go toolchain — we build the relay binary
|
|
# transparently and point the test at it. Otherwise that tier is skipped and
|
|
# only the pure-protocol/crypto tiers run.
|
|
test-zebra-spaces:
|
|
@bin=""; \
|
|
if [ -d ../proxy.unturf.com/cmd/zebra-spaces-signal ]; then \
|
|
go=$$(command -v go || echo /home/fox/.local/go/bin/go); \
|
|
if [ -x "$$go" ]; then \
|
|
echo "Building zebra-spaces-signal for live-server test..."; \
|
|
(cd ../proxy.unturf.com && "$$go" build -o /tmp/zspc-signal-test ./cmd/zebra-spaces-signal/) && bin=/tmp/zspc-signal-test; \
|
|
fi; \
|
|
fi; \
|
|
ZEBRA_SPACES_BINARY=$$bin node test/zebra-spaces.test.js; \
|
|
rc=$$?; rm -f /tmp/zspc-signal-test; exit $$rc
|
|
|
|
test-all: test/unit test/integration test/functional test-web test-fsm test-video-removal test-mesh test-zebra-spaces
|
|
@echo "--- unit ---"
|
|
@./test/unit
|
|
@echo "--- integration ---"
|
|
@./test/integration
|
|
@echo "--- functional ---"
|
|
@./test/functional
|
|
@echo "--- web protocol ---"
|
|
@node test/web-protocol.test.js
|
|
@echo "--- zebra-fsm ---"
|
|
@node test/zebra-fsm.test.js
|
|
@echo "--- video-track-removal ---"
|
|
@node test/video-track-removal.test.js
|
|
@echo "--- multi-peer-mesh ---"
|
|
@node test/multi-peer-mesh.test.js
|
|
@echo "--- zebra-spaces ---"
|
|
@$(MAKE) -s test-zebra-spaces
|
|
|
|
test/unit: test/unit.c include/zebra.h include/modem.h test/test.h
|
|
$(CC) $(CFLAGS) -o $@ test/unit.c
|
|
|
|
test/integration: test/integration.c src/pulse.c include/zebra.h include/modem.h test/test.h
|
|
$(CC) $(CFLAGS) -o $@ test/integration.c src/pulse.c $(LDFLAGS)
|
|
|
|
test/functional: test/functional.c src/pulse.c include/zebra.h include/modem.h test/test.h
|
|
$(CC) $(CFLAGS) -o $@ test/functional.c src/pulse.c $(LDFLAGS)
|
|
|
|
tx: src/tx.c $(PULSE)
|
|
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
|
|
rx: src/rx.c $(PULSE)
|
|
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
|
|
chat: src/chat.c $(PULSE)
|
|
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
|
|
bt: src/bt.c $(PULSE)
|
|
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
|
|
carrier: src/carrier.c
|
|
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
|
|
zebrad: src/zebrad.c include/zebra.h
|
|
$(CC) $(CFLAGS) -o $@ src/zebrad.c $(LDFLAGS) -lm
|
|
|
|
blog:
|
|
python3 blog/build.py
|
|
|
|
serve: blog
|
|
cd web && python3 -m http.server 8765
|
|
|
|
clean:
|
|
rm -f tx rx chat bt carrier zebrad test/unit test/integration test/functional
|
|
rm -rf web/blog/001-volume-modem web/blog/002-sse-chatroom web/blog/index.html
|