Skip to content

Updated unit tests - #11

Merged
colemancda merged 9 commits into
mainfrom
fix/networking-test-flakiness
Jul 18, 2026
Merged

colemancda merged 9 commits into
mainfrom
fix/networking-test-flakiness

Conversation

@colemancda

@colemancda colemancda commented Jul 18, 2026 •

Copy link
Copy Markdown
Owner

Problem

CI intermittently fails with timeout(nonceResponse) after 30s — e.g. the 0.3.2 tag run of the PR #10 merge. The view-model networking suites added in PR #10 spin up in-memory servers/clients that swift-testing runs in parallel in-process, and two issues made them flaky: the stabilization commits didn't make it into the PR #10 merge, so main has the tests without the fixes.

Fix

  • UDP mock parks instead of spinning — a per-server 10Hz wake starved the cooperative pool when many ran at once.
  • Unique server ports from the registry — random ports birthday-collide across a full run and silently overwrite each other's listeners, so a client connects to the wrong server and the handshake hangs.
  • Shared SerialGate serializes the server-spinning tests.
  • connect() fails fast (5s) and retries — the in-memory socket has a rare handshake lost-wakeup that a fresh socket pair sidesteps; retrying avoids the 30s request-timeout hang. Loopback suites route through the same retrying connect.
  • Ratchets the coverage gate to 71% (overall libs ~73%).

Test plan

  • swift test green across repeated local runs (~12s each, previously flaked ~1-in-4)
  • CI green on this PR

Several fixes so the server-spinning suites are deterministic under
swift-testing's in-process parallelism:
- UDP mock parks instead of spinning (a per-server 10Hz wake starved
  the cooperative pool when many ran at once).
- Unique server ports from the registry (random ports birthday-collide
  across a full run and silently overwrite each other's listeners).
- A shared SerialGate serializes server-spinning tests.
- connect() fails fast (5s) and retries: the in-memory socket has a
  rare handshake lost-wakeup that a fresh socket pair sidesteps.
- Loopback suites route through the same retrying connect.

Full suite is green across repeated runs (~12s).
GunBound view-model networking coverage lifted overall libs to ~73%.
A shared ScreenHarness (fake-texture renderer + nonexistent-asset
ClientContext + silent audio) drives each GameScreen through
onEnter -> render -> a spread of input events -> update -> render.
Lifts GunBoundClient from 37% to 65% by exercising the screens'
layout and draw code, which had no coverage at all.
Tests the factory maps every mode to a screen, and drives the state
machine through boot, transitions to every screen (arming the wipe),
input/gamepad forwarding, and render.
Runs aim/walk/weapon/charge/fire across several turns plus chat, a
relayed action, and a death, rendering every frame — covering the
screen's phase-dependent draw code and the underlying simulation.
Covers the screen and embedded-widget draw branches the default smoke
pass leaves untouched: populated room/server lists, open Create Room
and buddy panels, avatar catalog selection + try-on + tab switches,
and a seeded Ready Room roster.
Tests every ClientMode's description/rawValue/round-trip and the
Mobile(argument:) parser (valid, unknown-number, non-number).
@colemancda colemancda changed the title Fix flaky in-memory networking tests (CI timeout) Updated unit tests Jul 18, 2026
@colemancda
colemancda merged commit 5e85a35 into main Jul 18, 2026
5 checks passed
@colemancda
colemancda deleted the fix/networking-test-flakiness branch July 18, 2026 04:13
@colemancda colemancda mentioned this pull request Jul 18, 2026
1 of 2 tasks
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.

1 participant