Files
90CNServer/server/cmd/server/control/client_manifest_hash_test.go
T
hanfuit 645b64fe21 DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go):
- GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面
- GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新
- 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新)
- 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍
- 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0)
- 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算

启动器(Python/JS):
- 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭
- GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐)
- 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
2026-11-04 14:31:55 +08:00

73 lines
2.4 KiB
Go

package main
import (
"crypto/sha256"
"encoding/hex"
"os"
"path/filepath"
"strings"
"testing"
)
// TestClientManifestPinsShippedPatchHashes keeps runtime/assets/client-compatibility.json
// honest about the two DLLs this repository builds.
//
// This controller validates client files by existence only, so a stale hash
// here costs it nothing and would never be noticed locally. DNF90Hub (another
// repository) is the consumer that compares them, and it treats any mismatch —
// including an absent hash, which compares against the empty string — as a
// permanent failure: its "verify and repair client files" action copies the
// file, reports success, and the very next check fails again on the same
// expectation. That is a defect the server side can only cause and only fix,
// so it is pinned from this side.
//
// Commercial client files (DNF.exe / ijl15*.dll) are deliberately not asserted:
// they are not built here and are not in the repository.
func TestClientManifestPinsShippedPatchHashes(t *testing.T) {
t.Setenv("DNF90_PROJECT_ROOT", "")
paths, err := discoverPaths()
if err != nil {
t.Fatalf("discoverPaths() error = %v", err)
}
var manifest clientManifest
if err := readStrictJSON(paths.clientManifest, &manifest); err != nil {
t.Fatalf("read client manifest: %v", err)
}
pinned := map[string]string{}
for _, entry := range manifest.Files {
for _, name := range entry.Names {
pinned[strings.ToLower(name)] = entry.SHA256
}
}
for _, name := range []string{"90CN.dll", "90CNLua.dll"} {
declared, found := pinned[strings.ToLower(name)]
if !found {
t.Fatalf("client manifest does not declare %s", name)
}
if strings.TrimSpace(declared) == "" {
t.Fatalf(
"client manifest has no sha256 for %s; DNF90Hub compares this value and an "+
"empty one makes its client repair loop forever",
name,
)
}
shipped := filepath.Join(paths.runtimeRoot, "patch", name)
data, err := os.ReadFile(shipped)
if err != nil {
t.Fatalf("read shipped %s: %v", name, err)
}
sum := sha256.Sum256(data)
actual := hex.EncodeToString(sum[:])
if !strings.EqualFold(actual, declared) {
t.Fatalf(
"client manifest sha256 for %s is stale: manifest=%s runtime/patch=%s; "+
"update runtime/assets/client-compatibility.json after rebuilding the client patch",
name, strings.ToUpper(declared), strings.ToUpper(actual),
)
}
}
}