mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Check connection and status in subspace_storage timers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
11e067a933
commit
1eea756ab3
2 files changed
+42
-12
No files matched your search
@@ -154,5 +154,38 @@ describe("subspace_storage plugin", function() {
|
||||
nodeMock.timers.reset();
|
||||
}
|
||||
});
|
||||
describe("timers and unpause", function() {
|
||||
const ping = "/sc __subspace_storage__ global.ticksSinceMasterPinged = 0";
|
||||
const isInventory = command => command.includes("UpdateInvData");
|
||||
let startedInstance;
|
||||
let host;
|
||||
beforeEach(async function() {
|
||||
nodeMock.timers.enable({ apis: ["setInterval", "Date"], now: 1000000 });
|
||||
({ instance: startedInstance, host } = await mock.loadInstancePlugin(instanceEntrypoint, info));
|
||||
host.connected = true;
|
||||
startedInstance.sendTo = async () => [];
|
||||
await startedInstance.hooks.start.invoke();
|
||||
startedInstance.server.rconCommands.length = 0;
|
||||
});
|
||||
afterEach(async function() {
|
||||
await startedInstance.hooks.stop.invoke();
|
||||
nodeMock.timers.reset();
|
||||
});
|
||||
|
||||
it("should not ping while the host is disconnected", async function() {
|
||||
host.connected = false;
|
||||
nodeMock.timers.tick(5000);
|
||||
await startedInstance.hooks.autoPauseChanged.invoke(false);
|
||||
const commands = startedInstance.server.rconCommands;
|
||||
assert(!commands.includes(ping), "ping was sent");
|
||||
assert.equal(commands.filter(isInventory).length, 6);
|
||||
});
|
||||
it("should not send inventory while not running", async function() {
|
||||
startedInstance.status = "stopping";
|
||||
nodeMock.timers.tick(5000);
|
||||
await startedInstance.hooks.autoPauseChanged.invoke(false);
|
||||
assert.deepEqual(startedInstance.server.rconCommands, [ping]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user