autopilot/prefattach_test: ensure non-connected nodes get 0-score

This addition to the unit tests makes sure nodes that have no channels
in the graph are left out od the scored nodes, implicitly giving them a
score of 0.
This commit is contained in:
Johan T. Halseth 2018-12-10 14:56:54 +01:00
parent b9c33da3f8
commit 0255db5120
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

View File

@ -376,6 +376,12 @@ func TestConstrainedPrefAttachmentSelectTwoVertexes(t *testing.T) {
t1.Fatalf("unable to generate channel: %v", err)
}
// We also add a third, non-connected node to the graph.
_, err = graph.addRandNode()
if err != nil {
t1.Fatalf("unable to add random node: %v", err)
}
// Get the score for all nodes found in the graph at
// this point.
nodes := make(map[NodeID]struct{})
@ -386,7 +392,7 @@ func TestConstrainedPrefAttachmentSelectTwoVertexes(t *testing.T) {
t1.Fatalf("unable to traverse graph: %v", err)
}
if len(nodes) != 2 {
if len(nodes) != 3 {
t1.Fatalf("expected 2 nodes, found %d", len(nodes))
}
@ -401,8 +407,10 @@ func TestConstrainedPrefAttachmentSelectTwoVertexes(t *testing.T) {
"directives: %v", err)
}
if len(candidates) != len(nodes) {
t1.Fatalf("all nodes should be scored, "+
// We expect two candidates, since one of the nodes
// doesn't have any channels.
if len(candidates) != 2 {
t1.Fatalf("2 nodes should be scored, "+
"instead %v were", len(candidates))
}