mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
35 lines
1.3 KiB
Go
35 lines
1.3 KiB
Go
package domain
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func FuzzQueueCreateDoesNotPanic(f *testing.F) {
|
|
f.Add("player-1", "ticket-1", "key-1234567890123456", 1500.0, "EU", 20.0)
|
|
f.Fuzz(func(t *testing.T, playerID, ticketID, key string, rating float64, region string, rtt float64) {
|
|
q := NewQueue()
|
|
now := time.Unix(1000, 0)
|
|
candidate := Candidate{PlayerID: playerID, TicketID: ticketID, Rating: rating, EnqueuedAt: now, PredictedRTT: map[string]float64{region: rtt}}
|
|
_, _ = q.Create(playerID, ticketID, key, candidate, now)
|
|
})
|
|
}
|
|
|
|
func FuzzResultDigestIsDeterministic(f *testing.F) {
|
|
f.Add("match-1", "server-1", "nonce-1234567890", 3, 2, string(IntegrityCertified))
|
|
f.Fuzz(func(t *testing.T, matchID, serverID, nonce string, team0, team1 int, integrity string) {
|
|
result := MatchResult{MatchID: matchID, ServerID: serverID, ResultNonce: nonce, Team0Score: team0, Team1Score: team1, IntegrityState: IntegrityState(integrity)}
|
|
if resultDigest(result) != resultDigest(result) {
|
|
t.Fatal("digest is not deterministic")
|
|
}
|
|
})
|
|
}
|
|
|
|
func FuzzSyncEventApplicationDoesNotPanic(f *testing.F) {
|
|
f.Add(uint64(1), "QUEUED")
|
|
f.Fuzz(func(t *testing.T, revision uint64, state string) {
|
|
r, _ := NewReplicaResource(ResourceQueueTicket, "ticket-1", Queued)
|
|
_ = r.ApplyEvent(SyncEvent{Kind: ResourceQueueTicket, ResourceID: "ticket-1", Revision: revision, State: State(state)})
|
|
})
|
|
}
|