mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 14:17:56 +01:00
Let all the NewTestDB functions return the V1Store interface type instead of pointers. Then add a manual skip in the TestGraphLoading test for any non-bbolt backend. We can remove this once all the methods used by the test have been implemented by the SQLStore. We only need the manual skip for this one test since it is the only one that doesnt use MakeGraphTest to init the graph db.
36 lines
883 B
Go
36 lines
883 B
Go
//go:build !test_db_posgres && test_db_sqlite
|
|
|
|
package graphdb
|
|
|
|
import (
|
|
"database/sql"
|
|
"testing"
|
|
|
|
"github.com/lightningnetwork/lnd/kvdb"
|
|
"github.com/lightningnetwork/lnd/sqldb"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// NewTestDB is a helper function that creates a SQLStore backed by a sqlite
|
|
// database for testing. At the moment, it embeds a KVStore but once the
|
|
// SQLStore fully implements the V1Store interface, the KVStore will be removed.
|
|
func NewTestDB(t testing.TB) V1Store {
|
|
backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr")
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(backendCleanup)
|
|
|
|
graphStore, err := NewKVStore(backend)
|
|
require.NoError(t, err)
|
|
|
|
db := sqldb.NewTestSqliteDB(t).BaseDB
|
|
|
|
executor := sqldb.NewTransactionExecutor(
|
|
db, func(tx *sql.Tx) SQLQueries {
|
|
return db.WithTx(tx)
|
|
},
|
|
)
|
|
|
|
return NewSQLStore(executor, graphStore)
|
|
}
|