graph/db: use only exported KVStore ForEachNode method in tests

Replace all tests calls to the private `forEachNode` method on the
`KVStore` with the exported ForEachNode method. This is in preparation
for having the tests run against an abstract DB backend.
This commit is contained in:
Elle Mouton committed 2025-05-22 14:14:38 +02:00
1 parent b83b4015d9
commit 2f54a0a26a
1 file changed
+13 -18
+13 -18
View File
@@ -1103,13 +1103,11 @@ func TestGraphTraversalCacheable(t *testing.T) {
// Create a map of all nodes with the iteration we know works (because
// it is tested in another test).
nodeMap := make(map[route.Vertex]struct{})
err = graph.forEachNode(
func(tx kvdb.RTx, n *models.LightningNode) error {
nodeMap[n.PubKeyBytes] = struct{}{}
err = graph.ForEachNode(func(tx NodeRTx) error {
nodeMap[tx.Node().PubKeyBytes] = struct{}{}
return nil
},
)
return nil
})
require.NoError(t, err)
require.Len(t, nodeMap, numNodes)
@@ -1225,12 +1223,10 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
// Iterate over each node as returned by the graph, if all nodes are
// reached, then the map created above should be empty.
err := graph.forEachNode(
func(_ kvdb.RTx, node *models.LightningNode) error {
delete(nodeIndex, node.Alias)
return nil
},
)
err := graph.ForEachNode(func(tx NodeRTx) error {
delete(nodeIndex, tx.Node().Alias)
return nil
})
require.NoError(t, err)
require.Len(t, nodeIndex, 0)
@@ -1337,12 +1333,11 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
numNodes := 0
err := graph.forEachNode(
func(_ kvdb.RTx, _ *models.LightningNode) error {
numNodes++
return nil
},
)
err := graph.ForEachNode(func(tx NodeRTx) error {
numNodes++
return nil
})
if err != nil {
_, _, line, _ := runtime.Caller(1)
t.Fatalf("line %v: unable to scan nodes: %v", line, err)