multi: change RegisterAttempt error checking order
Move our more generic terminal check forward so that we only need to handle a single class of expected errors. This change is mirrored in our mock, and our reproducing tests are updated to assert that this move catches both classes of errors we get.
This commit is contained in:
4 files changed
+14
-17
No files matched your search
@@ -325,6 +325,10 @@ func (m *mockControlTower) RegisterAttempt(phash lntypes.Hash,
|
||||
_, settled := m.successful[phash]
|
||||
_, failed := m.failed[phash]
|
||||
|
||||
if settled || failed {
|
||||
return channeldb.ErrPaymentTerminal
|
||||
}
|
||||
|
||||
if settled && !inFlight {
|
||||
return channeldb.ErrPaymentAlreadySucceeded
|
||||
}
|
||||
@@ -333,10 +337,6 @@ func (m *mockControlTower) RegisterAttempt(phash lntypes.Hash,
|
||||
return channeldb.ErrPaymentAlreadyFailed
|
||||
}
|
||||
|
||||
if settled || failed {
|
||||
return channeldb.ErrPaymentTerminal
|
||||
}
|
||||
|
||||
// Add attempt to payment.
|
||||
p.attempts = append(p.attempts, channeldb.HTLCAttempt{
|
||||
HTLCAttemptInfo: *a,
|
||||
|
||||
@@ -619,7 +619,7 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
||||
// 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
|
||||
// and "unexpected" ErrPaymentTerminal rather than
|
||||
// failing with a permanent error. This results in the
|
||||
// payment getting stuck.
|
||||
name: "MP path found after failure",
|
||||
@@ -648,7 +648,7 @@ func TestRouterPaymentStateMachine(t *testing.T) {
|
||||
routes: []*route.Route{
|
||||
shard, shard,
|
||||
},
|
||||
paymentErr: channeldb.ErrPaymentAlreadyFailed,
|
||||
paymentErr: channeldb.ErrPaymentTerminal,
|
||||
},
|
||||
{
|
||||
// A MP payment scenario when our path finding returns
|
||||
|
||||
Reference in new issue
Block a user