From 923ba10d2a45e90d4d12b34fa08d65d45271eb76 Mon Sep 17 00:00:00 2001 From: bbassie <17990055+bbassie@users.noreply.github.com> Date: Fri, 16 Oct 2026 20:01:22 +0000 Subject: [PATCH] Test the download race and cleared requests without inventories Co-Authored-By: Claude Opus 5.5 --- plugins/player_sync/test/components.js | 9 +++++++++ plugins/player_sync/test/instance.js | 11 ++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/player_sync/test/components.js b/plugins/player_sync/test/components.js index 5f4f298a..2acea5a5 100644 --- a/plugins/player_sync/test/components.js +++ b/plugins/player_sync/test/components.js @@ -148,5 +148,14 @@ describe("player_sync components", function() { const merged = mergePlayerData(storedSlots, withComponents(noSlots, [])); assert.equal("personal_logistic_slots" in merged, false); }); + it("should take cleared logistic requests from an upload without inventories", function() { + const storedSlots = { ...stored, personal_logistic_slots: [{ name: "stored" }] }; + // Factorio 1.1 serializes a character without requests as an empty table + const cleared = { ...uploaded, personal_logistic_slots: {} }; + delete cleared.character; + delete cleared.crafting_queue; + const merged = mergePlayerData(storedSlots, withComponents(cleared, ["inventories"])); + assert.deepEqual(merged.personal_logistic_slots, {}); + }); }); }); diff --git a/plugins/player_sync/test/instance.js b/plugins/player_sync/test/instance.js index 72e95886..93689029 100644 --- a/plugins/player_sync/test/instance.js +++ b/plugins/player_sync/test/instance.js @@ -135,9 +135,14 @@ describe("player_sync", function() { const expected = { generation: 1, name: "test", tag: "tag" }; assert.deepEqual(instance.server.rconCommands, [downloadCommand(expected)]); }); - it("should ignore config changes made after the download was started", async function() { - instance.mockConfigEntries.set("player_sync.sync_force", false); - respondWith({ generation: 1, name: "test", force: "enemy", tag: "tag" }); + it("should ignore config changes made while the controller responds", async function() { + instance.connector.once("send", message => { + instance.mockConfigEntries.set("player_sync.sync_force", false); + instance.connector.emit("message", new lib.MessageResponse( + 1, message.dst, message.src, + new DownloadResponse({ generation: 1, name: "test", force: "enemy", tag: "tag" }), + )); + }); await download({ player_name: "test", components: { force: true } }); const expected = { generation: 1, name: "test", force: "enemy" }; assert.deepEqual(instance.server.rconCommands, [downloadCommand(expected)]);