Skip to content

Commit

Permalink
Replace 32 with sha256.Size const (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
roger2hk authored Dec 5, 2024
1 parent b637d9f commit b3345f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion api/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package api_test
import (
"bytes"
"crypto/rand"
"crypto/sha256"
"fmt"
"testing"

Expand All @@ -44,7 +45,7 @@ func TestHashTile_MarshalTileRoundtrip(t *testing.T) {
tile := api.HashTile{Nodes: make([][]byte, 0, test.size)}
for i := 0; i < test.size; i++ {
// Fill in the leaf index
tile.Nodes = append(tile.Nodes, make([]byte, 32))
tile.Nodes = append(tile.Nodes, make([]byte, sha256.Size))
if _, err := rand.Read(tile.Nodes[i]); err != nil {
t.Error(err)
}
Expand Down
3 changes: 2 additions & 1 deletion dedupe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package tessera_test

import (
"context"
"crypto/sha256"
"fmt"
"sync"
"testing"
Expand Down Expand Up @@ -92,7 +93,7 @@ func BenchmarkDedupe(b *testing.B) {
for leafIndex := range 1024 {
wg.Add(1)
go func(index int) {
_, err := dedupeAdd(ctx, tessera.NewEntry([]byte(fmt.Sprintf("leaf with value %d", index%32))))()
_, err := dedupeAdd(ctx, tessera.NewEntry([]byte(fmt.Sprintf("leaf with value %d", index%sha256.Size))))()
if err != nil {
b.Error(err)
}
Expand Down

0 comments on commit b3345f0

Please sign in to comment.