graph/db: test the non-cached version of ForEachNodeDirectedChannel
Expand an existing test for ForEachNodeDirectedChannel so that it also tests the DB method and not just the ChannelGraph method which will use the in-memory graph cache for the query.
This commit is contained in:
1 file changed
+20
@@ -1320,7 +1320,17 @@ func TestGraphTraversalCacheable(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Len(t, nodeMap, 0)
|
require.Len(t, nodeMap, 0)
|
||||||
|
|
||||||
|
// Duplicate the map before we start deleting from it so that we can
|
||||||
|
// check that both the cached and db version of
|
||||||
|
// ForEachNodeDirectedChannel works as expected here.
|
||||||
|
chanIndex2 := make(map[uint64]struct{})
|
||||||
|
for k, v := range chanIndex {
|
||||||
|
chanIndex2[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
|
// Query the ChannelGraph which uses the cache to iterate
|
||||||
|
// through the channels for each node.
|
||||||
err = graph.ForEachNodeDirectedChannel(
|
err = graph.ForEachNodeDirectedChannel(
|
||||||
node, func(d *DirectedChannel) error {
|
node, func(d *DirectedChannel) error {
|
||||||
delete(chanIndex, d.ChannelID)
|
delete(chanIndex, d.ChannelID)
|
||||||
@@ -1328,8 +1338,18 @@ func TestGraphTraversalCacheable(t *testing.T) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Now skip the cache and query the DB directly.
|
||||||
|
err = graph.V1Store.ForEachNodeDirectedChannel(
|
||||||
|
node, func(d *DirectedChannel) error {
|
||||||
|
delete(chanIndex2, d.ChannelID)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
require.Len(t, chanIndex, 0)
|
require.Len(t, chanIndex, 0)
|
||||||
|
require.Len(t, chanIndex2, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGraphCacheTraversal(t *testing.T) {
|
func TestGraphCacheTraversal(t *testing.T) {
|
||||||
|
|||||||
Reference in new issue
Block a user