mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-26 14:08:41 +01:00
multi: further decouple graph
To further separate the channel graph from the channel state, we refactor the AddrsForNode method to use the graphs's public methods instead of directly accessing any buckets. This makes sure that we can have the channel state cached with just its buckets while not using a kvdb level cache for the graph. At the same time we refactor the graph's test to also be less dependent upon the channel state DB.
This commit is contained in:
@@ -125,8 +125,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
|
||||
}
|
||||
|
||||
mc, err := NewMissionControl(
|
||||
graphInstance.graph.Database(), route.Vertex{},
|
||||
mcConfig,
|
||||
graphInstance.graphBackend, route.Vertex{}, mcConfig,
|
||||
)
|
||||
require.NoError(t, err, "failed to create missioncontrol")
|
||||
|
||||
@@ -188,7 +187,6 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
|
||||
|
||||
cleanUp := func() {
|
||||
ctx.router.Stop()
|
||||
graphInstance.cleanUp()
|
||||
}
|
||||
|
||||
return ctx, cleanUp
|
||||
@@ -197,17 +195,10 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
|
||||
func createTestCtxSingleNode(t *testing.T,
|
||||
startingHeight uint32) (*testCtx, func()) {
|
||||
|
||||
var (
|
||||
graph *channeldb.ChannelGraph
|
||||
sourceNode *channeldb.LightningNode
|
||||
cleanup func()
|
||||
err error
|
||||
)
|
||||
|
||||
graph, cleanup, err = makeTestGraph()
|
||||
graph, graphBackend, cleanup, err := makeTestGraph()
|
||||
require.NoError(t, err, "failed to make test graph")
|
||||
|
||||
sourceNode, err = createTestNode()
|
||||
sourceNode, err := createTestNode()
|
||||
require.NoError(t, err, "failed to create test node")
|
||||
|
||||
require.NoError(t,
|
||||
@@ -215,8 +206,9 @@ func createTestCtxSingleNode(t *testing.T,
|
||||
)
|
||||
|
||||
graphInstance := &testGraphInstance{
|
||||
graph: graph,
|
||||
cleanUp: cleanup,
|
||||
graph: graph,
|
||||
graphBackend: graphBackend,
|
||||
cleanUp: cleanup,
|
||||
}
|
||||
|
||||
return createTestCtxFromGraphInstance(
|
||||
@@ -1577,7 +1569,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
t.Fatalf("unable to find any routes: %v", err)
|
||||
}
|
||||
|
||||
copy1, err := ctx.graph.FetchLightningNode(nil, pub1)
|
||||
copy1, err := ctx.graph.FetchLightningNode(pub1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to fetch node: %v", err)
|
||||
}
|
||||
@@ -1586,7 +1578,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
t.Fatalf("fetched node not equal to original")
|
||||
}
|
||||
|
||||
copy2, err := ctx.graph.FetchLightningNode(nil, pub2)
|
||||
copy2, err := ctx.graph.FetchLightningNode(pub2)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to fetch node: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user