Merge pull request #8712 from djkazic/invoice-gc-noop

invoices: if there are no invoices make gc noop
This commit is contained in:
Oliver Gugger 2024-05-01 08:31:56 +02:00 committed by GitHub
commit fb632bb945
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -2139,14 +2139,14 @@ func (d *DB) DeleteCanceledInvoices(_ context.Context) error {
invoiceIndexBucket,
)
if invoiceIndex == nil {
return invpkg.ErrNoInvoicesCreated
return nil
}
invoiceAddIndex := invoices.NestedReadWriteBucket(
addIndexBucket,
)
if invoiceAddIndex == nil {
return invpkg.ErrNoInvoicesCreated
return nil
}
payAddrIndex := tx.ReadWriteBucket(payAddrIndexBucket)

View File

@ -2681,8 +2681,11 @@ func testDeleteCanceledInvoices(t *testing.T,
}, nil
}
// Add some invoices to the test db.
// Test deletion of canceled invoices when there are none.
ctxb := context.Background()
require.NoError(t, db.DeleteCanceledInvoices(ctxb))
// Add some invoices to the test db.
var invoices []invpkg.Invoice
for i := 0; i < 10; i++ {
invoice, err := randInvoice(lnwire.MilliSatoshi(i + 1))