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 2025-04-09 14:05:24 +02:00
parent e46c9f88c0
commit 033ad38164
No known key found for this signature in database
GPG Key ID: D7D916376026F177

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)