docs & feat: add license & attribution notice (Apache-2.0 / GPL-3.0) and core system enhancements
This commit is contained in:
1 parent
507836d367
commit
ce6aabfc55
47 files changed
+5674
-724
No files matched your search
@@ -0,0 +1,72 @@
|
||||
package gameserver
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gac-hkrpg-go/internal/common"
|
||||
pb "gac-hkrpg-go/protocol/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func TestGetGachaInfoScRspWireTags(t *testing.T) {
|
||||
if err := common.LoadBannersConfig(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
rsp := &pb.GetGachaInfoScRsp{
|
||||
Retcode: 0,
|
||||
GachaRandom: 1234,
|
||||
}
|
||||
banners := common.GetVisibleBanners(1)
|
||||
if len(banners) == 0 {
|
||||
t.Fatal("expected visible banners")
|
||||
}
|
||||
for _, b := range banners {
|
||||
rsp.GachaInfoList = append(rsp.GachaInfoList, b.ToProtoInfo())
|
||||
}
|
||||
|
||||
bin, err := proto.Marshal(rsp)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to marshal GetGachaInfoScRsp: %v", err)
|
||||
}
|
||||
|
||||
// Verify that tag 15 (gacha_info_list) is present:
|
||||
// Field number 15, wire type 2 (length delimited) -> (15 << 3) | 2 = 122 = 0x7a
|
||||
tag15Found := false
|
||||
for _, b := range bin {
|
||||
if b == 0x7a {
|
||||
tag15Found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !tag15Found {
|
||||
t.Errorf("Tag 15 (0x7a) for gacha_info_list was NOT found in serialized payload!")
|
||||
}
|
||||
|
||||
// Unmarshal back to ensure clean round-trip
|
||||
var decoded pb.GetGachaInfoScRsp
|
||||
if err := proto.Unmarshal(bin, &decoded); err != nil {
|
||||
t.Fatalf("failed to unmarshal: %v", err)
|
||||
}
|
||||
if len(decoded.GachaInfoList) != len(banners) {
|
||||
t.Fatalf("expected %d banners, got %d", len(banners), len(decoded.GachaInfoList))
|
||||
}
|
||||
|
||||
// Verify banner 1001
|
||||
var found1001 *pb.GachaInfo
|
||||
for _, info := range decoded.GachaInfoList {
|
||||
if info.GachaId == 1001 {
|
||||
found1001 = info
|
||||
break
|
||||
}
|
||||
}
|
||||
if found1001 == nil {
|
||||
t.Fatal("banner 1001 not found in decoded response")
|
||||
}
|
||||
if found1001.EndTime == 0 {
|
||||
t.Errorf("banner 1001 EndTime should not be 0")
|
||||
}
|
||||
if found1001.GachaCeiling == nil {
|
||||
t.Errorf("banner 1001 GachaCeiling should not be nil")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user