Skip to content

Commit

Permalink
Merge pull request #6224 from filecoin-project/chore/update-go-version
Browse files Browse the repository at this point in the history
chore: ci: update go versin to v1.20
  • Loading branch information
simlecode authored Nov 20, 2023
2 parents 3948271 + 284c410 commit d5c77d8
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ commands:
executors:
golang:
docker:
- image: cimg/go:1.19.10
- image: cimg/go:1.20.11

jobs:
test_all:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/baisc_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: '1.20'
cache: true

- name: install deps
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.0
golangci-lint run --timeout 10m
- name: Compatible all
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/common_build_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: '1.20'
cache: true

- name: install deps
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: '1.20'
cache: true

- name: install more deps
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/common_go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: '1.20'
cache: true

- name: vars
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.0
golangci-lint run --timeout 10m
- name: Detect changes
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: '1.20'
cache: true

- name: install deps
Expand Down
4 changes: 2 additions & 2 deletions pkg/messagepool/block_proba_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func TestBlockProbability(t *testing.T) {
func TestWinnerProba(t *testing.T) {
tf.UnitTest(t)

rand.Seed(time.Now().UnixNano())
r := rand.New(rand.NewSource(time.Now().UnixNano()))
const N = 1000000
winnerProba := noWinnersProb()
sum := 0
for i := 0; i < N; i++ {
minersRand := rand.Float64()
minersRand := r.Float64()
j := 0
for ; j < MaxBlocks; j++ {
minersRand -= winnerProba[j]
Expand Down
2 changes: 1 addition & 1 deletion pkg/repo/fskeystore/fskeystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package fskeystore

import (
"bytes"
"crypto/rand"
"fmt"
"math/rand"
"os"
"path/filepath"
"sort"
Expand Down
5 changes: 5 additions & 0 deletions pkg/shardedmutex/shardedmutex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
"sync/atomic"
"testing"
"time"

"github.com/filecoin-project/venus/pkg/testhelpers/testflags"
)

func TestLockingDifferentShardsDoesNotBlock(t *testing.T) {
testflags.UnitTest(t)
shards := 16
sm := New(shards)
done := make(chan struct{})
Expand All @@ -29,6 +32,7 @@ func TestLockingDifferentShardsDoesNotBlock(t *testing.T) {
close(done)
}
func TestLockingSameShardsBlocks(t *testing.T) {
testflags.UnitTest(t)
shards := 16
sm := New(shards)
wg := sync.WaitGroup{}
Expand Down Expand Up @@ -60,6 +64,7 @@ func TestLockingSameShardsBlocks(t *testing.T) {
}

func TestShardedByString(t *testing.T) {
testflags.UnitTest(t)
shards := 16
sm := NewFor(maphash.String, shards)

Expand Down
11 changes: 7 additions & 4 deletions pkg/util/fr32/fr32_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package fr32_test

import (
"bytes"
"crypto/rand"
"io"
"math/rand"
"os"
"testing"

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

var buf [128]byte

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

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

input := make([]byte, up)
rand.Read(input[:])
_, err := rand.Read(input[:])
require.NoError(t, err)

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

Expand Down
2 changes: 2 additions & 0 deletions pkg/util/merge_peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package util
import (
"testing"

"github.com/filecoin-project/venus/pkg/testhelpers/testflags"
"github.com/stretchr/testify/assert"
)

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

Expand Down
2 changes: 1 addition & 1 deletion tools/gengen/util/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (g *GenesisGenerator) Init(cfg *GenesisCfg) error {
}
keys = append(keys, cfg.ImportKeys...)
g.keys = keys
vrKey, err := key.NewSecpKeyFromSeed(g.pnrg)
vrKey, err := key.NewBLSKeyFromSeed(g.pnrg)
if err != nil {
return err
}
Expand Down
21 changes: 17 additions & 4 deletions venus-shared/testutil/value_provider_primitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"encoding/hex"
"math/rand"
"testing"
"time"

"github.com/stretchr/testify/require"
)

func init() {
Expand All @@ -17,7 +20,7 @@ const (
defaultBytesFixedSize = 16
)

func IntProvider(t *testing.T) int { return rand.Int() }
func IntProvider(t *testing.T) int { return r.Int() }

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

return min + rand.Intn(gap)
return min + r.Intn(gap)
}
}

var r = rand.New(rand.NewSource(time.Now().UnixNano()))

func getRand() *rand.Rand {
seed := time.Now().UnixNano()
r = rand.New(rand.NewSource(seed))
return rand.New(rand.NewSource(seed))
}

func BytesFixedProvider(size int) func(*testing.T) []byte {
return func(t *testing.T) []byte {
b := make([]byte, size)
rand.Read(b[:])
_, err := r.Read(b[:])
require.NoError(t, err)
return b
}
}

func BytesAtMostProvider(size int) func(*testing.T) []byte {
return func(t *testing.T) []byte {
b := make([]byte, rand.Intn(size))
rand.Read(b[:])
_, err := r.Read(b[:])
require.NoError(t, err)
return b
}
}
Expand Down
7 changes: 0 additions & 7 deletions venus-shared/testutil/value_provider_primitive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package testutil

import (
"encoding/hex"
"math/rand"
"reflect"
"testing"
"time"
Expand All @@ -11,12 +10,6 @@ import (
"github.com/stretchr/testify/require"
)

func getRand() *rand.Rand {
seed := time.Now().UnixNano()
rand.Seed(seed)
return rand.New(rand.NewSource(seed))
}

func TestDefaultBytes(t *testing.T) {
tf.UnitTest(t)

Expand Down

0 comments on commit d5c77d8

Please sign in to comment.