diff --git a/nogo_config.json b/nogo_config.json index 9d5913a17..d4d2ffa3b 100644 --- a/nogo_config.json +++ b/nogo_config.json @@ -86,6 +86,7 @@ "only_files": { "beacon-chain/.*": "", "shared/.*": "", + "slasher/.*": "", "validator/.*": "" }, "exclude_files": { diff --git a/slasher/db/testing/BUILD.bazel b/slasher/db/testing/BUILD.bazel index 85d5c92b1..5ceba5e81 100644 --- a/slasher/db/testing/BUILD.bazel +++ b/slasher/db/testing/BUILD.bazel @@ -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", diff --git a/slasher/db/testing/setup_db.go b/slasher/db/testing/setup_db.go index 7ab98b85d..dcf321fb7 100644 --- a/slasher/db/testing/setup_db.go +++ b/slasher/db/testing/setup_db.go @@ -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) diff --git a/slasher/detection/testing/BUILD.bazel b/slasher/detection/testing/BUILD.bazel index 9fac2862a..f7dcf3c87 100644 --- a/slasher/detection/testing/BUILD.bazel +++ b/slasher/detection/testing/BUILD.bazel @@ -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", ], ) diff --git a/slasher/detection/testing/utils.go b/slasher/detection/testing/utils.go index cb88c01a9..e5fc5b630 100644 --- a/slasher/detection/testing/utils.go +++ b/slasher/detection/testing/utils.go @@ -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 }