Skip to content

Commit c5a4485

Browse files
committed
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.
1 parent dc9e9b0 commit c5a4485

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

graph/db/graph_test.go

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,13 +1103,11 @@ func TestGraphTraversalCacheable(t *testing.T) {
11031103
// Create a map of all nodes with the iteration we know works (because
11041104
// it is tested in another test).
11051105
nodeMap := make(map[route.Vertex]struct{})
1106-
err = graph.forEachNode(
1107-
func(tx kvdb.RTx, n *models.LightningNode) error {
1108-
nodeMap[n.PubKeyBytes] = struct{}{}
1106+
err = graph.ForEachNode(func(tx NodeRTx) error {
1107+
nodeMap[tx.Node().PubKeyBytes] = struct{}{}
11091108

1110-
return nil
1111-
},
1112-
)
1109+
return nil
1110+
})
11131111
require.NoError(t, err)
11141112
require.Len(t, nodeMap, numNodes)
11151113

@@ -1225,12 +1223,10 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
12251223

12261224
// Iterate over each node as returned by the graph, if all nodes are
12271225
// reached, then the map created above should be empty.
1228-
err := graph.forEachNode(
1229-
func(_ kvdb.RTx, node *models.LightningNode) error {
1230-
delete(nodeIndex, node.Alias)
1231-
return nil
1232-
},
1233-
)
1226+
err := graph.ForEachNode(func(tx NodeRTx) error {
1227+
delete(nodeIndex, tx.Node().Alias)
1228+
return nil
1229+
})
12341230
require.NoError(t, err)
12351231
require.Len(t, nodeIndex, 0)
12361232

@@ -1337,12 +1333,11 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
13371333

13381334
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
13391335
numNodes := 0
1340-
err := graph.forEachNode(
1341-
func(_ kvdb.RTx, _ *models.LightningNode) error {
1342-
numNodes++
1343-
return nil
1344-
},
1345-
)
1336+
err := graph.ForEachNode(func(tx NodeRTx) error {
1337+
numNodes++
1338+
1339+
return nil
1340+
})
13461341
if err != nil {
13471342
_, _, line, _ := runtime.Caller(1)
13481343
t.Fatalf("line %v: unable to scan nodes: %v", line, err)

0 commit comments

Comments
 (0)