mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-14 10:29:29 +02:00
graph/db: expand AddChannelEdge test
Expand the existing TestAddChannelEdgeShellNodes test so that we have coverage for error we expect when AddChannelEdge is called a second time if we already know of a channel.
This commit is contained in:
@@ -3337,29 +3337,28 @@ func TestAddChannelEdgeShellNodes(t *testing.T) {
|
|||||||
// To start, we'll create two nodes, and only add one of them to the
|
// To start, we'll create two nodes, and only add one of them to the
|
||||||
// channel graph.
|
// channel graph.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(node1); err != nil {
|
require.NoError(t, graph.SetSourceNode(node1))
|
||||||
t.Fatalf("unable to add node: %v", err)
|
|
||||||
}
|
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
|
|
||||||
// We'll now create an edge between the two nodes, as a result, node2
|
// We'll now create an edge between the two nodes, as a result, node2
|
||||||
// should be inserted into the database as a shell node.
|
// should be inserted into the database as a shell node.
|
||||||
edgeInfo, _ := createEdge(100, 0, 0, 0, node1, node2)
|
edgeInfo, _ := createEdge(100, 0, 0, 0, node1, node2)
|
||||||
if err := graph.AddChannelEdge(&edgeInfo); err != nil {
|
require.NoError(t, graph.AddChannelEdge(&edgeInfo))
|
||||||
t.Fatalf("unable to add edge: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that node1 was inserted as a full node, while node2 only has
|
// Ensure that node1 was inserted as a full node, while node2 only has
|
||||||
// a shell node present.
|
// a shell node present.
|
||||||
node1, err := graph.FetchLightningNode(node1.PubKeyBytes)
|
node1, err := graph.FetchLightningNode(node1.PubKeyBytes)
|
||||||
require.NoError(t, err, "unable to fetch node1")
|
require.NoError(t, err, "unable to fetch node1")
|
||||||
if !node1.HaveNodeAnnouncement {
|
require.True(t, node1.HaveNodeAnnouncement)
|
||||||
t.Fatalf("have shell announcement for node1, shouldn't")
|
|
||||||
}
|
|
||||||
|
|
||||||
node2, err = graph.FetchLightningNode(node2.PubKeyBytes)
|
node2, err = graph.FetchLightningNode(node2.PubKeyBytes)
|
||||||
require.NoError(t, err, "unable to fetch node2")
|
require.NoError(t, err, "unable to fetch node2")
|
||||||
require.False(t, node2.HaveNodeAnnouncement)
|
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
|
// TestNodePruningUpdateIndexDeletion tests that once a node has been removed
|
||||||
|
Reference in New Issue
Block a user