From ebef51daa081b33bd18c100f6f80d4346d2158ec Mon Sep 17 00:00:00 2001 From: Seebs Date: Tue, 23 Aug 2022 13:19:01 -0500 Subject: [PATCH] smallify Quick checks Quick checks aren't super helpful, but they can test random stuff a bit, so let's keep them, but make them smaller. Also, let's cram the random selections into the first quarter of a shard so we see more container updates to fewer containers because that's probably more interesting. --- rbf/rbf_test.go | 13 ++++++++++++- rbf/tx_test.go | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) 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)