routing: fix gap in result interpretation

Fixes an off by one error that skipped assigning a success pair. Added a
test that previously failed because of this bug.
This commit is contained in:
Joost Jager
2019-12-20 08:55:45 +01:00
parent f6172fb83a
commit a3a1b488a6
2 changed files with 38 additions and 6 deletions

View File

@ -191,10 +191,8 @@ func (i *interpretedResult) processPaymentOutcomeFinal(
i.failPair(route, n-1)
// The other hops relayed corectly, so assign those pairs a
// success result.
if n > 2 {
i.successPairRange(route, 0, n-2)
}
// success result. At this point, n >= 2.
i.successPairRange(route, 0, n-2)
// We are using wrong payment hash or amount, fail the payment.
case *lnwire.FailIncorrectPaymentAmount,
@ -223,7 +221,7 @@ func (i *interpretedResult) processPaymentOutcomeFinal(
i.failNode(route, n)
// Other channels in the route forwarded correctly.
if n > 2 {
if n >= 2 {
i.successPairRange(route, 0, n-2)
}