diff --git a/routing/result_interpretation.go b/routing/result_interpretation.go index 7b3d539a..fae2835a 100644 --- a/routing/result_interpretation.go +++ b/routing/result_interpretation.go @@ -216,6 +216,22 @@ func (i *interpretedResult) processPaymentOutcomeFinal( // deliberately. What to penalize? i.finalFailureReason = &reasonIncorrectDetails + case *lnwire.FailMPPTimeout: + // TODO(carla): decide how to penalize mpp timeout. In the + // meantime, attribute success to the hops along the route and + // do not penalize the final node. + + i.finalFailureReason = &reasonError + + // If this is a direct payment, take no action. + if n == 1 { + return + } + + // Assign all pairs a success result except the final hop, as + // the payment reached the destination correctly. + i.successPairRange(route, 0, n-2) + default: // All other errors are considered terminal if coming from the // final hop. They indicate that something is wrong at the diff --git a/routing/result_interpretation_test.go b/routing/result_interpretation_test.go index 42f3ec87..a5ed7989 100644 --- a/routing/result_interpretation_test.go +++ b/routing/result_interpretation_test.go @@ -272,6 +272,39 @@ var resultTestCases = []resultTestCase{ nodeFailure: &hops[1], }, }, + + // Tests a single hop mpp timeout. Test that final node is not + // penalized. This is a temporary measure while we decide how to + // penalize mpp timeouts. + { + name: "one hop mpp timeout", + route: &routeOneHop, + failureSrcIdx: 1, + failure: &lnwire.FailMPPTimeout{}, + + expectedResult: &interpretedResult{ + finalFailureReason: &reasonError, + nodeFailure: nil, + }, + }, + + // Tests a two hop mpp timeout. Test that final node is not penalized + // and the intermediate hop is attributed the success. This is a + // temporary measure while we decide how to penalize mpp timeouts. + { + name: "two hop mpp timeout", + route: &routeTwoHop, + failureSrcIdx: 2, + failure: &lnwire.FailMPPTimeout{}, + + expectedResult: &interpretedResult{ + pairResults: map[DirectedNodePair]pairResult{ + getTestPair(0, 1): successPairResult(100), + }, + finalFailureReason: &reasonError, + nodeFailure: nil, + }, + }, } // TestResultInterpretation executes a list of test cases that test the result