mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-11 01:11:02 +02:00
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:
parent
e46c9f88c0
commit
033ad38164
@ -1103,13 +1103,11 @@ func TestGraphTraversalCacheable(t *testing.T) {
|
|||||||
// Create a map of all nodes with the iteration we know works (because
|
// Create a map of all nodes with the iteration we know works (because
|
||||||
// it is tested in another test).
|
// it is tested in another test).
|
||||||
nodeMap := make(map[route.Vertex]struct{})
|
nodeMap := make(map[route.Vertex]struct{})
|
||||||
err = graph.forEachNode(
|
err = graph.ForEachNode(func(tx NodeRTx) error {
|
||||||
func(tx kvdb.RTx, n *models.LightningNode) error {
|
nodeMap[tx.Node().PubKeyBytes] = struct{}{}
|
||||||
nodeMap[n.PubKeyBytes] = struct{}{}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
})
|
||||||
)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Len(t, nodeMap, numNodes)
|
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
|
// Iterate over each node as returned by the graph, if all nodes are
|
||||||
// reached, then the map created above should be empty.
|
// reached, then the map created above should be empty.
|
||||||
err := graph.forEachNode(
|
err := graph.ForEachNode(func(tx NodeRTx) error {
|
||||||
func(_ kvdb.RTx, node *models.LightningNode) error {
|
delete(nodeIndex, tx.Node().Alias)
|
||||||
delete(nodeIndex, node.Alias)
|
return nil
|
||||||
return nil
|
})
|
||||||
},
|
|
||||||
)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Len(t, nodeIndex, 0)
|
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) {
|
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
|
||||||
numNodes := 0
|
numNodes := 0
|
||||||
err := graph.forEachNode(
|
err := graph.ForEachNode(func(tx NodeRTx) error {
|
||||||
func(_ kvdb.RTx, _ *models.LightningNode) error {
|
numNodes++
|
||||||
numNodes++
|
|
||||||
return nil
|
return nil
|
||||||
},
|
})
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, _, line, _ := runtime.Caller(1)
|
_, _, line, _ := runtime.Caller(1)
|
||||||
t.Fatalf("line %v: unable to scan nodes: %v", line, err)
|
t.Fatalf("line %v: unable to scan nodes: %v", line, err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user