package common import ( "testing" goproto "gac-hkrpg-go/protocol/proto" "google.golang.org/protobuf/proto" ) func TestStandaloneBattleRelicWire(t *testing.T) { relic := Relic{ RelicID: 61151, Level: 15, MainAffixID: 1, InternalUID: 42, SubAffixes: []SubAffix{{SubAffixID: 7, Count: 3, Step: 3}, {SubAffixID: 8, Count: 3, Step: 0}}, } encoded, err := proto.Marshal(relic.ToBattleRelic()) if err != nil { t.Fatal(err) } var decoded goproto.BattleRelic if err := proto.Unmarshal(encoded, &decoded); err != nil { t.Fatal(err) } if decoded.UniqueId != 0 { t.Fatal("standalone battle relic must not use inventory ID") } if decoded.Id != 61151 || decoded.MainAffixId != 1 || len(decoded.SubAffixList) != 2 { t.Fatalf("relic or affixes lost on wire: %v", &decoded) } if decoded.SubAffixList[0].Cnt != 3 || decoded.SubAffixList[0].Step != 3 || decoded.SubAffixList[1].Step != 0 { t.Fatalf("sub-affix values changed on wire: %v", decoded.SubAffixList) } if relic.ToProtoRelic().UniqueId != 42 || relic.ToEquipRelic().RelicUniqueId != 42 { t.Fatal("inventory and equipped relic references must retain their IDs") } }