mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-15 08:22:06 +00:00
fix(multiplayer): validate ranked arena paths durably
This commit is contained in:
@@ -49,6 +49,18 @@ func RankedArenaForProposal(proposalID string) RankedArena {
|
||||
return rankedArenas[rankedArenaOrder[int(digest[0])%len(rankedArenaOrder)]]
|
||||
}
|
||||
|
||||
// IsRankedArenaPath is the durable-store boundary for arena paths. Proposal
|
||||
// and allocation records must not accept a merely non-empty caller supplied
|
||||
// scene path, even when the caller bypasses matcher formation.
|
||||
func IsRankedArenaPath(path string) bool {
|
||||
for _, arena := range rankedArenas {
|
||||
if arena.Path == path {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ValidateRankedAdmission(participants []RankedParticipant, arena RankedArena) error {
|
||||
if len(participants) != 6 || !validRankedArena(arena) {
|
||||
return fmt.Errorf("ranked admission requirements not met")
|
||||
|
||||
@@ -48,6 +48,19 @@ func TestRankedArenaRegistryExcludesElevatedVariants(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsRankedArenaPathOnlyAllowsFloorGoalRegistry(t *testing.T) {
|
||||
for _, path := range []string{"res://scenes/arena_01.tscn", "res://scenes/arena_02.tscn", "res://scenes/arena_03.tscn"} {
|
||||
if !IsRankedArenaPath(path) {
|
||||
t.Fatalf("eligible path %q rejected", path)
|
||||
}
|
||||
}
|
||||
for _, path := range []string{"", "res://scenes/arena_01_elevated.tscn", "res://forged.tscn"} {
|
||||
if IsRankedArenaPath(path) {
|
||||
t.Fatalf("ineligible path %q accepted", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRankedArenaForProposalIsStableAndRotatesEligibleRegistry(t *testing.T) {
|
||||
first := RankedArenaForProposal("proposal-stable")
|
||||
if first != RankedArenaForProposal("proposal-stable") {
|
||||
|
||||
Reference in New Issue
Block a user