Files
bd2/go/internal/server/feature/bootstrap_test.go
T

37 lines
1021 B
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
}{
{"/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")
}
})
}
}