use in-mem db in tests (#800)

This commit is contained in:
Alex Sharov 2022-12-23 14:34:14 +07:00 committed by GitHub
parent afe3703d28
commit d2603c5730
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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{},

View File

@ -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},

View File

@ -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},