routing: check for empty hops list

This commit fixes a crash that could be triggered by sending an empty
hop list to the SendToRoute rpc.
This commit is contained in:
Joost Jager
2018-12-10 09:41:03 +01:00
parent 4d647b6e5d
commit b2cb760c65
4 changed files with 30 additions and 5 deletions

View File

@@ -1903,3 +1903,15 @@ func assertExpectedPath(t *testing.T, path []*channeldb.ChannelEdgePolicy,
}
}
}
// TestNewRouteFromEmptyHops tests that the NewRouteFromHops function returns an
// error when the hop list is empty.
func TestNewRouteFromEmptyHops(t *testing.T) {
t.Parallel()
var source Vertex
_, err := NewRouteFromHops(0, 0, source, []*Hop{})
if err != ErrNoRouteHopsProvided {
t.Fatalf("expected empty hops error: instead got: %v", err)
}
}