Skip to content

Commit 8266938

Browse files
committed
Merge pull request #6224 from filecoin-project/chore/update-go-version
chore: ci: update go versin to v1.20
1 parent c1e31ca commit 8266938

File tree

13 files changed

+43
-27
lines changed

13 files changed

+43
-27
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ commands:
7272
executors:
7373
golang:
7474
docker:
75-
- image: cimg/go:1.19.10
75+
- image: cimg/go:1.20.11
7676

7777
jobs:
7878
test_all:

.github/workflows/baisc_checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Go
1919
uses: actions/setup-go@v4
2020
with:
21-
go-version: 1.19
21+
go-version: '1.20'
2222
cache: true
2323

2424
- name: install deps
@@ -35,7 +35,7 @@ jobs:
3535
3636
- name: Lint
3737
run: |
38-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
38+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.0
3939
golangci-lint run --timeout 10m
4040
4141
- name: Compatible all

.github/workflows/common_build_upload.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
- name: Set up Go
109109
uses: actions/setup-go@v4
110110
with:
111-
go-version: 1.19
111+
go-version: '1.20'
112112
cache: true
113113

114114
- name: install deps
@@ -247,7 +247,7 @@ jobs:
247247
- name: Set up Go
248248
uses: actions/setup-go@v4
249249
with:
250-
go-version: 1.19
250+
go-version: '1.20'
251251
cache: true
252252

253253
- name: install more deps

.github/workflows/common_go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Go
2323
uses: actions/setup-go@v4
2424
with:
25-
go-version: 1.19
25+
go-version: '1.20'
2626
cache: true
2727

2828
- name: vars
@@ -51,7 +51,7 @@ jobs:
5151
5252
- name: Lint
5353
run: |
54-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
54+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.0
5555
golangci-lint run --timeout 10m
5656
5757
- name: Detect changes

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Set up Go
2222
uses: actions/setup-go@v4
2323
with:
24-
go-version: 1.19
24+
go-version: '1.20'
2525
cache: true
2626

2727
- name: install deps

pkg/messagepool/block_proba_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ func TestBlockProbability(t *testing.T) {
2626
func TestWinnerProba(t *testing.T) {
2727
tf.UnitTest(t)
2828

29-
rand.Seed(time.Now().UnixNano())
29+
r := rand.New(rand.NewSource(time.Now().UnixNano()))
3030
const N = 1000000
3131
winnerProba := noWinnersProb()
3232
sum := 0
3333
for i := 0; i < N; i++ {
34-
minersRand := rand.Float64()
34+
minersRand := r.Float64()
3535
j := 0
3636
for ; j < MaxBlocks; j++ {
3737
minersRand -= winnerProba[j]

pkg/repo/fskeystore/fskeystore_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package fskeystore
22

33
import (
44
"bytes"
5+
"crypto/rand"
56
"fmt"
6-
"math/rand"
77
"os"
88
"path/filepath"
99
"sort"

pkg/shardedmutex/shardedmutex_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import (
88
"sync/atomic"
99
"testing"
1010
"time"
11+
12+
"github.com/filecoin-project/venus/pkg/testhelpers/testflags"
1113
)
1214

1315
func TestLockingDifferentShardsDoesNotBlock(t *testing.T) {
16+
testflags.UnitTest(t)
1417
shards := 16
1518
sm := New(shards)
1619
done := make(chan struct{})
@@ -29,6 +32,7 @@ func TestLockingDifferentShardsDoesNotBlock(t *testing.T) {
2932
close(done)
3033
}
3134
func TestLockingSameShardsBlocks(t *testing.T) {
35+
testflags.UnitTest(t)
3236
shards := 16
3337
sm := New(shards)
3438
wg := sync.WaitGroup{}
@@ -60,6 +64,7 @@ func TestLockingSameShardsBlocks(t *testing.T) {
6064
}
6165

6266
func TestShardedByString(t *testing.T) {
67+
testflags.UnitTest(t)
6368
shards := 16
6469
sm := NewFor(maphash.String, shards)
6570

pkg/util/fr32/fr32_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package fr32_test
22

33
import (
44
"bytes"
5+
"crypto/rand"
56
"io"
6-
"math/rand"
77
"os"
88
"testing"
99

@@ -74,7 +74,8 @@ func TestPadChunkRandEqFFI(t *testing.T) {
7474
tf.UnitTest(t)
7575
for i := 0; i < 200; i++ {
7676
var input [127]byte
77-
rand.Read(input[:])
77+
_, err := rand.Read(input[:])
78+
require.NoError(t, err)
7879

7980
var buf [128]byte
8081

@@ -113,7 +114,8 @@ func TestRoundtripChunkRand(t *testing.T) {
113114
tf.UnitTest(t)
114115
for i := 0; i < 200; i++ {
115116
var input [127]byte
116-
rand.Read(input[:])
117+
_, err := rand.Read(input[:])
118+
require.NoError(t, err)
117119

118120
var buf [128]byte
119121
copy(buf[:], input[:])
@@ -132,7 +134,8 @@ func TestRoundtrip16MRand(t *testing.T) {
132134
up := abi.PaddedPieceSize(16 << 20).Unpadded()
133135

134136
input := make([]byte, up)
135-
rand.Read(input[:])
137+
_, err := rand.Read(input[:])
138+
require.NoError(t, err)
136139

137140
buf := make([]byte, 16<<20)
138141

pkg/util/merge_peer_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package util
33
import (
44
"testing"
55

6+
"github.com/filecoin-project/venus/pkg/testhelpers/testflags"
67
"github.com/stretchr/testify/assert"
78
)
89

910
func TestMergePeers(t *testing.T) {
11+
testflags.UnitTest(t)
1012
t1 := MergePeers([]string{}, []string{"a"})
1113
assert.Equal(t, []string{"a"}, t1)
1214

tools/gengen/util/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (g *GenesisGenerator) Init(cfg *GenesisCfg) error {
119119
}
120120
keys = append(keys, cfg.ImportKeys...)
121121
g.keys = keys
122-
vrKey, err := key.NewSecpKeyFromSeed(g.pnrg)
122+
vrKey, err := key.NewBLSKeyFromSeed(g.pnrg)
123123
if err != nil {
124124
return err
125125
}

venus-shared/testutil/value_provider_primitive.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import (
44
"encoding/hex"
55
"math/rand"
66
"testing"
7+
"time"
8+
9+
"github.com/stretchr/testify/require"
710
)
811

912
func init() {
@@ -17,7 +20,7 @@ const (
1720
defaultBytesFixedSize = 16
1821
)
1922

20-
func IntProvider(t *testing.T) int { return rand.Int() }
23+
func IntProvider(t *testing.T) int { return r.Int() }
2124

2225
func IntRangedProvider(min, max int) func(*testing.T) int {
2326
return func(t *testing.T) int {
@@ -26,22 +29,32 @@ func IntRangedProvider(min, max int) func(*testing.T) int {
2629
t.Fatalf("invalid range [%d, %d)", min, max)
2730
}
2831

29-
return min + rand.Intn(gap)
32+
return min + r.Intn(gap)
3033
}
3134
}
3235

36+
var r = rand.New(rand.NewSource(time.Now().UnixNano()))
37+
38+
func getRand() *rand.Rand {
39+
seed := time.Now().UnixNano()
40+
r = rand.New(rand.NewSource(seed))
41+
return rand.New(rand.NewSource(seed))
42+
}
43+
3344
func BytesFixedProvider(size int) func(*testing.T) []byte {
3445
return func(t *testing.T) []byte {
3546
b := make([]byte, size)
36-
rand.Read(b[:])
47+
_, err := r.Read(b[:])
48+
require.NoError(t, err)
3749
return b
3850
}
3951
}
4052

4153
func BytesAtMostProvider(size int) func(*testing.T) []byte {
4254
return func(t *testing.T) []byte {
4355
b := make([]byte, rand.Intn(size))
44-
rand.Read(b[:])
56+
_, err := r.Read(b[:])
57+
require.NoError(t, err)
4558
return b
4659
}
4760
}

venus-shared/testutil/value_provider_primitive_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package testutil
22

33
import (
44
"encoding/hex"
5-
"math/rand"
65
"reflect"
76
"testing"
87
"time"
@@ -11,12 +10,6 @@ import (
1110
"github.com/stretchr/testify/require"
1211
)
1312

14-
func getRand() *rand.Rand {
15-
seed := time.Now().UnixNano()
16-
rand.Seed(seed)
17-
return rand.New(rand.NewSource(seed))
18-
}
19-
2013
func TestDefaultBytes(t *testing.T) {
2114
tf.UnitTest(t)
2215

0 commit comments

Comments
 (0)