mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 22:50:58 +02:00
channeldb+graphdb: init graph DB outside of channel db
We also now use the graph DB's own optional functions. An instance of the graph is currently still passed to the channeldb's `CreateWithBackend` function. This will be removed in a later commit once the two have been completely disjoint.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcwallet/walletdb"
|
||||
"github.com/go-errors/errors"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -422,7 +423,10 @@ func TestMigrationReversion(t *testing.T) {
|
||||
backend, cleanup, err := kvdb.GetTestBackend(tempDirName, "cdb")
|
||||
require.NoError(t, err, "unable to get test db backend")
|
||||
|
||||
cdb, err := CreateWithBackend(backend)
|
||||
graphDB, err := graphdb.NewChannelGraph(backend)
|
||||
require.NoError(t, err)
|
||||
|
||||
cdb, err := CreateWithBackend(backend, graphDB)
|
||||
if err != nil {
|
||||
cleanup()
|
||||
t.Fatalf("unable to open channeldb: %v", err)
|
||||
@@ -448,7 +452,10 @@ func TestMigrationReversion(t *testing.T) {
|
||||
require.NoError(t, err, "unable to get test db backend")
|
||||
t.Cleanup(cleanup)
|
||||
|
||||
_, err = CreateWithBackend(backend)
|
||||
graphDB, err = graphdb.NewChannelGraph(backend)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = CreateWithBackend(backend, graphDB)
|
||||
if err != ErrDBReversion {
|
||||
t.Fatalf("unexpected error when opening channeldb, "+
|
||||
"want: %v, got: %v", ErrDBReversion, err)
|
||||
@@ -676,8 +683,11 @@ func TestMarkerAndTombstone(t *testing.T) {
|
||||
err = db.View(EnsureNoTombstone, func() {})
|
||||
require.ErrorContains(t, err, string(tombstoneText))
|
||||
|
||||
graphDB, err := graphdb.NewChannelGraph(db.Backend)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Now that the DB has a tombstone, we should no longer be able to open
|
||||
// it once we close it.
|
||||
_, err = CreateWithBackend(db.Backend)
|
||||
_, err = CreateWithBackend(db.Backend, graphDB)
|
||||
require.ErrorContains(t, err, string(tombstoneText))
|
||||
}
|
||||
|
Reference in New Issue
Block a user