Files
ChronicleOfTheImmortalClan/tests/clock.test.ts
T
thzxx da4fb9f635 v0.1.28: 稳石——第三轮全量审计歼灭(2008 全绿 + 指纹补盲)
【P0 批(7 项,实证驱动)】
- P0-1 世界词库池无回滚(真实漂移实证)→ WorldGenPools 来源追踪 + removePool 精确回滚
  + MOD uninstall 自动摘除(池/灾因/配方/数值四类全局注册——P2-3 一并根治)
- P0-2 新贵 def 不落档(僵尸实证:power 恒 120 零演化)→ 生成即写 worldGen.npcs
  + normalize 占位 def 双保险 + 新贵 id 掺 seed 指纹(P1-10 防跨档碰撞)
- P0-3 校验死代码化 → installModText 装前 modPreflight(冲突拒+警告 toast)
- P0-4 MOD 读档静默消失 → state.pluginsMissing 收集提示(与 MOD_GUIDE 承诺对齐)
- P0-5 救济按钮乌龙(哈希序首个+直改 state)→ World.reliefCalamity(景气最低+双检)
- P0-6 天下快讯永久冻结(memo 依赖恒 120 length)→ 去 memo 每次 reverse
- P0-7 MOD 导出单行道 → modParse 识别 {app:'cotymod',bundle} 逐包递归(roundtrip 闭环)

【P1 批】
- P1-8 指纹补盲(worldGen/sagaAnnals/distress/declineYears 入 hash——0.1.27 成果真实锁定)+ 双基线重算
- P1-9 重放同步 worldGen.npcs(自捕获);P1-11 worldNum 字段接线(install/uninstall 复位)
- P1-13 落盘兜底(beforeunload/visibilitychange 突发 save,堵 12-tick 节流窗口)
- P1-14 onGameOver 停 timer + IPC mods 路径白名单(扩展名正则防穿越)
- P1-15 DataPack 摘除 npcs(覆写死路删除,与五口宣言对齐);P1-4 techniques 双源统一(techniquePrice 读包)

【P2 扫尾】tauntCD 清理/sagaAnnals 上限 40/worldGenMods 落空写入/validateMod 深度校验随 P0-3 提交

【测试】69 套件 2008 全绿(audit-0.1.28 八例:池回滚/僵尸/preflight/bundle/freeze/指纹敏感/worldNum/救济);
金钟罩 0.1.28 基线重算(指纹补盲+受控时序变更);build 通过
2026-08-23 18:07:31 +08:00

57 lines
2.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { stateFingerprint, longRun } from './fingerprint.helper'
import { World } from '../src/renderer/game/engine/runtime/World'
/**
* 金钟罩:固定种子长跑 560 月的状态指纹。
* 任何改动(重构日程/调平衡/加系统)若改变了确定性序列或结果,此测试立刻报红。
* 更新规则:仅当**有意**变更序列逻辑时,三枚 seed 指纹同版更新并注明原因。
*/
// 0.1.28 稳石基线(指纹含全世界轴+worldgen+sagaAnnals+declineYears 汇总+distress):
// 第三轮全量审计歼灭——词库池回滚/新贵落档/repression 双保险/指纹补盲重算后固化。
const GOLDEN: Record<string, Record<number, string>> = {
'bell-seed-1': { 560: 'b111633d', 1200: '7aaad380', 2160: '312ab6e6' },
'bell-seed-2': { 560: '0cad22aa', 1200: '54d97978', 2160: '7538f86e' },
'bell-seed-3': { 560: '99fc8b01', 1200: 'd125ca18', 2160: '079c3eff' }
}
/** 第二金钟罩:自动 resolve 长跑("现实"世界——每 tick 处理待决事件;
* 锁事件闸/事件流全程,防"冻结世界"指纹漏锁)。 */
const GOLDEN_RESOLVED: Record<string, Record<number, string>> = {
'bell-seed-1': { 560: 'cf3a2ea3', 1200: '2045e95b', 2160: '1ddcb672' },
'bell-seed-2': { 560: 'faa4e88c', 1200: '33650d8d', 2160: '2a22e4b7' },
'bell-seed-3': { 560: 'fe0657fa', 1200: 'f3678400', 2160: 'bd813ee1' }
}
const TIERS = [
[560, '47 年(4 个十年)'],
[1200, '100 年'],
[2160, '180 年']
] as const
describe('金钟罩 · 长跑确定性指纹(三档:47/100/180 年)', () => {
for (const [seed, tiers] of Object.entries(GOLDEN)) {
for (const [months, label] of TIERS) {
it(`${seed} ${label}指纹 === ${tiers[months]}`, () => {
const w = run(seed, months)
expect(stateFingerprint(w.state)).toBe(tiers[months])
})
}
}
it('同 seed 两次长跑指纹一致(无状态污染)', () => {
const a = stateFingerprint(longRun('bell-seed-1').state)
const b = stateFingerprint(longRun('bell-seed-1').state)
expect(a).toBe(b)
})
})
function run(seed: string, months: number): ReturnType<typeof longRun> {
const w = World.create({ seed, surname: '钟', familyName: '钟家', motto: 'm', difficulty: 'normal' })
for (let i = 0; i < months; i++) {
if (w.state.gameOver) break
w.advanceMonth()
}
return w
}