routing/router_test: add test case for ForwardingError on SendHTLC
This commit is contained in:
parent
589f0fcc5d
commit
649ee875fd
@ -2601,6 +2601,12 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
|||||||
// attempt was successfully forwarded.
|
// attempt was successfully forwarded.
|
||||||
sendToSwitchSuccess = "SendToSwitch:success"
|
sendToSwitchSuccess = "SendToSwitch:success"
|
||||||
|
|
||||||
|
// sendToSwitchResultFailure is a step where we expect the
|
||||||
|
// router to send the payment attempt to the switch, and we
|
||||||
|
// will respond with a forwarding error. This can happen when
|
||||||
|
// forwarding fail on our local links.
|
||||||
|
sendToSwitchResultFailure = "SendToSwitch:failure"
|
||||||
|
|
||||||
// getPaymentResultSuccess is a test step where we expect the
|
// getPaymentResultSuccess is a test step where we expect the
|
||||||
// router to call the GetPaymentResult method, and we will
|
// router to call the GetPaymentResult method, and we will
|
||||||
// respond with a successful payment result.
|
// respond with a successful payment result.
|
||||||
@ -2677,6 +2683,28 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
|||||||
},
|
},
|
||||||
routes: []*route.Route{rt, rt},
|
routes: []*route.Route{rt, rt},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// A payment flow with a forwarding failure first time
|
||||||
|
// sending to the switch, but that succeeds on the
|
||||||
|
// second attempt.
|
||||||
|
steps: []string{
|
||||||
|
routerInitPayment,
|
||||||
|
routerRegisterAttempt,
|
||||||
|
|
||||||
|
// Make the first sent attempt fail.
|
||||||
|
sendToSwitchResultFailure,
|
||||||
|
|
||||||
|
// The router should retry.
|
||||||
|
routerRegisterAttempt,
|
||||||
|
sendToSwitchSuccess,
|
||||||
|
|
||||||
|
// Make the second sent attempt succeed.
|
||||||
|
getPaymentResultSuccess,
|
||||||
|
routerSuccess,
|
||||||
|
paymentSuccess,
|
||||||
|
},
|
||||||
|
routes: []*route.Route{rt, rt},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// A payment that fails on the first attempt, and has
|
// A payment that fails on the first attempt, and has
|
||||||
// only one route available to try. It will therefore
|
// only one route available to try. It will therefore
|
||||||
@ -2982,6 +3010,18 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
|||||||
t.Fatalf("unable to send result")
|
t.Fatalf("unable to send result")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In this step we expect the SendToSwitch method to be
|
||||||
|
// called, and we respond with a forwarding error
|
||||||
|
case sendToSwitchResultFailure:
|
||||||
|
select {
|
||||||
|
case sendResult <- &htlcswitch.ForwardingError{
|
||||||
|
ErrorSource: errSource,
|
||||||
|
FailureMessage: &lnwire.FailTemporaryChannelFailure{},
|
||||||
|
}:
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
t.Fatalf("unable to send result")
|
||||||
|
}
|
||||||
|
|
||||||
// In this step we expect the GetPaymentResult method
|
// In this step we expect the GetPaymentResult method
|
||||||
// to be called, and we respond with the preimage to
|
// to be called, and we respond with the preimage to
|
||||||
// complete the payment.
|
// complete the payment.
|
||||||
|
Loading…
Reference in New Issue
Block a user