- 逆向并实现虎牙活动绑角色接口 webActUI.checkUserBindGameAccount,支持精准解析游戏角色名、区服和平台 - 增加本地持久化 roles.json 存储,启动即回显角色信息无需重复请求 - 前端账号作战表与 CK 管理列表整合角色展示([微信-安卓] 角色名),直观区分账号归属 - 工具栏增加「查询角色」按钮,并以兑换记录中的历史账号作为双重兜底 - 升级版本至 v0.5.5 并成功交叉编译 Windows 产物
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package huya
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"testing"
|
|
|
|
"huya-go/internal/wup"
|
|
)
|
|
|
|
var sampleBindRespHex = "000000be10032c3c4001560877656241637455496618636865636b5573657242696e6447616d654163636f756e747d0001008408000206001d0000010c0604745273701d0000700a0100c816002a0001100120013a0600160026027171360046085151e794a8e688b7560066000b4a0600160fe5bfa7e98381e5988ee5b7b4e8b1862604e6898b51360fe5ae89e58d9328616e64726f696429460056000b526a4fc5800b360ce5928ce5b9b3e7b2bee88bb1460050070b811388980ca80c"
|
|
|
|
func TestDecodeCheckUserBindGameAccountResp(t *testing.T) {
|
|
respBytes, err := hex.DecodeString(sampleBindRespHex)
|
|
if err != nil {
|
|
t.Fatalf("decode hex: %v", err)
|
|
}
|
|
|
|
var wResp wup.Response
|
|
if err := wResp.Decode(respBytes); err != nil {
|
|
t.Fatalf("wup decode: %v", err)
|
|
}
|
|
|
|
var resp CheckUserBindGameAccountResp
|
|
ok, err := wResp.ReadStruct("tRsp", &resp)
|
|
if err != nil {
|
|
t.Fatalf("readStruct tRsp: %v", err)
|
|
}
|
|
if !ok {
|
|
t.Fatalf("tRsp not found in response")
|
|
}
|
|
|
|
t.Logf("Status: %d, Msg: %s, GameName: %s", resp.Status, resp.Msg, resp.GameName)
|
|
t.Logf("RoleName: %s, AreaName: %s, PlatName: %s", resp.AccountData.GameRole.RoleName, resp.AccountData.GameRole.AreaName, resp.AccountData.GameRole.PlatName)
|
|
t.Logf("DisplayName: %s", resp.RoleDisplayName())
|
|
|
|
if resp.Status != 200 {
|
|
t.Errorf("expected status 200, got %d", resp.Status)
|
|
}
|
|
if resp.AccountData.GameRole.RoleName != "忧郁嘎巴豆" {
|
|
t.Errorf("expected roleName 忧郁嘎巴豆, got %s", resp.AccountData.GameRole.RoleName)
|
|
}
|
|
if resp.AccountData.GameRole.AreaName != "手Q" {
|
|
t.Errorf("expected areaName 手Q, got %s", resp.AccountData.GameRole.AreaName)
|
|
}
|
|
if resp.AccountData.GameRole.PlatName != "安卓(android)" {
|
|
t.Errorf("expected platName 安卓(android), got %s", resp.AccountData.GameRole.PlatName)
|
|
}
|
|
if resp.RoleDisplayName() != "忧郁嘎巴豆 [手Q-安卓]" {
|
|
t.Errorf("expected roleDisplayName 忧郁嘎巴豆 [手Q-安卓], got %s", resp.RoleDisplayName())
|
|
}
|
|
}
|