BlueGit

timfa questward

Files

questward / server / tests / worker-threads.test.js

worker-threads.test.js

worker-threads.test.js 782 B Download Raw
1import test from "node:test";
2import assert from "node:assert/strict";
3import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";
4
5test("thread workers speak the same protocol as in-process workers", { timeout: 20_000 }, async () =>
6{
7 const harness = makeSimulation({ workerCount: 1, workerMode: "thread" });
8 try
9 {
10 const character = makeCharacter(harness.stateDb);
11 const entityId = harness.simulation.spawnCharacter(1, character);
12 const snapshots = harness.simulation.snapshotFor(entityId);
13 assert.equal(snapshots.length, 9);
14 assert.ok(snapshots.some((snapshot) => snapshot.entities.some((entity) => entity.entityId === entityId)));
15 }
16 finally
17 {
18 await harness.simulation.shutdown();
19 harness.worldDb.close();
20 harness.stateDb.close();
21 }
22});