routing: assert that paths have same length in isSamePath

This commit is contained in:
Olaoluwa Osuntokun 2017-04-13 14:42:29 -07:00
parent d93e3e6fbe
commit 2d10d83f07
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 6 additions and 2 deletions

@ -75,6 +75,10 @@ func computeFee(amt btcutil.Amount, edge *ChannelHop) btcutil.Amount {
// isSamePath returns true if path1 and path2 travel through the exact same
// edges, and false otherwise.
func isSamePath(path1, path2 []*ChannelHop) bool {
if len(path1) != len(path2) {
return false
}
for i := 0; i < len(path1); i++ {
if path1[i].ChannelID != path2[i].ChannelID {
return false

@ -130,8 +130,8 @@ func TestFindRoutesFeeSorting(t *testing.T) {
// Exactly, two such paths should be found.
if len(routes) != 2 {
t.Fatalf("2 routes shouldn't been selected, instead %v were: ",
len(routes))
t.Fatalf("2 routes shouldn't been selected, instead %v were: %v",
len(routes), spew.Sdump(routes))
}
// The paths should properly be ranked according to their total fee