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:
@@ -6,7 +6,8 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import { gmKeyOf, makeStateDir, startServer, stopServer, withGmServer, openAs } from './withserver.mjs'
|
||||
import { gmKeyOf, makeStateDir, startServer, stopServer, withGmServer, openAs,
|
||||
waitForLog } from './withserver.mjs'
|
||||
import { createPlayer, sleep } from './lib.mjs'
|
||||
|
||||
// The GM's first connection: hello, then the wall snapshot (DESIGN 6.1 `walls`, 6.3).
|
||||
@@ -753,8 +754,9 @@ test('wall.flags: size, key-count and depth caps, boundaries included (#35)', as
|
||||
await sleep(80)
|
||||
assert.equal(gm.ws.messages.filter(m => m.t === 'wall').length, before,
|
||||
'a refused add emits no wall frame')
|
||||
assert.match(s.log(), /opaque_refused field=flags limit=size/)
|
||||
assert.equal(s.log().includes('xxxxxxxx'), false, 'the refused value is never logged')
|
||||
const refusedLog = await waitForLog(s, /opaque_refused field=flags limit=size/)
|
||||
assert.match(refusedLog, /opaque_refused field=flags limit=size/)
|
||||
assert.equal(refusedLog.includes('xxxxxxxx'), false, 'the refused value is never logged')
|
||||
// The refused add consumes no wall id: the next wall follows the accepted one densely.
|
||||
const next = await addWall(gm, { a: [10, 30], b: [100, 30] })
|
||||
assert.equal(next.id, ok.id + 1)
|
||||
|
||||
Reference in New Issue
Block a user