Skip to content

Commit

Permalink
Merge pull request #504 from onflow/fxamacker/reorganize-test-util-code
Browse files Browse the repository at this point in the history
Move test util funcs to test_utils package for reuse by smoke tests
  • Loading branch information
fxamacker authored Feb 12, 2025
2 parents cfb0b7c + 6560dd6 commit 7ddeb0f
Show file tree
Hide file tree
Showing 15 changed files with 3,860 additions and 3,705 deletions.
3 changes: 2 additions & 1 deletion array_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/onflow/atree"
"github.com/onflow/atree/test_utils"
)

var noopValue atree.Value
Expand Down Expand Up @@ -192,7 +193,7 @@ func setupArray(b *testing.B, r *rand.Rand, storage *atree.PersistentSlabStorage

address := atree.Address{1, 2, 3, 4, 5, 6, 7, 8}

typeInfo := testTypeInfo{42}
typeInfo := test_utils.NewSimpleTypeInfo(42)

array, err := atree.NewArray(storage, address, typeInfo)
require.NoError(b, err)
Expand Down
15 changes: 8 additions & 7 deletions array_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/onflow/atree"
"github.com/onflow/atree/test_utils"
)

// GENERAL COMMENT:
Expand Down Expand Up @@ -53,15 +54,15 @@ func BenchmarkXXXLArray(b *testing.B) { benchmarkArray(b, 100_000_000, opCount)
func RandomValue(r *rand.Rand) atree.Value {
switch r.Intn(4) {
case 0:
return Uint8Value(r.Intn(255))
return test_utils.Uint8Value(r.Intn(255))
case 1:
return Uint16Value(r.Intn(6535))
return test_utils.Uint16Value(r.Intn(6535))
case 2:
return Uint32Value(r.Intn(4294967295))
return test_utils.Uint32Value(r.Intn(4294967295))
case 3:
return Uint64Value(r.Intn(1844674407370955161))
return test_utils.Uint64Value(r.Intn(1844674407370955161))
default:
return Uint8Value(r.Intn(255))
return test_utils.Uint8Value(r.Intn(255))
}
}

Expand All @@ -74,7 +75,7 @@ func benchmarkArray(b *testing.B, initialArrayCount, numberOfElements int) {

address := atree.Address{1, 2, 3, 4, 5, 6, 7, 8}

typeInfo := testTypeInfo{42}
typeInfo := test_utils.NewSimpleTypeInfo(42)

array, err := atree.NewArray(storage, address, typeInfo)

Expand Down Expand Up @@ -207,7 +208,7 @@ func benchmarkLongTermImpactOnMemory(b *testing.B, initialArrayCount, numberOfOp

address := atree.Address{1, 2, 3, 4, 5, 6, 7, 8}

typeInfo := testTypeInfo{42}
typeInfo := test_utils.NewSimpleTypeInfo(42)

array, err := atree.NewArray(storage, address, typeInfo)

Expand Down
Loading

0 comments on commit 7ddeb0f

Please sign in to comment.