tools: the details group, the leak scenario's props and three fault classes (#22)
tools/details.test.mjs is the slice's WS acceptance: the five intents and their codes, a grow push clear of a wall, a squeeze in a corridor too narrow for the grown token, stuck from a wall and from a GM placement cleared by a removal and by a shrink, the GM source of a status, the caps and who reads which bucket, and a restart that brings size, props and statuses back. Waits use a cursor taken before the intent, so a repeated state cannot be matched by an older frame. The leak scenario gains a token in view with props in all three buckets, a GM-sourced status, a resize, a wall over it and the clears; leakcheck refuses the `gm` bucket (GM_PROP), the `owner` bucket on a non-controller (OWNER_PROP) and any `source` on a player status entry (STATUS_SOURCE), so `fault.test.mjs` now asserts all twelve classes. The schema-version fixtures in smoke/persistence move to 6, and mutation.sh gains am-au plus the renames.
This commit is contained in:
+11
-4
@@ -49,15 +49,16 @@ test('a fresh DB is created and migrated; re-opening applies nothing', async ()
|
||||
const first = await startServer({ stateDir })
|
||||
const firstLog = first.log()
|
||||
await stopServer(first)
|
||||
assert.match(firstLog, /db_ready .*schema_version=5 applied=5/, firstLog)
|
||||
assert.match(firstLog, /db_ready .*schema_version=6 applied=6/, firstLog)
|
||||
assert.ok(fs.existsSync(first.dbPath), 'state.db was not created')
|
||||
|
||||
const db = new DatabaseSync(first.dbPath)
|
||||
try {
|
||||
assert.equal(Number(db.prepare('PRAGMA user_version').get().user_version), 5)
|
||||
assert.equal(Number(db.prepare('PRAGMA user_version').get().user_version), 6)
|
||||
const rows = db.prepare('SELECT version, name FROM schema_migration ORDER BY version').all()
|
||||
assert.deepEqual(rows.map(r => [Number(r.version), r.name]),
|
||||
[[1, 'meta'], [2, 'auth'], [3, 'world'], [4, 'tokens'], [5, 'explored']])
|
||||
[[1, 'meta'], [2, 'auth'], [3, 'world'], [4, 'tokens'], [5, 'explored'],
|
||||
[6, 'token details']])
|
||||
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM meta').get().n), 0)
|
||||
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM player').get().n), 0)
|
||||
// step 3 seeds the single v1 scene (Q3) with no walls and a counter at 1
|
||||
@@ -68,6 +69,12 @@ test('a fresh DB is created and migrated; re-opening applies nothing', async ()
|
||||
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM entity').get().n), 0)
|
||||
// step 5 creates the chunked explored store (DESIGN 4.4, #21), empty
|
||||
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM explored_chunk').get().n), 0)
|
||||
// step 6 adds the three prop buckets and the status set (DESIGN 5.5, 8; #22), empty
|
||||
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM entity_status').get().n), 0)
|
||||
for (const col of ['props_public', 'props_owner', 'props_gm']) {
|
||||
assert.equal(Number(db.prepare(`SELECT count(*) AS n FROM pragma_table_info('entity')
|
||||
WHERE name = '${col}'`).get().n), 1, col)
|
||||
}
|
||||
assert.equal(db.prepare('PRAGMA journal_mode').get().journal_mode, 'wal')
|
||||
} finally {
|
||||
db.close()
|
||||
@@ -76,7 +83,7 @@ test('a fresh DB is created and migrated; re-opening applies nothing', async ()
|
||||
const second = await startServer({ stateDir })
|
||||
const secondLog = second.log().slice(firstLog.length)
|
||||
await stopServer(second)
|
||||
assert.match(secondLog, /db_ready .*schema_version=5 applied=0/, secondLog)
|
||||
assert.match(secondLog, /db_ready .*schema_version=6 applied=0/, secondLog)
|
||||
assert.doesNotMatch(secondLog, /applied=[1-9]/)
|
||||
} finally {
|
||||
fs.rmSync(stateDir, { recursive: true, force: true })
|
||||
|
||||
Reference in New Issue
Block a user