channeldb: return error when payment is not initialized

This commit changes `fetchPaymentStatus` to return an error when the
payment creation info bucket cannot be found. Instead of using the
ambiguous status `StatusUnknown`, we tell the callsite explictly that
there's no such payment. This also means the vague `StatusUnknown` can
now be removed as it has multiple meanings.
This commit is contained in:
yyforyongyu
2022-11-24 12:26:17 +08:00
committed by Olaoluwa Osuntokun
parent 21cecc40e1
commit 6be3817eed
4 changed files with 40 additions and 54 deletions

View File

@@ -273,8 +273,6 @@ func TestPaymentControlSuccessesWithoutInFlight(t *testing.T) {
if err != ErrPaymentNotInitiated {
t.Fatalf("expected ErrPaymentNotInitiated, got %v", err)
}
assertPaymentStatus(t, pControl, info.PaymentIdentifier, StatusUnknown)
}
// TestPaymentControlFailsWithoutInFlight checks that a strict payment
@@ -295,8 +293,6 @@ func TestPaymentControlFailsWithoutInFlight(t *testing.T) {
if err != ErrPaymentNotInitiated {
t.Fatalf("expected ErrPaymentNotInitiated, got %v", err)
}
assertPaymentStatus(t, pControl, info.PaymentIdentifier, StatusUnknown)
}
// TestPaymentControlDeleteNonInFlight checks that calling DeletePayments only
@@ -1085,7 +1081,7 @@ func assertPaymentStatus(t *testing.T, p *PaymentControl,
t.Helper()
payment, err := p.FetchPayment(hash)
if expStatus == StatusUnknown && err == ErrPaymentNotInitiated {
if err == ErrPaymentNotInitiated {
return
}
if err != nil {