mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-26 14:08:41 +01:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user