diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 62f153ede..12e33a960 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -1320,7 +1320,17 @@ func TestGraphTraversalCacheable(t *testing.T) { require.NoError(t, err) 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 { + // Query the ChannelGraph which uses the cache to iterate + // through the channels for each node. err = graph.ForEachNodeDirectedChannel( node, func(d *DirectedChannel) error { delete(chanIndex, d.ChannelID) @@ -1328,8 +1338,18 @@ func TestGraphTraversalCacheable(t *testing.T) { }, ) 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, chanIndex2, 0) } func TestGraphCacheTraversal(t *testing.T) {