tools: wall harness, and the walls frame in the existing groups (#19)

tools/walls.test.mjs: GM snapshot, CRUD acks and effects, ids monotonic and
never reused, the 6.1 validation table, door toggling, "players get no wall
data" (no walls/wall/wall_gone type and no wall coordinate in any player
frame) and a restart that leaves walls, door state and the id counter
identical. protocol.test.mjs/smoke.test.mjs follow the new frame and schema:
hello = 1, walls = 2, the first ack = 3; user_version 3 with the seeded scene.
This commit is contained in:
2026-11-15 08:49:24 +01:00
parent a8f508ef2e
commit d72fc6ed20
3 changed files with 351 additions and 12 deletions
+9 -4
View File
@@ -49,16 +49,21 @@ 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=2 applied=2/, firstLog)
assert.match(firstLog, /db_ready .*schema_version=3 applied=3/, 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), 2)
assert.equal(Number(db.prepare('PRAGMA user_version').get().user_version), 3)
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']])
assert.deepEqual(rows.map(r => [Number(r.version), r.name]),
[[1, 'meta'], [2, 'auth'], [3, 'world']])
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
assert.deepEqual(db.prepare('SELECT id, next_wall_id FROM scene').all()
.map(r => [Number(r.id), Number(r.next_wall_id)]), [[1, 1]])
assert.equal(Number(db.prepare('SELECT count(*) AS n FROM wall').get().n), 0)
assert.equal(db.prepare('PRAGMA journal_mode').get().journal_mode, 'wal')
} finally {
db.close()
@@ -67,7 +72,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=2 applied=0/, secondLog)
assert.match(secondLog, /db_ready .*schema_version=3 applied=0/, secondLog)
assert.doesNotMatch(secondLog, /applied=[1-9]/)
} finally {
fs.rmSync(stateDir, { recursive: true, force: true })