Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to math/rand/v2 #149

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compact/range_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"errors"
"fmt"
"math/bits"
"math/rand"
"math/rand/v2"
"reflect"
"testing"

Expand Down Expand Up @@ -272,9 +272,9 @@ func TestMergeInBatches(t *testing.T) {

// Build many trees of random size by randomly merging their sub-ranges.
func TestMergeRandomly(t *testing.T) {
for seed := int64(1); seed < 100; seed++ {
for seed := uint64(1); seed < 100; seed++ {
t.Run(fmt.Sprintf("seed:%d", seed), func(t *testing.T) {
rnd := rand.New(rand.NewSource(seed))
rnd := rand.New(rand.NewPCG(0, seed))
numNodes := rand.Uint64() % 500
t.Logf("Tree size: %d", numNodes)

Expand All @@ -287,7 +287,7 @@ func TestMergeRandomly(t *testing.T) {
t.Fatalf("Append(%d): %v", begin, err)
}
} else if begin < end {
mid := begin + uint64(rnd.Int63n(int64(end-begin)))
mid := begin + rnd.Uint64N(end-begin)
if err := rng.AppendRange(mergeAll(begin, mid), visit); err != nil {
t.Fatalf("AppendRange(%d,%d): %v", begin, mid, err)
}
Expand Down
8 changes: 4 additions & 4 deletions testonly/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package testonly
import (
"bytes"
"fmt"
"math/rand"
"math/rand/v2"
"strconv"
"testing"

Expand Down Expand Up @@ -140,11 +140,11 @@ func TestTreeConsistencyProof(t *testing.T) {
func TestTreeConsistencyProofFuzz(t *testing.T) {
entries := genEntries(256)

for treeSize := int64(1); treeSize <= 256; treeSize++ {
for treeSize := uint64(1); treeSize <= 256; treeSize++ {
mt := newTree(entries[:treeSize])
for i := 0; i < 8; i++ {
size2 := uint64(rand.Int63n(treeSize + 1))
size1 := uint64(rand.Int63n(int64(size2) + 1))
size2 := rand.Uint64N(treeSize + 1)
size1 := rand.Uint64N(size2 + 1)

got, err := mt.ConsistencyProof(size1, size2)
if err != nil {
Expand Down
Loading