diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index bb4edb4..4bd20fb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,10 +12,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Set up Go 1.x + - name: Set up Go 1.21 uses: actions/setup-go@v2 with: - go-version: ^1.19 + go-version: 1.21 id: go - name: Check out code into the Go module directory diff --git a/README.md b/README.md index 20e937d..8cda7a9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Namespaced Merkle Tree (NMT) -![Go version](https://img.shields.io/badge/go-1.19-blue.svg) +![Go version](https://img.shields.io/badge/go-1.21-blue.svg) [![API Reference](https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667)](https://pkg.go.dev/github.com/celestiaorg/nmt) ![golangci-lint](https://github.com/celestiaorg/nmt/workflows/golangci-lint/badge.svg?branch=master) ![Go](https://github.com/celestiaorg/nmt/workflows/Go/badge.svg) diff --git a/go.mod b/go.mod index b3b469b..6f42d7e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/celestiaorg/nmt -go 1.19 +go 1.21 require ( github.com/gogo/protobuf v1.3.2 diff --git a/nmt_test.go b/nmt_test.go index c4907b5..61da458 100644 --- a/nmt_test.go +++ b/nmt_test.go @@ -3,12 +3,12 @@ package nmt import ( "bytes" "crypto" + "crypto/rand" "crypto/sha256" "encoding/binary" "errors" "fmt" "math" - "math/rand" "reflect" "sort" "sync" @@ -534,7 +534,8 @@ func TestNodeVisitor(t *testing.T) { nodeHashes = append(nodeHashes, hash) } - data := generateRandNamespacedRawData(numLeaves, nidSize, leafSize) + data, err := generateRandNamespacedRawData(numLeaves, nidSize, leafSize) + require.NoError(t, err) n := New(sha256.New(), NamespaceIDSize(nidSize), NodeVisitor(collectNodeHashes)) for j := 0; j < numLeaves; j++ { if err := n.Push(data[j]); err != nil { @@ -706,7 +707,8 @@ func BenchmarkComputeRoot(b *testing.B) { } for _, tt := range tests { - data := generateRandNamespacedRawData(tt.numLeaves, tt.nidSize, tt.dataSize) + data, err := generateRandNamespacedRawData(tt.numLeaves, tt.nidSize, tt.dataSize) + require.NoError(b, err) b.ResetTimer() b.Run(tt.name, func(b *testing.B) { for i := 0; i < b.N; i++ { @@ -786,21 +788,27 @@ func repeat(data []namespaceDataPair, num int) []namespaceDataPair { return res } -func generateRandNamespacedRawData(total int, nidSize int, leafSize int) [][]byte { +func generateRandNamespacedRawData(total int, nidSize int, leafSize int) ([][]byte, error) { data := make([][]byte, total) for i := 0; i < total; i++ { nid := make([]byte, nidSize) - rand.Read(nid) + _, err := rand.Read(nid) + if err != nil { + return nil, err + } data[i] = nid } sortByteArrays(data) for i := 0; i < total; i++ { d := make([]byte, leafSize) - rand.Read(d) + _, err := rand.Read(d) + if err != nil { + return nil, err + } data[i] = append(data[i], d...) } - return data + return data, nil } func sortByteArrays(src [][]byte) {