diff --git a/rbf/rbf_test.go b/rbf/rbf_test.go index 0a2432128..986346aa5 100644 --- a/rbf/rbf_test.go +++ b/rbf/rbf_test.go @@ -158,9 +158,20 @@ func MustAddRandom(tb testing.TB, rand *rand.Rand, tx *rbf.Tx, name string, valu func GenerateValues(rand *rand.Rand, n int) []uint64 { a := make([]uint64, n) for i := range a { - a[i] = uint64(rand.Intn(rbf.ShardWidth)) + // Cram them into the first quarter of the shard, so we'll + // see more updates to existing things in smallish random + // tests. + a[i] = uint64(rand.Intn(rbf.ShardWidth / 4)) } sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) + prev := uint64(0) + // eliminate duplicates by bumping things a bit + for i := range a { + if a[i] <= prev { + a[i] = prev + 1 + } + prev = a[i] + } return a } diff --git a/rbf/tx_test.go b/rbf/tx_test.go index 410f52b61..a84941fc2 100644 --- a/rbf/tx_test.go +++ b/rbf/tx_test.go @@ -351,7 +351,7 @@ func TestTx_Add_Quick(t *testing.T) { defer MustCloseDB(t, db) tx := MustBegin(t, db, true) defer tx.Rollback() - values := GenerateValues(rand, 10000) + values := GenerateValues(rand, 2000) if err := tx.CreateBitmap("x"); err != nil { t.Fatal(err) @@ -499,7 +499,7 @@ func TestTx_AddRemove_Quick(t *testing.T) { defer MustCloseDB(t, db) tx := MustBegin(t, db, true) defer tx.Rollback() - values := GenerateValues(rand, 10000) + values := GenerateValues(rand, 2000) if err := tx.CreateBitmap("x"); err != nil { t.Fatal(err)