graph/db: introduce VersionedGraph

For now, all instances will use V1 only so as not to change behaviour
yet.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:21 +02:00
1 parent d8337be968
commit 4db5198079
9 files changed
+122 -84

No files matched your search

+14 -10
View File
@@ -61,7 +61,8 @@ type testCtx struct {
graphBuilder *mockGraphBuilder
graph *graphdb.ChannelGraph
graph *graphdb.ChannelGraph
v1Graph *graphdb.VersionedGraph
aliases map[string]route.Vertex
@@ -170,9 +171,12 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
router: router,
graphBuilder: graphBuilder,
graph: graphInstance.graph,
aliases: graphInstance.aliasMap,
privKeys: graphInstance.privKeyMap,
channelIDs: graphInstance.channelIDs,
v1Graph: graphdb.NewVersionedGraph(
graphInstance.graph, lnwire.GossipVersion1,
),
aliases: graphInstance.aliasMap,
privKeys: graphInstance.privKeyMap,
channelIDs: graphInstance.channelIDs,
}
t.Cleanup(func() {
@@ -2717,11 +2721,11 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
copy(pub2[:], priv2.PubKey().SerializeCompressed())
// The two nodes we are about to add should not exist yet.
exists1, err := ctx.graph.HasNode(ctxb, pub1)
exists1, err := ctx.v1Graph.HasNode(ctxb, pub1)
require.NoError(t, err, "unable to query graph")
require.False(t, exists1)
exists2, err := ctx.graph.HasNode(ctxb, pub2)
exists2, err := ctx.v1Graph.HasNode(ctxb, pub2)
require.NoError(t, err, "unable to query graph")
require.False(t, exists2)
@@ -2778,11 +2782,11 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
// After adding the edge between the two previously unknown nodes, they
// should have been added to the graph.
exists1, err = ctx.graph.HasNode(ctxb, pub1)
exists1, err = ctx.v1Graph.HasNode(ctxb, pub1)
require.NoError(t, err, "unable to query graph")
require.True(t, exists1)
exists2, err = ctx.graph.HasNode(ctxb, pub2)
exists2, err = ctx.v1Graph.HasNode(ctxb, pub2)
require.NoError(t, err, "unable to query graph")
require.True(t, exists2)
@@ -2907,12 +2911,12 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
_, _, err = ctx.router.FindRoute(req)
require.NoError(t, err, "unable to find any routes")
copy1, err := ctx.graph.FetchNode(ctxb, pub1)
copy1, err := ctx.v1Graph.FetchNode(ctxb, pub1)
require.NoError(t, err, "unable to fetch node")
require.Equal(t, n1.Alias, copy1.Alias)
copy2, err := ctx.graph.FetchNode(ctxb, pub2)
copy2, err := ctx.v1Graph.FetchNode(ctxb, pub2)
require.NoError(t, err, "unable to fetch node")
require.Equal(t, n2.Alias, copy2.Alias)