routing: assert that paths have same length in isSamePath
This commit is contained in:
parent
d93e3e6fbe
commit
2d10d83f07
@ -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
|
// isSamePath returns true if path1 and path2 travel through the exact same
|
||||||
// edges, and false otherwise.
|
// edges, and false otherwise.
|
||||||
func isSamePath(path1, path2 []*ChannelHop) bool {
|
func isSamePath(path1, path2 []*ChannelHop) bool {
|
||||||
|
if len(path1) != len(path2) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < len(path1); i++ {
|
for i := 0; i < len(path1); i++ {
|
||||||
if path1[i].ChannelID != path2[i].ChannelID {
|
if path1[i].ChannelID != path2[i].ChannelID {
|
||||||
return false
|
return false
|
||||||
|
@ -130,8 +130,8 @@ func TestFindRoutesFeeSorting(t *testing.T) {
|
|||||||
|
|
||||||
// Exactly, two such paths should be found.
|
// Exactly, two such paths should be found.
|
||||||
if len(routes) != 2 {
|
if len(routes) != 2 {
|
||||||
t.Fatalf("2 routes shouldn't been selected, instead %v were: ",
|
t.Fatalf("2 routes shouldn't been selected, instead %v were: %v",
|
||||||
len(routes))
|
len(routes), spew.Sdump(routes))
|
||||||
}
|
}
|
||||||
|
|
||||||
// The paths should properly be ranked according to their total fee
|
// The paths should properly be ranked according to their total fee
|
||||||
|
Loading…
Reference in New Issue
Block a user