mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 23:24:52 +09:00
Check the run token on every prefetched chunk
Chunks of an earlier controller run's copy still in flight could land in a newer run's copy of the same generation. Every chunk now carries the token, and the scenario ignores a chunk whose token differs from its record's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5e4dcada50
commit
17f029e39e
3 files changed
+10
-9
No files matched your search
@@ -277,7 +277,7 @@ describe("player_sync", function() {
|
||||
const sent = lib.escapeString(JSON.stringify(Object.fromEntries(enabled.map(c => [c, true]))));
|
||||
return chunks.map((chunk, i) => "/sc player_sync.prefetch_inventory(" +
|
||||
`'test',${playerData.generation},'${lib.escapeString(chunk)}',${i + 1},${chunks.length}` +
|
||||
`${i === 0 ? `,'${sent}','tok'` : ""})`);
|
||||
`${i === 0 ? `,'${sent}','tok'` : ",nil,'tok'"})`);
|
||||
}
|
||||
|
||||
it("should send prefetch_inventory chunks with the generation and the full recipe list", async function() {
|
||||
@@ -296,11 +296,11 @@ describe("player_sync", function() {
|
||||
assert.ok(commands.length > 1, "more than one chunk");
|
||||
assert.deepEqual(instance.server.rconCommands, commands);
|
||||
});
|
||||
it("should send the token with the first chunk only", async function() {
|
||||
it("should send the token with every chunk", async function() {
|
||||
await prefetch({ generation: 3, name: "test" });
|
||||
const commands = instance.server.rconCommands;
|
||||
assert.ok(commands[0].endsWith(",'tok')"));
|
||||
assert.ok(commands.slice(1).every(command => !command.includes("tok")));
|
||||
assert.ok(commands.length > 1 && commands.slice(1).every(command => command.endsWith(",nil,'tok')")));
|
||||
});
|
||||
it("should stop when the save refuses the first chunk", async function() {
|
||||
const playerData = { generation: 3, name: "test" };
|
||||
|
||||
Reference in new issue
Block a user