channeldb: remove graph calls from tests

The channeldb no longer depends on the graph. So remove the use of
MakeTestGraph from tests.
This commit is contained in:
Elle Mouton 2025-04-05 19:38:20 +02:00
parent 4ab0699e10
commit 149abb96f6
No known key found for this signature in database
GPG Key ID: D7D916376026F177
2 changed files with 11 additions and 19 deletions

View File

@ -14,7 +14,6 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
@ -185,21 +184,22 @@ func TestMultiSourceAddrsForNode(t *testing.T) {
fullDB, err := MakeTestDB(t) fullDB, err := MakeTestDB(t)
require.NoError(t, err, "unable to make test database") require.NoError(t, err, "unable to make test database")
graph, err := graphdb.MakeTestGraph(t) graph := newMockAddrSource(t)
require.NoError(t, err) t.Cleanup(func() {
graph.AssertExpectations(t)
})
// We'll make a test vertex to insert into the database, as the source // We'll make a test vertex, but this node will only have half the
// node, but this node will only have half the number of addresses it // number of addresses it usually does.
// usually does.
testNode := createTestVertex(t) testNode := createTestVertex(t)
require.NoError(t, err, "unable to create test node") nodePub, err := testNode.PubKey()
testNode.Addresses = []net.Addr{testAddr} require.NoError(t, err)
require.NoError(t, graph.SetSourceNode(testNode)) graph.On("AddrsForNode", nodePub).Return(
true, []net.Addr{testAddr}, nil,
).Once()
// Next, we'll make a link node with the same pubkey, but with an // Next, we'll make a link node with the same pubkey, but with an
// additional address. // additional address.
nodePub, err := testNode.PubKey()
require.NoError(t, err, "unable to recv node pub")
linkNode := NewLinkNode( linkNode := NewLinkNode(
fullDB.channelStateDB.linkNodeDB, wire.MainNet, nodePub, fullDB.channelStateDB.linkNodeDB, wire.MainNet, nodePub,
anotherAddr, anotherAddr,

View File

@ -6,7 +6,6 @@ import (
"github.com/btcsuite/btcwallet/walletdb" "github.com/btcsuite/btcwallet/walletdb"
"github.com/go-errors/errors" "github.com/go-errors/errors"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -22,13 +21,6 @@ func applyMigration(t *testing.T, beforeMigration, afterMigration func(d *DB),
} }
cdb.dryRun = dryRun cdb.dryRun = dryRun
// Create a test node that will be our source node.
testNode := createTestVertex(t)
graph, err := graphdb.MakeTestGraph(t)
require.NoError(t, err)
require.NoError(t, graph.SetSourceNode(testNode))
// beforeMigration usually used for populating the database // beforeMigration usually used for populating the database
// with test data. // with test data.
beforeMigration(cdb) beforeMigration(cdb)