test: wait for the async log line instead of racing it

Under the fan-out a test that greps server.log right after an ack can lose:
the logger writes the line after the ack. waitForLog polls to a deadline and
the assertions are unchanged (the line must still appear; absence checks still
run on the same snapshot). Fixes the one observed assertion failure
(fault.test.mjs's intent_failed line) and the same latent race in the
opaque_refused and startup-line checks.
This commit is contained in:
2026-11-21 21:42:34 +01:00
parent 514104f897
commit 100df38230
7 changed files with 44 additions and 19 deletions
+3 -2
View File
@@ -7,7 +7,7 @@ import test from 'node:test'
import assert from 'node:assert/strict'
import fs from 'node:fs'
import { createPlayer, namePlayer, sleep } from './lib.mjs'
import { gmKeyOf, makeStateDir, openAs, startServer, stopServer } from './withserver.mjs'
import { gmKeyOf, makeStateDir, openAs, startServer, stopServer, waitForLog } from './withserver.mjs'
async function gmConnect(origin, gmKey) {
const conn = await openAs(origin, gmKey)
@@ -246,7 +246,8 @@ test('scene.extra: size, key-count and depth caps, boundaries included (#35)', a
const hello2 = await after(gm.ws, mark2, 'hello')
assert.equal(hello2.scene.name, 'Scene', 'the refused patch applied no other field')
assert.equal(hello2.scene.grid_size, 60)
assert.match(s.log(), /opaque_refused field=extra limit=size/)
assert.match(await waitForLog(s, /opaque_refused field=extra limit=size/),
/opaque_refused field=extra limit=size/)
// Key count: 64 accepted, 65 refused; per object, so a 64-key nested object is fine.
assert.equal((await gm.ws.request({ t: 'scene.set', scene: gm.sceneId,