From 227e49d0ae18b3a4ebcff9457d3e14afec3c2ec8 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Thu, 8 May 2025 10:06:52 +0200 Subject: [PATCH] graph/db: expand TestNodeInsertionAndDeletion Expand this existing test so that it also tests that a node's addresses and feature are fetched correctly after insertion. With this, we ensure that the `FetchNodeFeatures` and `AddrsForNodes` methods of the `V1Store` interface are properly covered by unit tests. --- graph/db/graph_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index a543772a4..079f46c21 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -136,6 +136,27 @@ func TestNodeInsertionAndDeletion(t *testing.T) { // The two nodes should match exactly! compareNodes(t, node, dbNode) + // Check that the addresses for the node are fetched correctly. + pub, err := node.PubKey() + require.NoError(t, err) + + known, addrs, err := graph.AddrsForNode(pub) + require.NoError(t, err) + require.True(t, known) + require.Equal(t, testAddrs, addrs) + + // Check that the node's features are fetched correctly. This check + // will use the graph cache to fetch the features. + features, err := graph.FetchNodeFeatures(node.PubKeyBytes) + require.NoError(t, err) + require.Equal(t, testFeatures, features) + + // Check that the node's features are fetched correctly. This check + // will check the database directly. + features, err = graph.V1Store.FetchNodeFeatures(node.PubKeyBytes) + require.NoError(t, err) + require.Equal(t, testFeatures, features) + // Next, delete the node from the graph, this should purge all data // related to the node. if err := graph.DeleteLightningNode(testPub); err != nil {