From cb55e6b3897d239561bf55bd4c28eba89c555799 Mon Sep 17 00:00:00 2001 From: tony Date: Mon, 23 Sep 2024 16:47:38 +0800 Subject: [PATCH] use math/rand/v2 package --- .golangci.yml | 6 ------ api/accounts/accounts_test.go | 4 ++-- api/blocks/blocks_test.go | 2 +- api/debug/debug_test.go | 2 +- api/events/events_test.go | 2 +- api/metrics_test.go | 2 +- api/node/node_test.go | 2 +- api/transactions/transactions_test.go | 4 ++-- api/transfers/transfers_test.go | 2 +- block/header_test.go | 12 ++++++------ cache/prio_cache_test.go | 10 ++++------ cache/rnd_cache.go | 11 +++-------- cmd/thor/node/tx_stash_test.go | 4 ++-- cmd/thor/solo/solo.go | 2 +- comm/peer.go | 8 ++------ log/format_test.go | 6 +++--- metrics/noop_test.go | 8 ++++---- metrics/prometheus_test.go | 10 +++++----- p2psrv/rpc/rpc.go | 7 +------ runtime/statedb/statedb_test.go | 2 +- state/cached_object_test.go | 4 ++-- thor/hash_test.go | 5 +++-- trie/iterator_test.go | 4 ++-- trie/proof_test.go | 13 ++++--------- trie/trie_test.go | 2 +- tx/block_ref_test.go | 4 ++-- tx/reserved_test.go | 2 +- txpool/blocklist_test.go | 2 +- txpool/tx_object_test.go | 6 +++--- txpool/tx_pool.go | 2 +- 30 files changed, 62 insertions(+), 88 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ac2943c5b..3c06f4810 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -24,7 +24,6 @@ linters: - durationcheck - copyloopvar - whitespace - - gosec - revive # - structcheck # lots of false positives @@ -39,11 +38,6 @@ linters: linters-settings: gofmt: simplify: true - gosec: - excludes: - - G115 - - G406 # ignore ripe160 deprecation - - G507 # ignore ripe160 deprecation revive: rules: - name: var-naming diff --git a/api/accounts/accounts_test.go b/api/accounts/accounts_test.go index 16f08e252..a2966c2cf 100644 --- a/api/accounts/accounts_test.go +++ b/api/accounts/accounts_test.go @@ -543,7 +543,7 @@ func httpPost(t *testing.T, url string, body interface{}) ([]byte, int) { if err != nil { t.Fatal(err) } - res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) // nolint:gosec + res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) if err != nil { t.Fatal(err) } @@ -556,7 +556,7 @@ func httpPost(t *testing.T, url string, body interface{}) ([]byte, int) { } func httpGet(t *testing.T, url string) ([]byte, int) { - res, err := http.Get(url) // nolint:gosec + res, err := http.Get(url) if err != nil { t.Fatal(err) } diff --git a/api/blocks/blocks_test.go b/api/blocks/blocks_test.go index 0ad5350b5..e04196a53 100644 --- a/api/blocks/blocks_test.go +++ b/api/blocks/blocks_test.go @@ -253,7 +253,7 @@ func checkExpandedBlock(t *testing.T, expBl *block.Block, actBl *blocks.JSONExpa } func httpGet(t *testing.T, url string) ([]byte, int) { - res, err := http.Get(url) // nolint:gosec + res, err := http.Get(url) if err != nil { t.Fatal(err) } diff --git a/api/debug/debug_test.go b/api/debug/debug_test.go index 3c61dfcab..17ceb57c2 100644 --- a/api/debug/debug_test.go +++ b/api/debug/debug_test.go @@ -597,7 +597,7 @@ func httpPostAndCheckResponseStatus(t *testing.T, url string, obj interface{}, r if err != nil { t.Fatal(err) } - res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) // nolint:gosec + res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) if err != nil { t.Fatal(err) } diff --git a/api/events/events_test.go b/api/events/events_test.go index c8494019f..5126a18cc 100644 --- a/api/events/events_test.go +++ b/api/events/events_test.go @@ -206,7 +206,7 @@ func httpPost(t *testing.T, url string, body interface{}) ([]byte, int) { if err != nil { t.Fatal(err) } - res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) // nolint:gosec + res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) if err != nil { t.Fatal(err) } diff --git a/api/metrics_test.go b/api/metrics_test.go index 703f626c6..c1c918291 100644 --- a/api/metrics_test.go +++ b/api/metrics_test.go @@ -181,7 +181,7 @@ func TestWebsocketMetrics(t *testing.T) { } func httpGet(t *testing.T, url string) ([]byte, int) { - res, err := http.Get(url) // nolint:gosec + res, err := http.Get(url) if err != nil { t.Fatal(err) } diff --git a/api/node/node_test.go b/api/node/node_test.go index 90857d0d0..7952415a3 100644 --- a/api/node/node_test.go +++ b/api/node/node_test.go @@ -56,7 +56,7 @@ func initCommServer(t *testing.T) { } func httpGet(t *testing.T, url string) []byte { - res, err := http.Get(url) // nolint:gosec + res, err := http.Get(url) if err != nil { t.Fatal(err) } diff --git a/api/transactions/transactions_test.go b/api/transactions/transactions_test.go index 2d86d13e3..6443921ee 100644 --- a/api/transactions/transactions_test.go +++ b/api/transactions/transactions_test.go @@ -265,7 +265,7 @@ func httpPostAndCheckResponseStatus(t *testing.T, url string, obj interface{}, r if err != nil { t.Fatal(err) } - res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) // nolint: gosec + res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) if err != nil { t.Fatal(err) } @@ -371,7 +371,7 @@ func checkMatchingTx(t *testing.T, expectedTx *tx.Transaction, actualTx *transac } func httpGetAndCheckResponseStatus(t *testing.T, url string, responseStatusCode int) []byte { - res, err := http.Get(url) // nolint:gosec + res, err := http.Get(url) if err != nil { t.Fatal(err) } diff --git a/api/transfers/transfers_test.go b/api/transfers/transfers_test.go index 0c7814993..0061d7114 100644 --- a/api/transfers/transfers_test.go +++ b/api/transfers/transfers_test.go @@ -214,7 +214,7 @@ func httpPost(t *testing.T, url string, body interface{}) ([]byte, int) { if err != nil { t.Fatal(err) } - res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) // nolint: gosec + res, err := http.Post(url, "application/x-www-form-urlencoded", bytes.NewReader(data)) if err != nil { t.Fatal(err) } diff --git a/block/header_test.go b/block/header_test.go index 141dfe804..1e1aa5a68 100644 --- a/block/header_test.go +++ b/block/header_test.go @@ -6,7 +6,7 @@ package block import ( - "math/rand" + "crypto/rand" "sync/atomic" "testing" @@ -86,8 +86,8 @@ func TestHeaderEncoding(t *testing.T) { var proof [81]byte var alpha [32]byte - rand.Read(proof[:]) // nolint - rand.Read(alpha[:]) // nolint + rand.Read(proof[:]) + rand.Read(alpha[:]) cplx, err := NewComplexSignature(sig[:], proof[:]) if err != nil { @@ -110,7 +110,7 @@ func TestHeaderEncoding(t *testing.T) { // type extension struct{Alpha []byte} func TestEncodingBadExtension(t *testing.T) { var sig [65]byte - rand.Read(sig[:]) // nolint + rand.Read(sig[:]) block := new(Builder).Build().WithSignature(sig[:]) h := block.Header() @@ -157,8 +157,8 @@ func TestEncodingBadExtension(t *testing.T) { func TestEncodingExtension(t *testing.T) { var sig [ComplexSigSize]byte var alpha [32]byte - rand.Read(sig[:]) // nolint - rand.Read(alpha[:]) // nolint + rand.Read(sig[:]) + rand.Read(alpha[:]) block := new(Builder).Alpha(alpha[:]).Build().WithSignature(sig[:]) h := block.Header() diff --git a/cache/prio_cache_test.go b/cache/prio_cache_test.go index 0c7489b06..8dffdd367 100644 --- a/cache/prio_cache_test.go +++ b/cache/prio_cache_test.go @@ -6,10 +6,9 @@ package cache_test import ( - "math/rand" + "math/rand/v2" "sort" "testing" - "time" "github.com/stretchr/testify/assert" "github.com/vechain/thor/v2/cache" @@ -35,7 +34,6 @@ func TestPrioCacheAddRemove(t *testing.T) { func TestPrioCache(t *testing.T) { c := cache.NewPrioCache(5) - rand.Seed(time.Now().UnixNano()) // nolint:staticcheck type kvp struct { k, v int @@ -46,9 +44,9 @@ func TestPrioCache(t *testing.T) { for i := 0; i < 100; i++ { e := kvp{ - rand.Int(), // nolint: gosec - rand.Int(), // nolint:gosec - rand.Float64()} // nolint:gosec + rand.Int(), // #nosec + rand.Int(), // #nosec + rand.Float64()} // #nosec kvps = append(kvps, e) c.Set(e.k, e.v, e.p) } diff --git a/cache/rnd_cache.go b/cache/rnd_cache.go index 66e939ae4..581840f2c 100644 --- a/cache/rnd_cache.go +++ b/cache/rnd_cache.go @@ -6,15 +6,10 @@ package cache import ( - "math/rand" + "math/rand/v2" "sync" - "time" ) -func init() { - rand.Seed(time.Now().UnixNano()) // nolint:staticcheck -} - // RandCache a simple cache which randomly evicts entries when // length exceeds limit. type RandCache struct { @@ -106,7 +101,7 @@ func (rc *RandCache) Pick() *Entry { if len(rc.s) == 0 { return nil } - ent := rc.s[rand.Intn(len(rc.s))] // #nosec + ent := rc.s[rand.N(len(rc.s))] // #nosec cpy := ent.Entry return &cpy } @@ -141,6 +136,6 @@ func (rc *RandCache) randDrop() { if len(rc.s) == 0 { return } - ent := rc.s[rand.Intn(len(rc.s))] // #nosec + ent := rc.s[rand.N(len(rc.s))] // #nosec rc.remove(ent.Key) } diff --git a/cmd/thor/node/tx_stash_test.go b/cmd/thor/node/tx_stash_test.go index a573b682a..fca9d5060 100644 --- a/cmd/thor/node/tx_stash_test.go +++ b/cmd/thor/node/tx_stash_test.go @@ -7,7 +7,7 @@ package node import ( "bytes" - "math/rand" + "math/rand/v2" "sort" "testing" @@ -20,7 +20,7 @@ import ( ) func newTx() *tx.Transaction { - tx := new(tx.Builder).Nonce(rand.Uint64()).Build() // nolint:gosec + tx := new(tx.Builder).Nonce(rand.Uint64()).Build() // #nosec sig, _ := crypto.Sign(tx.SigningHash().Bytes(), genesis.DevAccounts()[0].PrivateKey) return tx.WithSignature(sig) } diff --git a/cmd/thor/solo/solo.go b/cmd/thor/solo/solo.go index af498ca04..8fb3e70c1 100644 --- a/cmd/thor/solo/solo.go +++ b/cmd/thor/solo/solo.go @@ -9,7 +9,7 @@ import ( "context" "fmt" "math/big" - "math/rand" + "math/rand/v2" "time" "github.com/ethereum/go-ethereum/common" diff --git a/comm/peer.go b/comm/peer.go index 8dab9bd5c..0cb21fe46 100644 --- a/comm/peer.go +++ b/comm/peer.go @@ -6,7 +6,7 @@ package comm import ( - "math/rand" + "math/rand/v2" "sync" "time" @@ -24,10 +24,6 @@ const ( maxKnownBlocks = 1024 // Maximum block IDs to keep in the known list (prevent DOS) ) -func init() { - rand.Seed(time.Now().UnixNano()) // nolint:staticcheck -} - // Peer extends p2p.Peer with RPC integrated. type Peer struct { *p2p.Peer @@ -84,7 +80,7 @@ func (p *Peer) UpdateHead(id thor.Bytes32, totalScore uint64) { // MarkTransaction marks a transaction to known. func (p *Peer) MarkTransaction(hash thor.Bytes32) { // that's 10~100 block intervals - expiration := mclock.AbsTime(time.Second * time.Duration(thor.BlockInterval*uint64(rand.Intn(91)+10))) // #nosec + expiration := mclock.AbsTime(time.Second * time.Duration(thor.BlockInterval*uint64(rand.N(91)+10))) // #nosec deadline := mclock.Now() + expiration p.knownTxs.Add(hash, deadline) diff --git a/log/format_test.go b/log/format_test.go index 43c2703b6..878b705cb 100644 --- a/log/format_test.go +++ b/log/format_test.go @@ -17,7 +17,7 @@ package log import ( - "math/rand" + "math/rand/v2" "testing" ) @@ -27,7 +27,7 @@ func BenchmarkPrettyInt64Logfmt(b *testing.B) { buf := make([]byte, 100) b.ReportAllocs() for i := 0; i < b.N; i++ { - sink = appendInt64(buf, rand.Int63()) // nolint + sink = appendInt64(buf, rand.Int64()) // #nosec } } @@ -35,6 +35,6 @@ func BenchmarkPrettyUint64Logfmt(b *testing.B) { buf := make([]byte, 100) b.ReportAllocs() for i := 0; i < b.N; i++ { - sink = appendUint64(buf, rand.Uint64(), false) // nolint + sink = appendUint64(buf, rand.Uint64(), false) // #nosec } } diff --git a/metrics/noop_test.go b/metrics/noop_test.go index 2d4133ed4..2a975ff91 100644 --- a/metrics/noop_test.go +++ b/metrics/noop_test.go @@ -6,7 +6,7 @@ package metrics import ( - "math/rand" + "math/rand/v2" "net/http" "net/http/httptest" "testing" @@ -26,21 +26,21 @@ func TestNoopMetrics(t *testing.T) { Counter("count2") count1.Add(1) - randCount2 := rand.Intn(100) + 1 // nolint:gosec + randCount2 := rand.N(100) + 1 // #nosec for i := 0; i < randCount2; i++ { Counter("count2").Add(1) } hist := Histogram("hist1", nil) histVect := HistogramVec("hist2", []string{"zeroOrOne"}, nil) - for i := 0; i < rand.Intn(100)+1; i++ { // nolint:gosec + for i := 0; i < rand.N(100)+1; i++ { // #nosec hist.Observe(int64(i)) histVect.ObserveWithLabels(int64(i), map[string]string{"thisIsNonsense": "butDoesntBreak"}) } countVect := CounterVec("countVec1", []string{"zeroOrOne"}) gaugeVec := GaugeVec("gaugeVec1", []string{"zeroOrOne"}) - for i := 0; i < rand.Intn(100)+1; i++ { // nolint:gosec + for i := 0; i < rand.N(100)+1; i++ { // #nosec countVect.AddWithLabel(int64(i), map[string]string{"thisIsNonsense": "butDoesntBreak"}) gaugeVec.AddWithLabel(int64(i), map[string]string{"thisIsNonsense": "butDoesntBreak"}) } diff --git a/metrics/prometheus_test.go b/metrics/prometheus_test.go index 7a3fd689a..974f5430d 100644 --- a/metrics/prometheus_test.go +++ b/metrics/prometheus_test.go @@ -6,7 +6,7 @@ package metrics import ( - "math/rand" + "math/rand/v2" "strconv" "testing" @@ -31,13 +31,13 @@ func TestPromMetrics(t *testing.T) { gaugeVec := GaugeVec("gaugeVec1", []string{"zeroOrOne"}) count1.Add(1) - randCount2 := rand.Intn(100) + 1 // nolint:gosec + randCount2 := rand.N(100) + 1 // #nosec for i := 0; i < randCount2; i++ { Counter("count2").Add(1) } histTotal := 0 - for i := 0; i < rand.Intn(100)+2; i++ { // nolint:gosec + for i := 0; i < rand.N(100)+2; i++ { // #nosec zeroOrOne := i % 2 hist.Observe(int64(i)) HistogramVec("hist2", []string{"zeroOrOne"}, nil). @@ -46,7 +46,7 @@ func TestPromMetrics(t *testing.T) { } totalCountVec := 0 - randCountVec := rand.Intn(100) + 2 // nolint:gosec + randCountVec := rand.N(100) + 2 // #nosec for i := 0; i < randCountVec; i++ { zeroOrOne := i % 2 countVect.AddWithLabel(int64(i), map[string]string{"zeroOrOne": strconv.Itoa(zeroOrOne)}) @@ -54,7 +54,7 @@ func TestPromMetrics(t *testing.T) { } totalGaugeVec := 0 - randGaugeVec := rand.Intn(100) + 2 // nolint:gosec + randGaugeVec := rand.N(100) + 2 // #nosec for i := 0; i < randGaugeVec; i++ { zeroOrOne := i % 2 gaugeVec.AddWithLabel(int64(i), map[string]string{"zeroOrOne": strconv.Itoa(zeroOrOne)}) diff --git a/p2psrv/rpc/rpc.go b/p2psrv/rpc/rpc.go index 5fa39fd46..e19185bbd 100644 --- a/p2psrv/rpc/rpc.go +++ b/p2psrv/rpc/rpc.go @@ -7,7 +7,7 @@ package rpc import ( "context" - "math/rand" + "math/rand/v2" "sync" "time" @@ -17,11 +17,6 @@ import ( "github.com/vechain/thor/v2/log" ) -func init() { - // required when generate call id - rand.Seed(time.Now().UnixNano()) // nolint:staticcheck -} - const ( rpcDefaultTimeout = time.Second * 10 ) diff --git a/runtime/statedb/statedb_test.go b/runtime/statedb/statedb_test.go index 422c9e1ce..ef1e25831 100644 --- a/runtime/statedb/statedb_test.go +++ b/runtime/statedb/statedb_test.go @@ -134,7 +134,7 @@ func newTestAction(addr common.Address, r *rand.Rand) testAction { nameargs = append(nameargs, addr.Hex()) } for _, i := range action.args { - action.args[i] = rand.Int63n(100) // nolint:gosec + action.args[i] = rand.Int63n(100) // #nosec nameargs = append(nameargs, fmt.Sprint(action.args[i])) } action.name += strings.Join(nameargs, ", ") diff --git a/state/cached_object_test.go b/state/cached_object_test.go index 2ae0368e4..5a5265217 100644 --- a/state/cached_object_test.go +++ b/state/cached_object_test.go @@ -6,8 +6,8 @@ package state import ( + "crypto/rand" "math/big" - "math/rand" "testing" "github.com/ethereum/go-ethereum/rlp" @@ -41,7 +41,7 @@ func TestCachedObject(t *testing.T) { assert.Nil(t, err) code := make([]byte, 100) - rand.Read(code) // nolint + rand.Read(code) codeHash := thor.Keccak256(code).Bytes() db.NewStore(codeStoreName).Put(codeHash, code) diff --git a/thor/hash_test.go b/thor/hash_test.go index c34d32cd1..fc9432ffb 100644 --- a/thor/hash_test.go +++ b/thor/hash_test.go @@ -18,7 +18,8 @@ import ( func BenchmarkHash(b *testing.B) { data := make([]byte, 10) - rand.New(rand.NewSource(1)).Read(data) // nolint:gosec + + rand.New(rand.NewSource(1)).Read(data) // #nosec b.Run("keccak", func(b *testing.B) { type keccakState interface { @@ -44,7 +45,7 @@ func BenchmarkHash(b *testing.B) { func BenchmarkBlake2b(b *testing.B) { data := make([]byte, 100) - rand.New(rand.NewSource(1)).Read(data) // nolint:gosec + rand.New(rand.NewSource(1)).Read(data) // #nosec b.Run("Blake2b", func(b *testing.B) { for i := 0; i < b.N; i++ { thor.Blake2b(data).Bytes() diff --git a/trie/iterator_test.go b/trie/iterator_test.go index 2e80f8dbe..48b57345f 100644 --- a/trie/iterator_test.go +++ b/trie/iterator_test.go @@ -20,7 +20,7 @@ import ( "bytes" "encoding/hex" "fmt" - "math/rand" + "math/rand/v2" "testing" "github.com/ethereum/go-ethereum/common" @@ -331,7 +331,7 @@ func TestIteratorContinueAfterError(t *testing.T) { // because that one is already loaded. var rkey []byte for { - if rkey = keys[rand.Intn(len(keys))]; !bytes.Equal(rkey, tr.Hash().Bytes()) { // nolint:gosec + if rkey = keys[rand.N(len(keys))]; !bytes.Equal(rkey, tr.Hash().Bytes()) { // #nosec break } } diff --git a/trie/proof_test.go b/trie/proof_test.go index 26695ea14..09ccf32ae 100644 --- a/trie/proof_test.go +++ b/trie/proof_test.go @@ -19,19 +19,14 @@ package trie import ( "bytes" crand "crypto/rand" - mrand "math/rand" + mrand "math/rand/v2" "testing" - "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" "github.com/vechain/thor/v2/thor" ) -func init() { - mrand.Seed(time.Now().Unix()) // nolint:staticcheck -} - func TestProof(t *testing.T) { trie, vals := randomTrie(500) root := trie.Hash() @@ -77,7 +72,7 @@ func TestVerifyBadProof(t *testing.T) { t.Fatal("zero length proof") } keys := proofs.Keys() - key := keys[mrand.Intn(len(keys))] // nolint:gosec + key := keys[mrand.N(len(keys))] // #nosec node, _ := proofs.Get(key) proofs.Delete(key) mutateByte(node) @@ -90,8 +85,8 @@ func TestVerifyBadProof(t *testing.T) { // mutateByte changes one byte in b. func mutateByte(b []byte) { - for r := mrand.Intn(len(b)); ; { // nolint:gosec - new := byte(mrand.Intn(255)) // nolint:gosec + for r := mrand.N(len(b)); ; { // #nosec + new := byte(mrand.N(255)) // #nosec if new != b[r] { b[r] = new break diff --git a/trie/trie_test.go b/trie/trie_test.go index 1687222cc..26e504bbc 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -546,7 +546,7 @@ func benchUpdate(b *testing.B, e binary.ByteOrder) *Trie { // insert into the trie before measuring the hashing. func BenchmarkHash(b *testing.B) { // Make the random benchmark deterministic - random := rand.New(rand.NewSource(0)) // nolint:gosec + random := rand.New(rand.NewSource(0)) // #nosec // Create a realistic account trie to hash addresses := make([][20]byte, b.N) diff --git a/tx/block_ref_test.go b/tx/block_ref_test.go index d90e06ec0..b2c2c267a 100644 --- a/tx/block_ref_test.go +++ b/tx/block_ref_test.go @@ -6,7 +6,7 @@ package tx_test import ( - "math/rand" + "crypto/rand" "testing" "github.com/vechain/thor/v2/thor" @@ -21,7 +21,7 @@ func TestBlockRef(t *testing.T) { assert.Equal(t, tx.BlockRef{0, 0, 0, 0xff, 0, 0, 0, 0}, tx.NewBlockRef(0xff)) var bid thor.Bytes32 - rand.Read(bid[:]) // nolint + rand.Read(bid[:]) br := tx.NewBlockRefFromID(bid) assert.Equal(t, bid[:8], br[:]) diff --git a/tx/reserved_test.go b/tx/reserved_test.go index 9af60a9c4..f2b392022 100644 --- a/tx/reserved_test.go +++ b/tx/reserved_test.go @@ -25,7 +25,7 @@ func TestReservedEncoding(t *testing.T) { } for i, c := range cases { - data, err := rlp.EncodeToBytes(&c.input) // nolint:gosec + data, err := rlp.EncodeToBytes(&c.input) assert.Nil(t, err, "case #%v", i) assert.Equal(t, c.expected, data, "case #%v", i) } diff --git a/txpool/blocklist_test.go b/txpool/blocklist_test.go index 49a4b2db8..c85bda845 100644 --- a/txpool/blocklist_test.go +++ b/txpool/blocklist_test.go @@ -26,7 +26,7 @@ func SetupTempFile(t *testing.T, dummyData string) string { } testFilePath := tempFile.Name() - err = os.WriteFile(testFilePath, []byte(dummyData), 0644) // nolint: gosec + err = os.WriteFile(testFilePath, []byte(dummyData), 0644) // #nosec if err != nil { t.Fatalf("Failed to write to temp file: %s", err) } diff --git a/txpool/tx_object_test.go b/txpool/tx_object_test.go index fd384fdcb..2b9056f3f 100644 --- a/txpool/tx_object_test.go +++ b/txpool/tx_object_test.go @@ -8,7 +8,7 @@ package txpool import ( "math" "math/big" - "math/rand" + "math/rand/v2" "testing" "github.com/ethereum/go-ethereum/crypto" @@ -42,7 +42,7 @@ func newTx(chainTag byte, clauses []*tx.Clause, gas uint64, blockRef tx.BlockRef tx := builder.BlockRef(blockRef). Expiration(expiration). - Nonce(rand.Uint64()). // nolint:gosec + Nonce(rand.Uint64()). // #nosec DependsOn(dependsOn). Features(features). Gas(gas).Build() @@ -61,7 +61,7 @@ func newDelegatedTx(chainTag byte, clauses []*tx.Clause, gas uint64, blockRef tx tx := builder.BlockRef(blockRef). Expiration(expiration). - Nonce(rand.Uint64()). // nolint:gosec + Nonce(rand.Uint64()). // #nosec DependsOn(dependsOn). Features(features). Gas(gas).Build() diff --git a/txpool/tx_pool.go b/txpool/tx_pool.go index eb3409624..454411b9d 100644 --- a/txpool/tx_pool.go +++ b/txpool/tx_pool.go @@ -8,7 +8,7 @@ package txpool import ( "context" "math/big" - "math/rand" + "math/rand/v2" "os" "sync/atomic" "time"