From 7a3116f8a97223bb8403aedb058bb4a6f0417eca Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 6 Dec 2017 18:45:45 -0800 Subject: [PATCH] routing: ensure we set the TotalFees value on routes properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- routing/pathfind.go | 2 ++ routing/router_test.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/routing/pathfind.go b/routing/pathfind.go index e2209d5b..d19c8863 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -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. diff --git a/routing/router_test.go b/routing/router_test.go index 8568cbf2..c3b43098 100644 --- a/routing/router_test.go +++ b/routing/router_test.go @@ -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])) }