mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2025-12-18 14:44:22 +01:00
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:
@@ -35,7 +35,10 @@ func TestHtlcIncomingResolverFwdPreimageKnown(t *testing.T) {
|
||||
defer timeout(t)()
|
||||
|
||||
ctx := newIncomingResolverTestContext(t)
|
||||
ctx.registry.notifyErr = channeldb.ErrInvoiceNotFound
|
||||
ctx.registry.notifyResolution = invoices.NewFailureResolution(
|
||||
testResCircuitKey, testHtlcExpiry,
|
||||
invoices.ResultInvoiceNotFound,
|
||||
)
|
||||
ctx.witnessBeacon.lookupPreimage[testResHash] = testResPreimage
|
||||
ctx.resolve()
|
||||
ctx.waitForResult(true)
|
||||
@@ -49,7 +52,10 @@ func TestHtlcIncomingResolverFwdContestedSuccess(t *testing.T) {
|
||||
defer timeout(t)()
|
||||
|
||||
ctx := newIncomingResolverTestContext(t)
|
||||
ctx.registry.notifyErr = channeldb.ErrInvoiceNotFound
|
||||
ctx.registry.notifyResolution = invoices.NewFailureResolution(
|
||||
testResCircuitKey, testHtlcExpiry,
|
||||
invoices.ResultInvoiceNotFound,
|
||||
)
|
||||
ctx.resolve()
|
||||
|
||||
// Simulate a new block coming in. HTLC is not yet expired.
|
||||
@@ -66,7 +72,10 @@ func TestHtlcIncomingResolverFwdContestedTimeout(t *testing.T) {
|
||||
defer timeout(t)()
|
||||
|
||||
ctx := newIncomingResolverTestContext(t)
|
||||
ctx.registry.notifyErr = channeldb.ErrInvoiceNotFound
|
||||
ctx.registry.notifyResolution = invoices.NewFailureResolution(
|
||||
testResCircuitKey, testHtlcExpiry,
|
||||
invoices.ResultInvoiceNotFound,
|
||||
)
|
||||
ctx.resolve()
|
||||
|
||||
// Simulate a new block coming in. HTLC expires.
|
||||
@@ -82,8 +91,10 @@ func TestHtlcIncomingResolverFwdTimeout(t *testing.T) {
|
||||
defer timeout(t)()
|
||||
|
||||
ctx := newIncomingResolverTestContext(t)
|
||||
|
||||
ctx.registry.notifyErr = channeldb.ErrInvoiceNotFound
|
||||
ctx.registry.notifyResolution = invoices.NewFailureResolution(
|
||||
testResCircuitKey, testHtlcExpiry,
|
||||
invoices.ResultInvoiceNotFound,
|
||||
)
|
||||
ctx.witnessBeacon.lookupPreimage[testResHash] = testResPreimage
|
||||
ctx.resolver.htlcExpiry = 90
|
||||
ctx.resolve()
|
||||
|
||||
Reference in New Issue
Block a user