Skip to content

Commit

Permalink
routing: assert that paths have same length in isSamePath
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed Apr 13, 2017
1 parent d93e3e6 commit 2d10d83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions routing/pathfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions routing/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d10d83

Please sign in to comment.