mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-05 17:05:50 +02:00
multi: replace defer cleanup with t.Cleanup
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -149,8 +149,7 @@ func TestInvoiceWorkflow(t *testing.T) {
|
||||
}
|
||||
|
||||
func testInvoiceWorkflow(t *testing.T, test invWorkflowTest) {
|
||||
db, cleanUp, err := MakeTestDB()
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
// Create a fake invoice which we'll use several times in the tests
|
||||
@@ -293,8 +292,7 @@ func testInvoiceWorkflow(t *testing.T, test invWorkflowTest) {
|
||||
// TestAddDuplicatePayAddr asserts that the payment addresses of inserted
|
||||
// invoices are unique.
|
||||
func TestAddDuplicatePayAddr(t *testing.T) {
|
||||
db, cleanUp, err := MakeTestDB()
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Create two invoices with the same payment addr.
|
||||
@@ -320,8 +318,7 @@ func TestAddDuplicatePayAddr(t *testing.T) {
|
||||
// addresses to be inserted if they are blank to support JIT legacy keysend
|
||||
// invoices.
|
||||
func TestAddDuplicateKeysendPayAddr(t *testing.T) {
|
||||
db, cleanUp, err := MakeTestDB()
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Create two invoices with the same _blank_ payment addr.
|
||||
@@ -363,8 +360,7 @@ func TestAddDuplicateKeysendPayAddr(t *testing.T) {
|
||||
// ensures that the HTLC's payment hash always matches the payment hash in the
|
||||
// returned invoice.
|
||||
func TestFailInvoiceLookupMPPPayAddrOnly(t *testing.T) {
|
||||
db, cleanUp, err := MakeTestDB()
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Create and insert a random invoice.
|
||||
@@ -391,8 +387,7 @@ func TestFailInvoiceLookupMPPPayAddrOnly(t *testing.T) {
|
||||
// TestInvRefEquivocation asserts that retrieving or updating an invoice using
|
||||
// an equivocating InvoiceRef results in ErrInvRefEquivocation.
|
||||
func TestInvRefEquivocation(t *testing.T) {
|
||||
db, cleanUp, err := MakeTestDB()
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Add two random invoices.
|
||||
@@ -431,8 +426,7 @@ func TestInvRefEquivocation(t *testing.T) {
|
||||
func TestInvoiceCancelSingleHtlc(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanUp, err := MakeTestDB()
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
preimage := lntypes.Preimage{1}
|
||||
@@ -499,8 +493,7 @@ func TestInvoiceCancelSingleHtlc(t *testing.T) {
|
||||
func TestInvoiceCancelSingleHtlcAMP(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanUp, err := MakeTestDB(OptionClock(testClock))
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t, OptionClock(testClock))
|
||||
require.NoError(t, err, "unable to make test db: %v", err)
|
||||
|
||||
// We'll start out by creating an invoice and writing it to the DB.
|
||||
@@ -656,8 +649,7 @@ func TestInvoiceCancelSingleHtlcAMP(t *testing.T) {
|
||||
func TestInvoiceAddTimeSeries(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanUp, err := MakeTestDB(OptionClock(testClock))
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t, OptionClock(testClock))
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
_, err = db.InvoicesAddedSince(0)
|
||||
@@ -812,8 +804,7 @@ func TestSettleIndexAmpPayments(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testClock := clock.NewTestClock(testNow)
|
||||
db, cleanUp, err := MakeTestDB(OptionClock(testClock))
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t, OptionClock(testClock))
|
||||
require.Nil(t, err)
|
||||
|
||||
// First, we'll make a sample invoice that'll be paid to several times
|
||||
@@ -969,8 +960,7 @@ func TestSettleIndexAmpPayments(t *testing.T) {
|
||||
func TestScanInvoices(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanup, err := MakeTestDB()
|
||||
defer cleanup()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
var invoices map[lntypes.Hash]*Invoice
|
||||
@@ -1028,8 +1018,7 @@ func TestScanInvoices(t *testing.T) {
|
||||
func TestDuplicateSettleInvoice(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanUp, err := MakeTestDB(OptionClock(testClock))
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t, OptionClock(testClock))
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
// We'll start out by creating an invoice and writing it to the DB.
|
||||
@@ -1087,8 +1076,7 @@ func TestDuplicateSettleInvoice(t *testing.T) {
|
||||
func TestQueryInvoices(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanUp, err := MakeTestDB(OptionClock(testClock))
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t, OptionClock(testClock))
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
// To begin the test, we'll add 50 invoices to the database. We'll
|
||||
@@ -1400,8 +1388,7 @@ func getUpdateInvoice(amt lnwire.MilliSatoshi) InvoiceUpdateCallback {
|
||||
func TestCustomRecords(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanUp, err := MakeTestDB()
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
preimage := lntypes.Preimage{1}
|
||||
@@ -1470,8 +1457,7 @@ func TestInvoiceHtlcAMPFields(t *testing.T) {
|
||||
}
|
||||
|
||||
func testInvoiceHtlcAMPFields(t *testing.T, isAMP bool) {
|
||||
db, cleanUp, err := MakeTestDB()
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t)
|
||||
require.Nil(t, err)
|
||||
|
||||
testInvoice, err := randInvoice(1000)
|
||||
@@ -1652,8 +1638,7 @@ 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()
|
||||
db, err := MakeTestDB(t)
|
||||
require.Nil(t, err)
|
||||
|
||||
testInvoice, err := randInvoice(1000)
|
||||
@@ -1672,8 +1657,7 @@ func TestAddInvoiceWithHTLCs(t *testing.T) {
|
||||
// that invoices with duplicate set ids are disallowed.
|
||||
func TestSetIDIndex(t *testing.T) {
|
||||
testClock := clock.NewTestClock(testNow)
|
||||
db, cleanUp, err := MakeTestDB(OptionClock(testClock))
|
||||
defer cleanUp()
|
||||
db, err := MakeTestDB(t, OptionClock(testClock))
|
||||
require.Nil(t, err)
|
||||
|
||||
// We'll start out by creating an invoice and writing it to the DB.
|
||||
@@ -1983,8 +1967,7 @@ func getUpdateInvoiceAMPSettle(setID *[32]byte,
|
||||
func TestUnexpectedInvoicePreimage(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanup, err := MakeTestDB()
|
||||
defer cleanup()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
invoice, err := randInvoice(lnwire.MilliSatoshi(100))
|
||||
@@ -2040,8 +2023,7 @@ func TestUpdateHTLCPreimages(t *testing.T) {
|
||||
}
|
||||
|
||||
func testUpdateHTLCPreimages(t *testing.T, test updateHTLCPreimageTestCase) {
|
||||
db, cleanup, err := MakeTestDB()
|
||||
defer cleanup()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
// We'll start out by creating an invoice and writing it to the DB.
|
||||
@@ -2772,8 +2754,7 @@ func testUpdateHTLC(t *testing.T, test updateHTLCTest) {
|
||||
func TestDeleteInvoices(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanup, err := MakeTestDB()
|
||||
defer cleanup()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
|
||||
// Add some invoices to the test db.
|
||||
@@ -2856,9 +2837,8 @@ func TestDeleteInvoices(t *testing.T) {
|
||||
func TestAddInvoiceInvalidFeatureDeps(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db, cleanup, err := MakeTestDB()
|
||||
db, err := MakeTestDB(t)
|
||||
require.NoError(t, err, "unable to make test db")
|
||||
defer cleanup()
|
||||
|
||||
invoice, err := randInvoice(500)
|
||||
require.NoError(t, err)
|
||||
|
Reference in New Issue
Block a user