Combined critique #52: tests for gameRuntime join/tick/dirty + multiplayer races - #856
Merged
Merged
Conversation
… races Adds unit tests for the untested join/tick/dirty paths in gameRuntime (rejoin idempotency, player-row preservation, toProfileRow, tick no-op), an out-of-order world-diff delivery scenario for the client mirror (reorder recovery + permanent loss of the skipped diff), and host-level concurrency tests for concurrent writers to the same room and a mid-session reconnect that evicts the stale connection without dropping room membership.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
# Conflicts: # packages/ws/src/host.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Critique #52: fill highest-risk testing gaps around
gameRuntimejoin/tick/dirty logic and untested multiplayer race conditions.What's added (all additive test files)
packages/core/src/runtime/runtime.test.ts—gameRuntime.tsdirty-flag/commit gaps not covered by the existing join/tick tests:joinPlayermarksdirty.server/dirty.playersand a rejoin doesn't duplicate the dirty-players entryjoinPlayerpreserves an already-seeded player row (economy/unlocks) on rejoin instead of resetting ittoProfileRowreturnsnullfor an unknown player, a proper row for a known onetickwith noonTickhook returns the identical snapshot (early-return branch)packages/core/src/runtime/worldMirror.test.ts— out-of-order diff delivery:needsResync, is dropped for good, and only a diff matching the mirror's current revision recovers it — a diff built on the dropped revision re-triggers resync. Documents real (intended) behavior; not a bug fix.packages/ws/src/host.test.ts— concurrent writers to the same room:runCommandcalls both apply (no lost update from a staleentry.snapshotread)joinServer+runCommandon a freshly-created server never race past server creationpackages/ws/src/hostRouter.test.ts— mid-session reconnect:runCommandimmediately without re-joiningNo bugs found; all behavior tested matches current
origin/main. No production code changed.Still open
Editor
.tsxpanel tests — needs a React testing setup, out of scope here.Gate
bun install— okbun run build— okbun scripts/check-types-all.ts— 29/29 (baseline maintained)bun run test:all— 4512 pass, 0 fail, 1 pre-existing skipGenerated by Claude Code