mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 13:32:04 +00:00
feat(multiplayer): rotate ranked arenas deterministically
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package domain
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func rankedParticipants() []RankedParticipant {
|
||||
result := make([]RankedParticipant, 6)
|
||||
@@ -44,3 +47,21 @@ func TestRankedArenaRegistryExcludesElevatedVariants(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRankedArenaForProposalIsStableAndRotatesEligibleRegistry(t *testing.T) {
|
||||
first := RankedArenaForProposal("proposal-stable")
|
||||
if first != RankedArenaForProposal("proposal-stable") {
|
||||
t.Fatal("same proposal selected different arenas")
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for index := 0; index < 128; index++ {
|
||||
arena := RankedArenaForProposal(fmt.Sprintf("proposal-%d", index))
|
||||
if !validRankedArena(arena) {
|
||||
t.Fatalf("proposal selected ineligible arena %+v", arena)
|
||||
}
|
||||
seen[arena.ID] = true
|
||||
}
|
||||
if len(seen) != len(rankedArenaOrder) {
|
||||
t.Fatalf("selected arenas = %v, want every eligible arena", seen)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user