mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-12 16:13:44 +00:00
fix(multiplayer): complete live results atomically
This commit is contained in:
@@ -102,6 +102,9 @@ func (s *ResultStore) Submit(resultID string, result MatchResult, binding Worklo
|
||||
if resultID == "" || !sameBinding(s.expected, binding) {
|
||||
return ResultReceipt{}, false, ErrResultBinding
|
||||
}
|
||||
if now.IsZero() {
|
||||
return ResultReceipt{}, false, ErrResultInvalid
|
||||
}
|
||||
if err := validateResult(s.expected, result); err != nil {
|
||||
return ResultReceipt{}, false, err
|
||||
}
|
||||
|
||||
@@ -36,6 +36,17 @@ func TestResultStoreBindsWorkloadAndMakesIdenticalDuplicateInert(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestResultStoreRejectsMissingAuthoritativeTime(t *testing.T) {
|
||||
binding := testBinding()
|
||||
store, err := NewResultStore(binding)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, _, err := store.Submit("result-1", testResult(), binding, time.Time{}); !errors.Is(err, ErrResultInvalid) {
|
||||
t.Fatalf("zero-time result error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConflictingResultIsInertAndIntegritySuppressesRating(t *testing.T) {
|
||||
now := time.Unix(1000, 0)
|
||||
binding := testBinding()
|
||||
|
||||
Reference in New Issue
Block a user