Skip to content

Commit fe7f852

Browse files
committed
nits
Signed-off-by: Sam Batschelet <[email protected]>
1 parent 3002fd4 commit fe7f852

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

tstate/tstate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
type op struct {
18-
k []byte
18+
k string
1919

2020
pastExists bool
2121
pastV []byte
@@ -139,7 +139,7 @@ func (ts *TState) Insert(ctx context.Context, key []byte, value []byte) error {
139139
}
140140
past, changed, exists := ts.getValue(ctx, key)
141141
ts.ops = append(ts.ops, &op{
142-
k: key,
142+
k: string(key),
143143
pastExists: exists,
144144
pastV: past,
145145
pastChanged: changed,
@@ -158,7 +158,7 @@ func (ts *TState) Remove(ctx context.Context, key []byte) error {
158158
return nil
159159
}
160160
ts.ops = append(ts.ops, &op{
161-
k: key,
161+
k: string(key),
162162
pastExists: true,
163163
pastV: past,
164164
pastChanged: changed,

tstate/tstate_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ func benchmarkFetchAndSetScope(b *testing.B, size int) {
356356
db := NewTestDB()
357357
ctx := context.TODO()
358358

359-
keys, vals := initializeSet(size)
359+
keys, vals := initializeSet(require, size)
360360
for i, key := range keys {
361361
err := db.Insert(ctx, key, vals[i])
362362
require.NoError(err, "Error during insert.")
@@ -376,7 +376,7 @@ func benchmarkInsert(b *testing.B, size int) {
376376
ts := New(size)
377377
ctx := context.TODO()
378378

379-
keys, vals := initializeSet(size)
379+
keys, vals := initializeSet(require, size)
380380

381381
storage := map[string][]byte{}
382382
for i, key := range keys {
@@ -401,7 +401,7 @@ func benchmarkGetValue(b *testing.B, size int) {
401401
ts := New(size)
402402
ctx := context.TODO()
403403

404-
keys, vals := initializeSet(size)
404+
keys, vals := initializeSet(require, size)
405405

406406
storage := map[string][]byte{}
407407
for i, key := range keys {
@@ -421,20 +421,21 @@ func benchmarkGetValue(b *testing.B, size int) {
421421
b.StopTimer()
422422
}
423423

424-
func initializeSet(size int) ([][]byte, [][]byte) {
424+
func initializeSet(r *require.Assertions, size int) ([][]byte, [][]byte) {
425425
keys := [][]byte{}
426426
vals := [][]byte{}
427427

428428
for i := 0; i <= size; i++ {
429-
keys = append(keys, randomBytes(33))
430-
vals = append(vals, randomBytes(8))
429+
keys = append(keys, randomBytes(r, 65))
430+
vals = append(vals, randomBytes(r, 8))
431431
}
432432

433433
return keys, vals
434434
}
435435

436-
func randomBytes(size int) []byte {
436+
func randomBytes(r *require.Assertions, size int) []byte {
437437
bytes := make([]byte, size)
438-
rand.Read(bytes)
438+
_, err := rand.Read(bytes)
439+
r.NoError(err)
439440
return bytes
440441
}

0 commit comments

Comments
 (0)