channeldb: add k/v implementation for InvoiceDB.FetchPendingInvoices

This commit is contained in:
Andras Banki-Horvath
2023-10-10 18:41:06 +02:00
parent ad5cd9c8bb
commit 1f8065de35
4 changed files with 127 additions and 0 deletions

View File

@@ -56,6 +56,11 @@ type InvoiceDB interface {
ScanInvoices(ctx context.Context, scanFunc InvScanFunc,
reset func()) error
// FetchPendingInvoices returns all invoices that have not yet been
// settled or canceled.
FetchPendingInvoices(ctx context.Context) (map[lntypes.Hash]Invoice,
error)
// QueryInvoices allows a caller to query the invoice database for
// invoices within the specified add index range.
QueryInvoices(ctx context.Context, q InvoiceQuery) (InvoiceSlice, error)

View File

@@ -1,6 +1,8 @@
package invoices
import (
"context"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/stretchr/testify/mock"
)
@@ -55,6 +57,13 @@ func (m *MockInvoiceDB) ScanInvoices(scanFunc InvScanFunc,
return args.Error(0)
}
func (m *MockInvoiceDB) FetchPendingInvoices(ctx context.Context) (
map[lntypes.Hash]Invoice, error) {
args := m.Called(ctx)
return args.Get(0).(map[lntypes.Hash]Invoice), args.Error(1)
}
func (m *MockInvoiceDB) QueryInvoices(q InvoiceQuery) (InvoiceSlice, error) {
args := m.Called(q)
invoiceSlice, _ := args.Get(0).(InvoiceSlice)