multi: replace errInvoiceNotFound with resolution result
This commit moves handling of invoice not found errors into NotifyExitHopHtlc and exposes a resolution result to the calling functions. The intention of this change is to make calling functions as naive of the invoice registry's mechanics as possible. When NotifyExitHopHtlc is called and an invoice is not found, calling functions can take action based on the HtlcResolution's InvoiceNotFound outcome rather than having to add a special error check on every call to handle the error.
This commit is contained in:
6 files changed
+54
-36
No files matched your search
@@ -585,12 +585,16 @@ func TestUnknownInvoice(t *testing.T) {
|
||||
// succeed.
|
||||
hodlChan := make(chan interface{})
|
||||
amt := lnwire.MilliSatoshi(100000)
|
||||
_, err := ctx.registry.NotifyExitHopHtlc(
|
||||
result, err := ctx.registry.NotifyExitHopHtlc(
|
||||
testInvoicePaymentHash, amt, testHtlcExpiry, testCurrentHeight,
|
||||
getCircuitKey(0), hodlChan, testPayload,
|
||||
)
|
||||
if err != channeldb.ErrInvoiceNotFound {
|
||||
t.Fatal("expected invoice not found error")
|
||||
if err != nil {
|
||||
t.Fatal("unexpected error")
|
||||
}
|
||||
if result.Outcome != ResultInvoiceNotFound {
|
||||
t.Fatalf("expected ResultInvoiceNotFound, got: %v",
|
||||
result.Outcome)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user