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:
+12
-8
@@ -27,19 +27,22 @@ test('hello is the first frame; n counts server frames per connection, never glo
|
||||
assert.equal(hello.proto, 1) // M3 ships proto 1 (DESIGN 6.2)
|
||||
assert.equal(hello.role, 'gm')
|
||||
assert.deepEqual(hello.me, { id: 1, name: 'GM' })
|
||||
// the GM wall snapshot follows hello on the same connection (slice 4, DESIGN 6.1 `walls`)
|
||||
assert.equal((await gm.ws.waitText('walls')).n, 2)
|
||||
|
||||
const first = await gm.ws.request({ t: 'conn.ping', ts: 42 })
|
||||
assert.equal(first.ok, true)
|
||||
assert.equal(first.ts, 42) // the ack echoes ts
|
||||
assert.equal(first.n, 2)
|
||||
assert.equal((await gm.ws.request({ t: 'conn.ping', ts: 43 })).n, 3)
|
||||
assert.equal(first.n, 3)
|
||||
assert.equal((await gm.ws.request({ t: 'conn.ping', ts: 43 })).n, 4)
|
||||
|
||||
// a second connection of the same player counts on its own (H25: no global counter)
|
||||
const other = await openWs(s.origin, gm.cookie)
|
||||
assert.equal((await other.waitText('hello')).n, 1)
|
||||
assert.equal((await other.request({ t: 'conn.ping', ts: 7 })).n, 2)
|
||||
assert.equal((await other.waitText('walls')).n, 2)
|
||||
assert.equal((await other.request({ t: 'conn.ping', ts: 7 })).n, 3)
|
||||
// ... and the first connection's sequence did not move
|
||||
assert.equal((await gm.ws.request({ t: 'conn.ping', ts: 44 })).n, 4)
|
||||
assert.equal((await gm.ws.request({ t: 'conn.ping', ts: 44 })).n, 5)
|
||||
for (const m of gm.ws.messages) assert.equal(typeof m.n, 'number', JSON.stringify(m))
|
||||
})
|
||||
})
|
||||
@@ -59,7 +62,7 @@ test('every server frame carries a catalogue type (nothing outside the wire cata
|
||||
await gm.ws.sendText('{')
|
||||
await sleep(100)
|
||||
const seen = new Set(gm.ws.messages.map(m => m.t))
|
||||
assert.deepEqual([...seen].sort(), ['ack', 'error', 'hello'])
|
||||
assert.deepEqual([...seen].sort(), ['ack', 'error', 'hello', 'walls'])
|
||||
for (const m of gm.ws.messages) assert.ok(SERVER_TYPES.has(m.t), `off-catalogue type ${m.t}`)
|
||||
assert.ok(!seen.has('event'), '`event` is reserved and not built (DESIGN 9)')
|
||||
gm.ws.close()
|
||||
@@ -95,7 +98,8 @@ test('an unknown type is refused, unknown fields are ignored, and every intent g
|
||||
assert.equal((await gm.ws.request({ t: '' })).code, 'unknown-type')
|
||||
assert.equal((await gm.ws.request({ t: 'TOKEN.MOVE', id: 'x' })).code, 'unknown-type')
|
||||
// a catalogue intent whose slice has not landed still answers exactly once
|
||||
assert.equal((await gm.ws.request({ t: 'wall.add', scene: 's' })).code, 'unknown-type')
|
||||
assert.equal((await gm.ws.request({ t: 'token.create', scene: 1 })).code, 'unknown-type')
|
||||
assert.equal((await gm.ws.request({ t: 'scene.set', scene: 1 })).code, 'unknown-type')
|
||||
// the reserved FFF hook is refused for everyone and is never ok
|
||||
const act = await gm.ws.request({ t: 'act.do', actor: 1, action: 'x', args: {} })
|
||||
assert.equal(act.ok, false)
|
||||
@@ -277,12 +281,12 @@ test('the server pings the connection and answers a client Ping with a Pong', as
|
||||
const pong = await raw.waitFor(f => f.opcode === opcodes.pong && f.payload.toString() === 'hello')
|
||||
assert.ok(pong)
|
||||
|
||||
// control frames are not counted by `n`: the next app frame is n = 2
|
||||
// control frames are not counted by `n`: hello = 1, walls = 2, this ack = 3
|
||||
raw.sendText({ t: 'conn.ping', reqId: 900, ts: 5 })
|
||||
const ack = await raw.waitText('ack')
|
||||
assert.equal(ack.reqId, 900)
|
||||
assert.equal(ack.ok, true)
|
||||
assert.equal(ack.n, 2)
|
||||
assert.equal(ack.n, 3)
|
||||
raw.close()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user