routing: ensure we set the TotalFees value on routes properly

Before this commit, we wouldn’t properly set the TotalFees attribute.
As a result, our sorting algorithm at the end to select candidate
routes would simply maintain the time-lock order rather than also sort
by total fees. This commit fixes this issue and also allows the test
added in the prior commit to pass.
This commit is contained in:
Olaoluwa Osuntokun 2017-12-06 18:45:45 -08:00
parent 4444ec39ea
commit 7a3116f8a9
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
2 changed files with 3 additions and 1 deletions

@ -302,6 +302,8 @@ func newRoute(amtToSend lnwire.MilliSatoshi, sourceVertex Vertex,
}
edge.Node.PubKey.Curve = nil
route.TotalFees += nextHop.Fee
// As a sanity check, we ensure that the selected channel has
// enough capacity to forward the required amount which
// includes the fee dictated at each hop.

@ -186,7 +186,7 @@ func TestFindRoutesFeeSorting(t *testing.T) {
routes[0].TotalFees)
}
if routes[1].TotalFees == 0 {
t.Fatalf("total fees not set in second route: ",
t.Fatalf("total fees not set in second route: %v",
spew.Sdump(routes[0]))
}