enable cryptorand analyzer in slasher (#7417)

This commit is contained in:
Victor Farazdagi 2020-10-02 19:32:21 +03:00 committed by GitHub
parent b589ddd774
commit e36e9250f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 9 deletions

View File

@ -86,6 +86,7 @@
"only_files": {
"beacon-chain/.*": "",
"shared/.*": "",
"slasher/.*": "",
"validator/.*": ""
},
"exclude_files": {

View File

@ -8,6 +8,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/slasher/db/testing",
visibility = ["//slasher:__subpackages__"],
deps = [
"//shared/rand:go_default_library",
"//shared/testutil:go_default_library",
"//slasher/db:go_default_library",
"//slasher/db/kv:go_default_library",

View File

@ -3,13 +3,12 @@
package testing
import (
"crypto/rand"
"fmt"
"math/big"
"os"
"path"
"testing"
"github.com/prysmaticlabs/prysm/shared/rand"
"github.com/prysmaticlabs/prysm/shared/testutil"
slasherDB "github.com/prysmaticlabs/prysm/slasher/db"
"github.com/prysmaticlabs/prysm/slasher/db/kv"
@ -17,10 +16,7 @@ import (
// SetupSlasherDB instantiates and returns a SlasherDB instance.
func SetupSlasherDB(t testing.TB, spanCacheEnabled bool) *kv.Store {
randPath, err := rand.Int(rand.Reader, big.NewInt(1000000))
if err != nil {
t.Fatalf("Could not generate random file path: %v", err)
}
randPath := rand.NewDeterministicGenerator().Int()
p := path.Join(testutil.TempDir(), fmt.Sprintf("/%d", randPath))
if err := os.RemoveAll(p); err != nil {
t.Fatalf("Failed to remove directory: %v", err)

View File

@ -7,6 +7,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//shared/params:go_default_library",
"//shared/rand:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
],
)

View File

@ -3,10 +3,9 @@
package testing
import (
"crypto/rand"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/rand"
)
// SignedBlockHeader given slot, proposer index this function generates signed block header.
@ -43,7 +42,8 @@ func BlockHeader(slot uint64, proposerIdx uint64) (*ethpb.BeaconBlockHeader, err
func genRandomByteArray(length int) ([]byte, error) {
blk := make([]byte, length)
_, err := rand.Read(blk)
randGen := rand.NewDeterministicGenerator()
_, err := randGen.Read(blk)
return blk, err
}