From cb48b90e8b8010a8440f2855b63efe4ce9193bd3 Mon Sep 17 00:00:00 2001 From: John Osumi <931193+sumitake@users.noreply.github.com> Date: Sun, 30 Aug 2026 21:57:24 -0700 Subject: [PATCH] test: allocate capacity slot IDs atomically go test -race on internal/state failed on a sibling branch because nextCapacitySlotID mutated a package-level uint32 from parallel tests. Use atomic.Uint32 so main cannot flake the same way. --- internal/state/sqlite_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/state/sqlite_test.go b/internal/state/sqlite_test.go index 5585690..83fec19 100644 --- a/internal/state/sqlite_test.go +++ b/internal/state/sqlite_test.go @@ -11,6 +11,7 @@ import ( "reflect" "strings" "sync" + "sync/atomic" "testing" "time" @@ -74,12 +75,11 @@ func recordTestOffer( return receipt.Key } -var slotCounter uint32 +var slotCounter atomic.Uint32 func nextCapacitySlotID(t *testing.T) uint32 { t.Helper() - slotCounter++ - return slotCounter + return slotCounter.Add(1) } // checkpointStep is one entry of the happy-path walk used by advanceTo.