channeldb: ensure invoices can't be added with HTLCs

This commit is contained in:
Conner Fromknecht committed 2021-03-03 16:26:43 -08:00
1 parent b2234703f6
commit da049ebcf7
2 files changed
+27

No files matched your search

+18
View File
@@ -1304,6 +1304,24 @@ func TestHTLCSet(t *testing.T) {
}
}
// TestAddInvoiceWithHTLCs asserts that you can't insert an invoice that already
// has HTLCs.
func TestAddInvoiceWithHTLCs(t *testing.T) {
db, cleanUp, err := MakeTestDB()
defer cleanUp()
require.Nil(t, err)
testInvoice, err := randInvoice(1000)
require.Nil(t, err)
key := CircuitKey{HtlcID: 1}
testInvoice.Htlcs[key] = &InvoiceHTLC{}
payHash := testInvoice.Terms.PaymentPreimage.Hash()
_, err = db.AddInvoice(testInvoice, payHash)
require.Equal(t, ErrInvoiceHasHtlcs, err)
}
// TestDeleteInvoices tests that deleting a list of invoices will succeed
// if all delete references are valid, or will fail otherwise.
func TestDeleteInvoices(t *testing.T) {