Skip to content

Commit 31f4525

Browse files
authored
chore: bump to Go 1.21 (#230)
1 parent 3311036 commit 31f4525

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

.github/workflows/go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414

15-
- name: Set up Go 1.x
15+
- name: Set up Go 1.21
1616
uses: actions/setup-go@v2
1717
with:
18-
go-version: ^1.19
18+
go-version: 1.21
1919
id: go
2020

2121
- name: Check out code into the Go module directory

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Namespaced Merkle Tree (NMT)
22

3-
![Go version](https://img.shields.io/badge/go-1.19-blue.svg)
3+
![Go version](https://img.shields.io/badge/go-1.21-blue.svg)
44
[![API Reference](https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667)](https://pkg.go.dev/github.com/celestiaorg/nmt)
55
![golangci-lint](https://github.com/celestiaorg/nmt/workflows/golangci-lint/badge.svg?branch=master)
66
![Go](https://github.com/celestiaorg/nmt/workflows/Go/badge.svg)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/celestiaorg/nmt
22

3-
go 1.19
3+
go 1.21
44

55
require (
66
github.com/gogo/protobuf v1.3.2

nmt_test.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package nmt
33
import (
44
"bytes"
55
"crypto"
6+
"crypto/rand"
67
"crypto/sha256"
78
"encoding/binary"
89
"errors"
910
"fmt"
1011
"math"
11-
"math/rand"
1212
"reflect"
1313
"sort"
1414
"sync"
@@ -534,7 +534,8 @@ func TestNodeVisitor(t *testing.T) {
534534
nodeHashes = append(nodeHashes, hash)
535535
}
536536

537-
data := generateRandNamespacedRawData(numLeaves, nidSize, leafSize)
537+
data, err := generateRandNamespacedRawData(numLeaves, nidSize, leafSize)
538+
require.NoError(t, err)
538539
n := New(sha256.New(), NamespaceIDSize(nidSize), NodeVisitor(collectNodeHashes))
539540
for j := 0; j < numLeaves; j++ {
540541
if err := n.Push(data[j]); err != nil {
@@ -706,7 +707,8 @@ func BenchmarkComputeRoot(b *testing.B) {
706707
}
707708

708709
for _, tt := range tests {
709-
data := generateRandNamespacedRawData(tt.numLeaves, tt.nidSize, tt.dataSize)
710+
data, err := generateRandNamespacedRawData(tt.numLeaves, tt.nidSize, tt.dataSize)
711+
require.NoError(b, err)
710712
b.ResetTimer()
711713
b.Run(tt.name, func(b *testing.B) {
712714
for i := 0; i < b.N; i++ {
@@ -786,21 +788,27 @@ func repeat(data []namespaceDataPair, num int) []namespaceDataPair {
786788
return res
787789
}
788790

789-
func generateRandNamespacedRawData(total int, nidSize int, leafSize int) [][]byte {
791+
func generateRandNamespacedRawData(total int, nidSize int, leafSize int) ([][]byte, error) {
790792
data := make([][]byte, total)
791793
for i := 0; i < total; i++ {
792794
nid := make([]byte, nidSize)
793-
rand.Read(nid)
795+
_, err := rand.Read(nid)
796+
if err != nil {
797+
return nil, err
798+
}
794799
data[i] = nid
795800
}
796801
sortByteArrays(data)
797802
for i := 0; i < total; i++ {
798803
d := make([]byte, leafSize)
799-
rand.Read(d)
804+
_, err := rand.Read(d)
805+
if err != nil {
806+
return nil, err
807+
}
800808
data[i] = append(data[i], d...)
801809
}
802810

803-
return data
811+
return data, nil
804812
}
805813

806814
func sortByteArrays(src [][]byte) {

0 commit comments

Comments
 (0)