invoice/test: make all tests parallel
When we have tests using global variables and a mix of parallel and non-parallel tests, odd races can appear when we run them.
This commit is contained in:
1 file changed
+22
@@ -19,6 +19,8 @@ import (
|
|||||||
|
|
||||||
// TestSettleInvoice tests settling of an invoice and related notifications.
|
// TestSettleInvoice tests settling of an invoice and related notifications.
|
||||||
func TestSettleInvoice(t *testing.T) {
|
func TestSettleInvoice(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
ctx := newTestContext(t, nil)
|
ctx := newTestContext(t, nil)
|
||||||
|
|
||||||
allSubscriptions, err := ctx.registry.SubscribeNotifications(0, 0)
|
allSubscriptions, err := ctx.registry.SubscribeNotifications(0, 0)
|
||||||
@@ -194,6 +196,8 @@ func TestSettleInvoice(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testCancelInvoice(t *testing.T, gc bool) {
|
func testCancelInvoice(t *testing.T, gc bool) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
cfg := defaultRegistryConfig()
|
cfg := defaultRegistryConfig()
|
||||||
|
|
||||||
// If set to true, then also delete the invoice from the DB after
|
// If set to true, then also delete the invoice from the DB after
|
||||||
@@ -326,6 +330,8 @@ func testCancelInvoice(t *testing.T, gc bool) {
|
|||||||
|
|
||||||
// TestCancelInvoice tests cancellation of an invoice and related notifications.
|
// TestCancelInvoice tests cancellation of an invoice and related notifications.
|
||||||
func TestCancelInvoice(t *testing.T) {
|
func TestCancelInvoice(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
// Test cancellation both with garbage collection (meaning that canceled
|
// Test cancellation both with garbage collection (meaning that canceled
|
||||||
// invoice will be deleted) and without (meaning it'll be kept).
|
// invoice will be deleted) and without (meaning it'll be kept).
|
||||||
t.Run("garbage collect", func(t *testing.T) {
|
t.Run("garbage collect", func(t *testing.T) {
|
||||||
@@ -340,6 +346,7 @@ func TestCancelInvoice(t *testing.T) {
|
|||||||
// TestSettleHoldInvoice tests settling of a hold invoice and related
|
// TestSettleHoldInvoice tests settling of a hold invoice and related
|
||||||
// notifications.
|
// notifications.
|
||||||
func TestSettleHoldInvoice(t *testing.T) {
|
func TestSettleHoldInvoice(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
defer timeout()()
|
defer timeout()()
|
||||||
|
|
||||||
idb, err := newTestChannelDB(t, clock.NewTestClock(time.Time{}))
|
idb, err := newTestChannelDB(t, clock.NewTestClock(time.Time{}))
|
||||||
@@ -513,6 +520,7 @@ func TestSettleHoldInvoice(t *testing.T) {
|
|||||||
// TestCancelHoldInvoice tests canceling of a hold invoice and related
|
// TestCancelHoldInvoice tests canceling of a hold invoice and related
|
||||||
// notifications.
|
// notifications.
|
||||||
func TestCancelHoldInvoice(t *testing.T) {
|
func TestCancelHoldInvoice(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
defer timeout()()
|
defer timeout()()
|
||||||
|
|
||||||
testClock := clock.NewTestClock(testTime)
|
testClock := clock.NewTestClock(testTime)
|
||||||
@@ -593,6 +601,7 @@ func TestCancelHoldInvoice(t *testing.T) {
|
|||||||
// if we are the exit hop, but in htlcIncomingContestResolver it is called with
|
// if we are the exit hop, but in htlcIncomingContestResolver it is called with
|
||||||
// forwarded htlc hashes as well.
|
// forwarded htlc hashes as well.
|
||||||
func TestUnknownInvoice(t *testing.T) {
|
func TestUnknownInvoice(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
ctx := newTestContext(t, nil)
|
ctx := newTestContext(t, nil)
|
||||||
|
|
||||||
// Notify arrival of a new htlc paying to this invoice. This should
|
// Notify arrival of a new htlc paying to this invoice. This should
|
||||||
@@ -613,6 +622,8 @@ func TestUnknownInvoice(t *testing.T) {
|
|||||||
// TestKeySend tests receiving a spontaneous payment with and without keysend
|
// TestKeySend tests receiving a spontaneous payment with and without keysend
|
||||||
// enabled.
|
// enabled.
|
||||||
func TestKeySend(t *testing.T) {
|
func TestKeySend(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("enabled", func(t *testing.T) {
|
t.Run("enabled", func(t *testing.T) {
|
||||||
testKeySend(t, true)
|
testKeySend(t, true)
|
||||||
})
|
})
|
||||||
@@ -624,6 +635,7 @@ func TestKeySend(t *testing.T) {
|
|||||||
// testKeySend is the inner test function that tests keysend for a particular
|
// testKeySend is the inner test function that tests keysend for a particular
|
||||||
// enabled state on the receiver end.
|
// enabled state on the receiver end.
|
||||||
func testKeySend(t *testing.T, keySendEnabled bool) {
|
func testKeySend(t *testing.T, keySendEnabled bool) {
|
||||||
|
t.Parallel()
|
||||||
defer timeout()()
|
defer timeout()()
|
||||||
|
|
||||||
cfg := defaultRegistryConfig()
|
cfg := defaultRegistryConfig()
|
||||||
@@ -738,6 +750,8 @@ func testKeySend(t *testing.T, keySendEnabled bool) {
|
|||||||
|
|
||||||
// TestHoldKeysend tests receiving a spontaneous payment that is held.
|
// TestHoldKeysend tests receiving a spontaneous payment that is held.
|
||||||
func TestHoldKeysend(t *testing.T) {
|
func TestHoldKeysend(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("settle", func(t *testing.T) {
|
t.Run("settle", func(t *testing.T) {
|
||||||
testHoldKeysend(t, false)
|
testHoldKeysend(t, false)
|
||||||
})
|
})
|
||||||
@@ -748,6 +762,7 @@ func TestHoldKeysend(t *testing.T) {
|
|||||||
|
|
||||||
// testHoldKeysend is the inner test function that tests hold-keysend.
|
// testHoldKeysend is the inner test function that tests hold-keysend.
|
||||||
func testHoldKeysend(t *testing.T, timeoutKeysend bool) {
|
func testHoldKeysend(t *testing.T, timeoutKeysend bool) {
|
||||||
|
t.Parallel()
|
||||||
defer timeout()()
|
defer timeout()()
|
||||||
|
|
||||||
const holdDuration = time.Minute
|
const holdDuration = time.Minute
|
||||||
@@ -838,6 +853,7 @@ func testHoldKeysend(t *testing.T, timeoutKeysend bool) {
|
|||||||
// It covers the case where there is a mpp timeout before the whole invoice is
|
// It covers the case where there is a mpp timeout before the whole invoice is
|
||||||
// paid and the case where the invoice is settled in time.
|
// paid and the case where the invoice is settled in time.
|
||||||
func TestMppPayment(t *testing.T) {
|
func TestMppPayment(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
defer timeout()()
|
defer timeout()()
|
||||||
|
|
||||||
ctx := newTestContext(t, nil)
|
ctx := newTestContext(t, nil)
|
||||||
@@ -1199,6 +1215,8 @@ func TestOldInvoiceRemovalOnStart(t *testing.T) {
|
|||||||
// invoice is settled before expiry (and thus not canceled), and the case
|
// invoice is settled before expiry (and thus not canceled), and the case
|
||||||
// where the invoice is expired.
|
// where the invoice is expired.
|
||||||
func TestHeightExpiryWithRegistry(t *testing.T) {
|
func TestHeightExpiryWithRegistry(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
t.Run("single shot settled before expiry", func(t *testing.T) {
|
t.Run("single shot settled before expiry", func(t *testing.T) {
|
||||||
testHeightExpiryWithRegistry(t, 1, true)
|
testHeightExpiryWithRegistry(t, 1, true)
|
||||||
})
|
})
|
||||||
@@ -1613,6 +1631,7 @@ func TestSettleInvoicePaymentAddrRequiredOptionalGrace(t *testing.T) {
|
|||||||
// TestAMPWithoutMPPPayload asserts that we correctly reject an AMP HTLC that
|
// TestAMPWithoutMPPPayload asserts that we correctly reject an AMP HTLC that
|
||||||
// does not include an MPP record.
|
// does not include an MPP record.
|
||||||
func TestAMPWithoutMPPPayload(t *testing.T) {
|
func TestAMPWithoutMPPPayload(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
defer timeout()()
|
defer timeout()()
|
||||||
|
|
||||||
cfg := defaultRegistryConfig()
|
cfg := defaultRegistryConfig()
|
||||||
@@ -1645,6 +1664,8 @@ func TestAMPWithoutMPPPayload(t *testing.T) {
|
|||||||
// TestSpontaneousAmpPayment tests receiving a spontaneous AMP payment with both
|
// TestSpontaneousAmpPayment tests receiving a spontaneous AMP payment with both
|
||||||
// valid and invalid reconstructions.
|
// valid and invalid reconstructions.
|
||||||
func TestSpontaneousAmpPayment(t *testing.T) {
|
func TestSpontaneousAmpPayment(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
ampEnabled bool
|
ampEnabled bool
|
||||||
@@ -1698,6 +1719,7 @@ func TestSpontaneousAmpPayment(t *testing.T) {
|
|||||||
func testSpontaneousAmpPayment(
|
func testSpontaneousAmpPayment(
|
||||||
t *testing.T, ampEnabled, failReconstruction bool, numShards int) {
|
t *testing.T, ampEnabled, failReconstruction bool, numShards int) {
|
||||||
|
|
||||||
|
t.Parallel()
|
||||||
defer timeout()()
|
defer timeout()()
|
||||||
|
|
||||||
cfg := defaultRegistryConfig()
|
cfg := defaultRegistryConfig()
|
||||||
|
|||||||
Reference in new issue
Block a user