From 799e70fe464c64614f027f5ab0545b1d97a29c3c Mon Sep 17 00:00:00 2001 From: Seebs Date: Thu, 1 Sep 2022 10:24:13 -0500 Subject: [PATCH] shorten SetValue_QuickCheck We reuse a fragment. It might seem surprising that this works, but the fragment code actually doesn't have a persistent bit depth at all, it just accepts whatever bit depth you tell it to use. Cutting out the recreation of the fragments saves some time. We also cap bit depth at 8, instead of 62, because there's a ton of runtime cost to testing more bit depths, but it doesn't actually change the logic. --- fragment_internal_test.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fragment_internal_test.go b/fragment_internal_test.go index 512fe9da4..1ff1ef7b8 100644 --- a/fragment_internal_test.go +++ b/fragment_internal_test.go @@ -384,19 +384,22 @@ func TestFragment_SetValue(t *testing.T) { }) t.Run("QuickCheck", func(t *testing.T) { + f, idx, tx := mustOpenFragment(t, "i", "f", viewStandard, 0, "") + _ = idx + defer f.Clean(t) + tx.Rollback() + if err := quick.Check(func(bitDepth uint64, bitN uint64, values []uint64) bool { + tx = idx.holder.txf.NewTx(Txo{Write: true, Index: idx, Fragment: f, Shard: f.shard}) + defer tx.Rollback() // Limit bit depth & maximum values. - bitDepth = (bitDepth % 62) + 1 + bitDepth = (bitDepth % 8) + 1 bitN = (bitN % 99) + 1 for i := range values { values[i] = values[i] % (1 << bitDepth) } - f, idx, tx := mustOpenFragment(t, "i", "f", viewStandard, 0, "") - _ = idx - defer f.Clean(t) - // Set values. m := make(map[uint64]int64) for _, value := range values { @@ -425,7 +428,7 @@ func TestFragment_SetValue(t *testing.T) { if err := tx.Commit(); err != nil { t.Fatal(err) } - tx = idx.holder.txf.NewTx(Txo{Write: writable, Index: idx, Fragment: f, Shard: f.shard}) + tx = idx.holder.txf.NewTx(Txo{Write: false, Index: idx, Fragment: f, Shard: f.shard}) defer tx.Rollback() // Ensure values are set.