What changed, and why it matters
This is a minor test-only cleanup in the LND codebase. It adjusts how a graph cache is enabled in one test and removes a redundant assertion in a helper function. There is no change to production code, no security fix, and no vulnerability.
No security action needed. Treat as routine test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies graph/db/graph_test.go only. It removes a duplicate require.False check on g.graphCache.nodeChannels[n] from assertNodeNotInCache, updates TestGraphCacheTraversal to explicitly enable the graph cache via WithUseGraphCache(true), and switches the traversal call from graph.graphCache.ForEachChannel to graph.ForEachNodeDirectedChannel with a context and reset callback. These are test-refactoring changes with no runtime security implications.
Changed components
graph/db/graph_test.goInspect captured patch +9 / −6
diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go
index 1c38b3e..13f24ed 100644
--- a/graph/db/graph_test.go
+++ b/graph/db/graph_test.go
@@ -1347,9 +1347,6 @@ func assertNodeNotInCache(t *testing.T, g *ChannelGraph, n route.Vertex) {
_, ok := g.graphCache.nodeFeatures[n]
require.False(t, ok)
- _, ok = g.graphCache.nodeChannels[n]
- require.False(t, ok)
-
// We should get the default features for this node.
features := g.graphCache.GetFeatures(n)
require.Equal(t, lnwire.EmptyFeatureVector(), features)
@@ -1915,10 +1912,14 @@ func testGraphTraversalCacheable(t *testing.T, v lnwire.GossipVersion) {
require.Len(t, chanIndex2, 0)
}
+// TestGraphCacheTraversal tests traversal of the graph via the graph cache.
func TestGraphCacheTraversal(t *testing.T) {
t.Parallel()
+ ctx := t.Context()
- graph := MakeTestGraph(t)
+ // Explicitly enable the graph cache so that the
+ // ForEachNodeDirectedChannel call below will use the cache.
+ graph := MakeTestGraph(t, WithUseGraphCache(true))
// We'd like to test some of the graph traversal capabilities within
// the DB, so we'll create a series of fake nodes to insert into the
@@ -1936,8 +1937,8 @@ func TestGraphCacheTraversal(t *testing.T) {
for _, node := range nodeList {
node := node
- err := graph.graphCache.ForEachChannel(
- node.PubKeyBytes, func(d *DirectedChannel) error {
+ err := graph.ForEachNodeDirectedChannel(
+ ctx, node.PubKeyBytes, func(d *DirectedChannel) error {
delete(chanIndex, d.ChannelID)
if !d.OutPolicySet || d.InPolicy == nil {
@@ -1958,6 +1959,8 @@ func TestGraphCacheTraversal(t *testing.T) {
numNodeChans++
return nil
+ }, func() {
+ numNodeChans = 0
},
)
require.NoError(t, err)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.