diff --git a/channeldb/invoices.go b/channeldb/invoices.go index a7663cabf6..df124b632a 100644 --- a/channeldb/invoices.go +++ b/channeldb/invoices.go @@ -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) diff --git a/invoices/invoices_test.go b/invoices/invoices_test.go index 6f3cbd8f23..c9e2045719 100644 --- a/invoices/invoices_test.go +++ b/invoices/invoices_test.go @@ -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))