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:
+2
-3
@@ -15,7 +15,7 @@ import crypto from 'node:crypto'
|
||||
import fs from 'node:fs'
|
||||
import { createPlayer, join, openWs, rawWs, sleep } from './lib.mjs'
|
||||
import { gmKeyOf, makeStateDir, openAs, parseGmKey, runGmKey, startServer,
|
||||
stopServer } from './withserver.mjs'
|
||||
stopServer, waitForLog } from './withserver.mjs'
|
||||
|
||||
const sha256 = s => crypto.createHash('sha256').update(s).digest('hex')
|
||||
|
||||
@@ -134,8 +134,7 @@ test('logs: the negative control finds a raw key when the server leaks one', asy
|
||||
env: { LEAK_FAULT: 'keylog' } })
|
||||
try {
|
||||
assert.equal((await join(s.origin, gmKey)).status, 303)
|
||||
await sleep(100)
|
||||
const log = s.log()
|
||||
const log = await waitForLog(s, gmKey)
|
||||
assert.ok(log.includes(gmKey), `the leaked key must be visible to the grep; log:\n${log}`)
|
||||
} finally {
|
||||
await stopServer(s)
|
||||
|
||||
Reference in New Issue
Block a user