From d2603c57305fd51d165c966a69c196e3b8a5b3b0 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Fri, 23 Dec 2022 14:34:14 +0700 Subject: [PATCH] use in-mem db in tests (#800) --- state/aggregator_bench_test.go | 2 +- state/aggregator_test.go | 4 ++-- state/domain_test.go | 2 +- state/history_test.go | 2 +- state/inverted_index_test.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/state/aggregator_bench_test.go b/state/aggregator_bench_test.go index 143a6170e..830392cd3 100644 --- a/state/aggregator_bench_test.go +++ b/state/aggregator_bench_test.go @@ -19,7 +19,7 @@ func testDbAndAggregatorBench(b *testing.B, prefixLen int, aggStep uint64) (stri path := b.TempDir() b.Cleanup(func() { os.RemoveAll(path) }) logger := log.New() - db := mdbx.NewMDBX(logger).Path(path).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { + db := mdbx.NewMDBX(logger).InMem(path).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { return kv.ChaindataTablesCfg }).MustOpen() b.Cleanup(db.Close) diff --git a/state/aggregator_test.go b/state/aggregator_test.go index 8e80684e4..96077aec2 100644 --- a/state/aggregator_test.go +++ b/state/aggregator_test.go @@ -24,7 +24,7 @@ func testDbAndAggregator(t *testing.T, prefixLen int, aggStep uint64) (string, k path := t.TempDir() t.Cleanup(func() { os.RemoveAll(path) }) logger := log.New() - db := mdbx.NewMDBX(logger).Path(filepath.Join(path, "db4")).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { + db := mdbx.NewMDBX(logger).InMem(filepath.Join(path, "db4")).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { return kv.ChaindataTablesCfg }).MustOpen() t.Cleanup(db.Close) @@ -259,7 +259,7 @@ func TestAggregator_RestartOnFiles(t *testing.T) { require.NoError(t, os.RemoveAll(filepath.Join(path, "db4"))) - newDb, err := mdbx.NewMDBX(log.New()).Path(filepath.Join(path, "db4")).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { + newDb, err := mdbx.NewMDBX(log.New()).InMem(filepath.Join(path, "db4")).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { return kv.ChaindataTablesCfg }).Open() require.NoError(t, err) diff --git a/state/domain_test.go b/state/domain_test.go index 0272258a4..742bad1f3 100644 --- a/state/domain_test.go +++ b/state/domain_test.go @@ -47,7 +47,7 @@ func testDbAndDomain(t *testing.T, prefixLen int) (string, kv.RwDB, *Domain) { historyValsTable := "HistoryVals" settingsTable := "Settings" indexTable := "Index" - db := mdbx.NewMDBX(logger).Path(path).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { + db := mdbx.NewMDBX(logger).InMem(path).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { return kv.TableCfg{ keysTable: kv.TableCfgItem{Flags: kv.DupSort}, valsTable: kv.TableCfgItem{}, diff --git a/state/history_test.go b/state/history_test.go index a99943694..f202f59d2 100644 --- a/state/history_test.go +++ b/state/history_test.go @@ -43,7 +43,7 @@ func testDbAndHistory(tb testing.TB) (string, kv.RwDB, *History) { indexTable := "Index" valsTable := "Vals" settingsTable := "Settings" - db := mdbx.NewMDBX(logger).Path(path).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { + db := mdbx.NewMDBX(logger).InMem(path).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { return kv.TableCfg{ keysTable: kv.TableCfgItem{Flags: kv.DupSort}, indexTable: kv.TableCfgItem{Flags: kv.DupSort}, diff --git a/state/inverted_index_test.go b/state/inverted_index_test.go index 42c38d271..94d9fe940 100644 --- a/state/inverted_index_test.go +++ b/state/inverted_index_test.go @@ -43,7 +43,7 @@ func testDbAndInvertedIndex(t *testing.T, aggStep uint64) (string, kv.RwDB, *Inv logger := log.New() keysTable := "Keys" indexTable := "Index" - db := mdbx.NewMDBX(logger).Path(path).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { + db := mdbx.NewMDBX(logger).InMem(path).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg { return kv.TableCfg{ keysTable: kv.TableCfgItem{Flags: kv.DupSort}, indexTable: kv.TableCfgItem{Flags: kv.DupSort},