2021-07-07 09:27:43 +02:00
|
|
|
package kvdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/btcsuite/btcwallet/walletdb"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
type boltFixture struct {
|
|
|
|
t *testing.T
|
|
|
|
tempDir string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewBoltFixture(t *testing.T) *boltFixture {
|
|
|
|
return &boltFixture{
|
|
|
|
t: t,
|
2022-08-15 15:07:05 +02:00
|
|
|
tempDir: t.TempDir(),
|
2021-07-07 09:27:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *boltFixture) NewBackend() walletdb.DB {
|
|
|
|
dbPath := filepath.Join(b.tempDir)
|
|
|
|
|
|
|
|
db, err := GetBoltBackend(&BoltBackendConfig{
|
|
|
|
DBPath: dbPath,
|
|
|
|
DBFileName: "test.db",
|
|
|
|
NoFreelistSync: true,
|
|
|
|
DBTimeout: DefaultDBTimeout,
|
|
|
|
})
|
|
|
|
require.NoError(b.t, err)
|
|
|
|
|
|
|
|
return db
|
|
|
|
}
|