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:
carla committed 2021-04-23 08:39:45 +02:00
1 parent 12136a97a9
commit 58d95be4dd
4 files changed
+14 -17

No files matched your search

+4 -4
View File
@@ -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,