perf(channelserver): cache rengoku_data.bin at startup

Load and validate rengoku_data.bin once during server initialization
instead of reading it from disk on every client request. The file is
static ECD-encrypted config data (~4.9 KB) that never changes at
runtime. Validation checks file size and ECD magic bytes, logging a
warning if the file is missing or invalid so misconfiguration is
caught before any client connects.
This commit is contained in:
Houmgaor
2026-03-02 20:12:39 +01:00
parent aee53534a2
commit 5b631d1704
5 changed files with 139 additions and 8 deletions

View File

@@ -520,6 +520,42 @@ func TestEnumerateRengokuRanking_Applicant(t *testing.T) {
}
}
// --- handleMsgMhfGetRengokuBinary tests ---
func TestGetRengokuBinary_Cached(t *testing.T) {
server := createMockServer()
server.rengokuBin = []byte{0x65, 0x63, 0x64, 0x1a, 0xDE, 0xAD}
session := createMockSession(1, server)
pkt := &mhfpacket.MsgMhfGetRengokuBinary{AckHandle: 100}
handleMsgMhfGetRengokuBinary(session, pkt)
select {
case p := <-session.sendPackets:
if len(p.data) == 0 {
t.Error("Response should have data")
}
default:
t.Error("No response packet queued")
}
}
func TestGetRengokuBinary_NilCache(t *testing.T) {
server := createMockServer()
server.rengokuBin = nil
session := createMockSession(1, server)
pkt := &mhfpacket.MsgMhfGetRengokuBinary{AckHandle: 100}
handleMsgMhfGetRengokuBinary(session, pkt)
select {
case <-session.sendPackets:
// fail ACK was sent — expected
default:
t.Error("No response packet queued (expected fail ACK)")
}
}
// Tests consolidated from handlers_coverage3_test.go
func TestNonTrivialHandlers_RengokuGo(t *testing.T) {