commit 43712e85851afef65c67fddb62ab2844a26859ff
parent 387a684f32cd32df11b76f799989d22c07cc116e
Author: anon <anon@example.com>
Date: Fri, 30 Oct 2026 10:27:31 +0000
Retain native test errors after trace rollover
Diffstat:
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/client/tests/game_test.mjs b/client/tests/game_test.mjs
@@ -101,3 +101,17 @@ test('a stalled game releases held keys and reports the unmet condition', async
await assert.rejects(action, /Timed out waiting for crossing the doorway/);
assert.deepEqual(keys, [['down', 'KeyW'], ['up', 'KeyW']]);
});
+
+test('client errors still fail waits after ordinary traffic fills the trace', async () => {
+ const game = new GameTest();
+ game.snapshot = async () => ({frame: 1});
+ game.record({kind: 'error', message: 'native client aborted'});
+ for (let i = 0; i < 2048; ++i) game.record({kind: 'position', position: [1, 2, 3]});
+
+ const action = game.wait('an otherwise satisfied condition', () => true);
+
+ await assert.rejects(action, /native client aborted/);
+ assert.equal(game.dropped, 1);
+ assert.equal(game.events.some(event => event.kind === 'error'), false);
+ assert.equal(game.errors[0].message, 'native client aborted');
+});
diff --git a/tools/client/game_test.mjs b/tools/client/game_test.mjs
@@ -30,6 +30,7 @@ export class PacketStream {
export class GameTest {
events = [];
+ errors = [];
snapshots = [];
sequence = 0;
dropped = 0;
@@ -103,7 +104,9 @@ export class GameTest {
if (event.kind === 'packet' && event.direction === 'framereceived' && event.opcode === '570c2039' &&
event.navigation === this.navigation && event.stream === this.worldStream && event.actor?.[0] === 50000)
this.readyActors.add(event.actor[1]);
- this.events.push({time: Date.now(), navigation: this.navigation, ...event, sequence: ++this.sequence});
+ const recorded = {time: Date.now(), navigation: this.navigation, ...event, sequence: ++this.sequence};
+ this.events.push(recorded);
+ if (event.kind === 'error') this.errors.push(recorded);
if (this.events.length > 2048) { this.events.shift(); ++this.dropped; }
}
@@ -149,7 +152,7 @@ export class GameTest {
if (error.name !== 'TimeoutError') throw error;
break;
}
- const error = this.events.find(event => event.kind === 'error');
+ const error = this.errors[0];
assert(!error, error?.message);
if (predicate(state)) return state;
} while (Date.now() < deadline);
@@ -248,7 +251,7 @@ export class GameTest {
async save(directory) {
await fs.mkdir(directory, {recursive: true});
await fs.writeFile(`${directory}/trace.json`, JSON.stringify({url: this.page.url(),
- dropped: this.dropped, events: this.events, snapshots: this.snapshots}, null, 2) + '\n');
+ dropped: this.dropped, errors: this.errors, events: this.events, snapshots: this.snapshots}, null, 2) + '\n');
await this.page.screenshot({path: `${directory}/screen.png`});
}
}
diff --git a/tools/client/test_starter_equipment.mjs b/tools/client/test_starter_equipment.mjs
@@ -77,7 +77,7 @@ try {
assert.deepEqual(reworn.Items, equipped.Items);
await observer.snapshot();
assert.deepEqual(observer.local().inventory, watched);
- for (const game of games) assert.deepEqual(game.events.filter(event => event.kind === 'error'), []);
+ for (const game of games) assert.deepEqual(game.errors, []);
console.log('PASS: native remove/rewear preserves both starter loadouts and charges');
} finally {
try {