Load datastores with SubscribableDatastore.fromProvider

clusterio#1129 replaced DatastoreProvider.bootstrap with async factories
and Instance now takes its FactorioServer in the constructor, so the
instance tests pass their server stub there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-28 23:43:25 +00:00
1 parent e84bd97b99
commit afc1d35668
11 files changed
+69 -87

No files matched your search

+4 -6
View File
@@ -7,12 +7,10 @@ import * as path from "node:path";
export default async function (context: ControllerPluginContext) {
const { controller, plugin } = context;
const databaseDirectory = controller.config.get("controller.database_directory");
const players = new lib.SubscribableDatastore(
...await new lib.JsonIdDatastoreProvider(
path.join(databaseDirectory, "exp_player_statistics", "players.json"),
messages.PlayerStatistics.fromJSON.bind(messages.PlayerStatistics),
).bootstrap()
);
const players = await lib.SubscribableDatastore.fromProvider(new lib.JsonIdDatastoreProvider(
path.join(databaseDirectory, "exp_player_statistics", "players.json"),
messages.PlayerStatistics.fromJSON.bind(messages.PlayerStatistics),
));
function addDeltas(deltas: messages.StatisticsDelta[]) {
const changed = new Map<string, messages.PlayerStatistics>();
+5 -4
View File
@@ -29,15 +29,16 @@ async function startPlugin(t2, { status = "running", stats = { Kills: 3 } } = {}
instanceConfig.set("instance.id", 1);
instanceConfig.set("instance.name", "test");
const instance = new Instance(
{ assignGamePort: () => 1 }, new TestConnector(), t2.testdir(), "factorioDir", instanceConfig
);
const state = { sent: [], rcons: [], warnings: [] };
const ipc = new Map();
instance.server = {
const server = {
on: () => {},
handle: (name, handler) => ipc.set(name, handler),
};
const instance = new Instance(
{ assignGamePort: () => 1 }, new TestConnector(), t2.testdir(), instanceConfig, server
);
instance.sendRcon = async command => {
state.rcons.push(command);
return "";