Files
bd2/go/internal/server/feature/bootstrap_test.go
T
Flechazo 5b5a219dc2 feat(server): add special loot and data-driven gameplay rules
Generate equipment loot atomically, grant random boxes and prevent repeat claims.
Read gacha pools, pity, products, tickets, missions, presets, chapter rewards
and inventory costs from GameData; extend both collaboration UR ticket pools.
Sync owned recipes, configure startup state and calendars in versioned seeds,
and validate unlock tickets and revival talents.
2026-10-04 19:15:59 +08:00

38 lines
1.0 KiB
Go

package feature
import (
"bytes"
"testing"
"bd2server/internal/server/wire"
)
func TestBootstrapProtocolDefaults(t *testing.T) {
for _, test := range []struct {
path string
code int
proto []byte
}{
{"/CashMailInfo", 140, []byte{0x18, 0}},
{"/AvatarInfo", 467, []byte{0x0a, 0}},
{"/GuildRaidSeasonReward", 310, []byte{0x0a, 0}},
} {
t.Run(test.path, func(t *testing.T) {
code, proto, handled, err := Handle(test.path, wire.AppendVarint(nil, 1, 42))
if err != nil || !handled || code != test.code || !bytes.Equal(proto, test.proto) {
t.Fatalf("code=%d proto=%x handled=%v err=%v", code, proto, handled, err)
}
if len(proto) != 0 {
proto[0] ^= 0xff
}
_, again, _, err := Handle(test.path, wire.AppendVarint(nil, 1, 43))
if err != nil || !bytes.Equal(again, test.proto) {
t.Fatalf("response mutation escaped into defaults: proto=%x err=%v", again, err)
}
if _, _, handled, err := Handle(test.path, nil); !handled || err == nil {
t.Fatal("bootstrap endpoint accepted missing sequence")
}
})
}
}