TestState: share db (#8576)

This commit is contained in:
Alex Sharov 2023-10-25 20:08:50 +07:00 committed by GitHub
parent 656c3d239e
commit 7aa79a5bbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,9 +28,9 @@ import (
"testing" "testing"
"github.com/ledgerwatch/erigon-lib/common/datadir" "github.com/ledgerwatch/erigon-lib/common/datadir"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/log/v3"
"github.com/ledgerwatch/erigon/core/state/temporal"
"github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm"
"github.com/ledgerwatch/erigon/eth/tracers/logger" "github.com/ledgerwatch/erigon/eth/tracers/logger"
) )
@ -38,7 +38,7 @@ import (
func TestState(t *testing.T) { func TestState(t *testing.T) {
defer log.Root().SetHandler(log.Root().GetHandler()) defer log.Root().SetHandler(log.Root().GetHandler())
log.Root().SetHandler(log.LvlFilterHandler(log.LvlError, log.StderrHandler)) log.Root().SetHandler(log.LvlFilterHandler(log.LvlError, log.StderrHandler))
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { if runtime.GOOS == "windows" {
t.Skip("fix me on win please") // it's too slow on win and stops on macos, need generally improve speed of this tests t.Skip("fix me on win please") // it's too slow on win and stops on macos, need generally improve speed of this tests
} }
//t.Parallel() //t.Parallel()
@ -49,12 +49,12 @@ func TestState(t *testing.T) {
st.skipLoad(`^stTimeConsuming/`) st.skipLoad(`^stTimeConsuming/`)
st.skipLoad(`.*vmPerformance/loop.*`) st.skipLoad(`.*vmPerformance/loop.*`)
_, db, _ := temporal.NewTestDB(t, datadir.New(t.TempDir()), nil)
st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) { st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
for _, subtest := range test.Subtests() { for _, subtest := range test.Subtests() {
subtest := subtest subtest := subtest
key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index) key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index)
t.Run(key, func(t *testing.T) { t.Run(key, func(t *testing.T) {
_, db, _ := temporal.NewTestDB(t, datadir.New(t.TempDir()), nil)
withTrace(t, func(vmconfig vm.Config) error { withTrace(t, func(vmconfig vm.Config) error {
tx, err := db.BeginRw(context.Background()) tx, err := db.BeginRw(context.Background())
if err != nil { if err != nil {