import test from "node:test"; import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; test("client stores migration state and exposes all three transfer actions", async () => { const [gameManager, gameConfig, utils] = await Promise.all([ readFile(new URL("../../../assets/Script/GameManager.ts", import.meta.url), "utf8"), readFile(new URL("../../../assets/Script/module/Config/GameConfig.ts", import.meta.url), "utf8"), readFile(new URL("../../../assets/Script/module/Pay/Utils.ts", import.meta.url), "utf8"), ]); assert.match(gameConfig, /wucai_type:\s*number/); assert.match(gameConfig, /wucai_type:\s*-1/); assert.match(gameConfig, /wucai_preview:\s*any/); assert.match(gameManager, /GM_INFO\.wucai_type\s*=\s*Number\.isInteger/); assert.match(gameManager, /GM_INFO\.wucai_preview\s*=\s*data\.data\.wucai_preview \|\| null/); assert.match(gameManager, /GM_INFO\.wucai_type === 1/); assert.match(utils, /"claim_reward" \| "choose_wucai" \| "choose_current"/); assert.match(utils, /Utils\.POST\("wucaiTransfer"/); assert.match(utils, /MiniGameSdk\.API\.reboot\(\)/); }); test("forcedUpdate is acknowledged only from the completed load gate", async () => { const gameManager = await readFile( new URL("../../../assets/Script/GameManager.ts", import.meta.url), "utf8" ); const updateIndex = gameManager.indexOf("update(dt)"); const clearIndex = gameManager.indexOf("Utils.setForcedUpdate("); assert.ok(updateIndex >= 0); assert.ok(clearIndex > updateIndex); assert.match(gameManager, /data\.forcedUpdate === true[\s\S]*this\.applyForcedProgress\(data\)/); assert.match(gameManager, /data\.data\.forcedUpdate === true[\s\S]*effectivePowerTime/); assert.match(gameManager, /data\.data\.forcedUpdate === true[\s\S]*StorageMessage\.setStorage\("health"/); assert.match(gameManager, /winStreak !== undefined && data\.data\.winStreak !== null/); }); test("forcedUpdate backend requires a token and checks the update result", async () => { const source = await readFile( new URL("../functions/setForcedUpdate.ts", import.meta.url), "utf8" ); assert.match(source, /!res\.data \|\| !res\.data\.token \|\| !token1/); assert.match(source, /res1\.ok !== false && res1\.updated !== 0/); assert.doesNotMatch(source, /if \(res\.ok && res1\.updated/); });