Skip to content

Combined critique #52: tests for gameRuntime join/tick/dirty + multiplayer races - #856

Merged
Noisemaker111 merged 2 commits into
mainfrom
claude/critique-52-testing-gaps
Jul 16, 2026
Merged

Noisemaker111 merged 2 commits into
mainfrom
claude/critique-52-testing-gaps

Conversation

@Noisemaker111

Copy link
Copy Markdown
Owner

Problem

Critique #52: fill highest-risk testing gaps around gameRuntime join/tick/dirty logic and untested multiplayer race conditions.

What's added (all additive test files)

packages/core/src/runtime/runtime.test.tsgameRuntime.ts dirty-flag/commit gaps not covered by the existing join/tick tests:

  • joinPlayer marks dirty.server/dirty.players and a rejoin doesn't duplicate the dirty-players entry
  • joinPlayer preserves an already-seeded player row (economy/unlocks) on rejoin instead of resetting it
  • toProfileRow returns null for an unknown player, a proper row for a known one
  • tick with no onTick hook returns the identical snapshot (early-return branch)

packages/core/src/runtime/worldMirror.test.ts — out-of-order diff delivery:

  • a diff arriving out of order (revision 3 before revision 2) flags 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:

  • two different users' concurrent runCommand calls both apply (no lost update from a stale entry.snapshot read)
  • a burst of 10 concurrent calls from one player all serialize correctly through the host's internal queue
  • a concurrent joinServer + runCommand on a freshly-created server never race past server creation

packages/ws/src/hostRouter.test.ts — mid-session reconnect:

  • a second connection for the same userId (singleSession) evicts the stale connection but keeps room membership live — the new connection can runCommand immediately without re-joining

No bugs found; all behavior tested matches current origin/main. No production code changed.

Still open

Editor .tsx panel tests — needs a React testing setup, out of scope here.

Gate

  • bun install — ok
  • bun run build — ok
  • bun scripts/check-types-all.ts — 29/29 (baseline maintained)
  • bun run test:all — 4512 pass, 0 fail, 1 pre-existing skip

Generated by Claude Code

… 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.
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
jgengine-web Ready Ready Preview, Comment Jul 16, 2026 1:54pm

# Conflicts:
#	packages/ws/src/host.test.ts
@Noisemaker111
Noisemaker111 merged commit c4a4c08 into main Jul 16, 2026
1 of 2 checks passed
@Noisemaker111
Noisemaker111 deleted the claude/critique-52-testing-gaps branch July 16, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants