mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 22:22:36 +02:00
routing/test: add test to demonstrate stuck payment, single shard
This commit adds a test which demonstrates that payments can get stuck if we receive a payment failure while we're pathfinding for another shard, then try to dispatch a shard after we've recorded a permanent failure. It also updates our mock to only consider payments with no in-flight htlcs as in-flight, to more closely represent our actual RegisterAttempt.
This commit is contained in:
@ -615,6 +615,41 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
||||
},
|
||||
paymentErr: channeldb.FailureReasonPaymentDetails,
|
||||
},
|
||||
{
|
||||
// A MP payment scenario when our path finding returns
|
||||
// after we've just received a terminal failure, and
|
||||
// demonstrates a bug where the payment will return with
|
||||
// and "unexpected" ErrPaymentAlreadyFailed rather than
|
||||
// failing with a permanent error. This results in the
|
||||
// payment getting stuck.
|
||||
name: "MP path found after failure",
|
||||
|
||||
steps: []string{
|
||||
routerInitPayment,
|
||||
|
||||
// shard 0
|
||||
routeRelease,
|
||||
routerRegisterAttempt,
|
||||
sendToSwitchSuccess,
|
||||
|
||||
// The first shard fail with a terminal error.
|
||||
getPaymentResultTerminalFailure,
|
||||
routerFailAttempt,
|
||||
routerFailPayment,
|
||||
|
||||
// shard 1 fails because we've had a terminal
|
||||
// failure.
|
||||
routeRelease,
|
||||
routerRegisterAttempt,
|
||||
|
||||
// Payment fails.
|
||||
paymentError,
|
||||
},
|
||||
routes: []*route.Route{
|
||||
shard, shard,
|
||||
},
|
||||
paymentErr: channeldb.ErrPaymentAlreadyFailed,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Reference in New Issue
Block a user