Skip to content

Commit 2e9baeb

Browse files
CopilotFiloSottile
andcommitted
Use atomic.Uint64 for test upload counter
Co-authored-by: FiloSottile <1225294+FiloSottile@users.noreply.github.com>
1 parent 207359b commit 2e9baeb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

internal/ctlog/ctlog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func TestSequenceUploadCount(t *testing.T) {
125125

126126
var old uint64
127127
uploads := func() uint64 {
128-
new := tl.Config.Backend.(*MemoryBackend).uploads
128+
new := tl.Config.Backend.(*MemoryBackend).uploads.Load()
129129
n := new - old
130130
old = new
131131
return n

internal/ctlog/testlog_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ type MemoryBackend struct {
440440
imm map[string]bool
441441
del map[string]bool
442442

443-
uploads uint64
443+
uploads atomic.Uint64
444444

445445
UploadCallback func(key string, data []byte) (apply bool, err error)
446446
}
@@ -452,7 +452,7 @@ func NewMemoryBackend(t testing.TB) *MemoryBackend {
452452
}
453453

454454
func (b *MemoryBackend) Upload(ctx context.Context, key string, data []byte, opts *ctlog.UploadOptions) error {
455-
atomic.AddUint64(&b.uploads, 1)
455+
b.uploads.Add(1)
456456
// TODO: check key format is expected.
457457
if len(data) == 0 && key != "_roots.pem" {
458458
b.t.Errorf("uploaded key %q with empty data", key)

0 commit comments

Comments
 (0)