fix(multiplayer): complete live results atomically

This commit is contained in:
Josh Creek
2026-09-03 13:29:31 +01:00
parent 8c28374eb4
commit 2e9da3032c
6 changed files with 112 additions and 8 deletions
+3
View File
@@ -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
}
+11
View File
@@ -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()