diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 918369a9c..c76d4006b 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -97,6 +97,7 @@ func createTestVertex(t testing.TB) *models.LightningNode { return createLightningNode(priv) } +// TestNodeInsertionAndDeletion tests the CRUD operations for a LightningNode. func TestNodeInsertionAndDeletion(t *testing.T) { t.Parallel() ctx := context.Background() @@ -124,9 +125,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) { // First, insert the node into the graph DB. This should succeed // without any errors. node := nodeWithAddrs(testAddrs) - if err := graph.AddLightningNode(ctx, node); err != nil { - t.Fatalf("unable to add node: %v", err) - } + require.NoError(t, graph.AddLightningNode(ctx, node)) assertNodeInCache(t, graph, node, testFeatures) // Next, fetch the node from the database to ensure everything was @@ -135,11 +134,8 @@ func TestNodeInsertionAndDeletion(t *testing.T) { require.NoError(t, err, "unable to locate node") _, exists, err := graph.HasLightningNode(ctx, dbNode.PubKeyBytes) - if err != nil { - t.Fatalf("unable to query for node: %v", err) - } else if !exists { - t.Fatalf("node should be found but wasn't") - } + require.NoError(t, err) + require.True(t, exists) // The two nodes should match exactly! compareNodes(t, node, dbNode) @@ -194,7 +190,17 @@ func TestNodeInsertionAndDeletion(t *testing.T) { // Fetch the node and assert the empty addresses. dbNode, err = graph.FetchLightningNode(ctx, testPub) require.NoError(t, err) - require.Empty(t, dbNode.Addresses) + + // Temporarily have a special case for SQLStore, as currently, it does + // not correctly handle empty addresses. We assert this incorrect + // behaviour here in order to demonstrate the bug. This will be fixed in + // an upcoming commit. + if _, ok := graph.V1Store.(*SQLStore); ok { + require.Empty(t, dbNode.Addresses) + require.NotEqual(t, node.Addresses, dbNode.Addresses) + } else { + compareNodes(t, node, dbNode) + } known, addrs, err = graph.AddrsForNode(ctx, pub) require.NoError(t, err)