diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index e644fea19..bd4a2d56f 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -3337,29 +3337,28 @@ func TestAddChannelEdgeShellNodes(t *testing.T) { // To start, we'll create two nodes, and only add one of them to the // channel graph. node1 := createTestVertex(t) - if err := graph.AddLightningNode(node1); err != nil { - t.Fatalf("unable to add node: %v", err) - } + require.NoError(t, graph.SetSourceNode(node1)) node2 := createTestVertex(t) // We'll now create an edge between the two nodes, as a result, node2 // should be inserted into the database as a shell node. edgeInfo, _ := createEdge(100, 0, 0, 0, node1, node2) - if err := graph.AddChannelEdge(&edgeInfo); err != nil { - t.Fatalf("unable to add edge: %v", err) - } + require.NoError(t, graph.AddChannelEdge(&edgeInfo)) // Ensure that node1 was inserted as a full node, while node2 only has // a shell node present. node1, err := graph.FetchLightningNode(node1.PubKeyBytes) require.NoError(t, err, "unable to fetch node1") - if !node1.HaveNodeAnnouncement { - t.Fatalf("have shell announcement for node1, shouldn't") - } + require.True(t, node1.HaveNodeAnnouncement) node2, err = graph.FetchLightningNode(node2.PubKeyBytes) require.NoError(t, err, "unable to fetch node2") require.False(t, node2.HaveNodeAnnouncement) + + // Show that attempting to add the channel again will result in an + // error. + err = graph.AddChannelEdge(&edgeInfo) + require.ErrorIs(t, err, ErrEdgeAlreadyExist) } // TestNodePruningUpdateIndexDeletion tests that once a node has been removed