invoices: remove the global mock htlcModifierMock

This can create race in the tests.
This commit is contained in:
yyforyongyu
2025-07-14 13:44:45 +08:00
parent 6b326152d4
commit 5d0c787856

View File

@@ -24,12 +24,6 @@ import (
"github.com/stretchr/testify/require"
)
var (
// htlcModifierMock is a mock implementation of the invoice HtlcModifier
// interface.
htlcModifierMock = &invpkg.MockHtlcModifier{}
)
// TestInvoiceRegistry is a master test which encompasses all tests using an
// InvoiceDB instance. The purpose of this test is to be able to run all tests
// with a custom DB instance, so that we can test the same logic with different
@@ -541,7 +535,7 @@ func testSettleHoldInvoice(t *testing.T,
cfg := invpkg.RegistryConfig{
FinalCltvRejectDelta: testFinalCltvRejectDelta,
Clock: clock,
HtlcInterceptor: htlcModifierMock,
HtlcInterceptor: &invpkg.MockHtlcModifier{},
}
expiryWatcher := invpkg.NewInvoiceExpiryWatcher(
@@ -711,7 +705,7 @@ func testCancelHoldInvoice(t *testing.T,
cfg := invpkg.RegistryConfig{
FinalCltvRejectDelta: testFinalCltvRejectDelta,
Clock: testClock,
HtlcInterceptor: htlcModifierMock,
HtlcInterceptor: &invpkg.MockHtlcModifier{},
}
expiryWatcher := invpkg.NewInvoiceExpiryWatcher(
cfg.Clock, 0, uint32(testCurrentHeight), nil, newMockNotifier(),
@@ -1231,7 +1225,7 @@ func testInvoiceExpiryWithRegistry(t *testing.T,
cfg := invpkg.RegistryConfig{
FinalCltvRejectDelta: testFinalCltvRejectDelta,
Clock: testClock,
HtlcInterceptor: htlcModifierMock,
HtlcInterceptor: &invpkg.MockHtlcModifier{},
}
expiryWatcher := invpkg.NewInvoiceExpiryWatcher(
@@ -1342,7 +1336,7 @@ func testOldInvoiceRemovalOnStart(t *testing.T,
FinalCltvRejectDelta: testFinalCltvRejectDelta,
Clock: testClock,
GcCanceledInvoicesOnStartup: true,
HtlcInterceptor: htlcModifierMock,
HtlcInterceptor: &invpkg.MockHtlcModifier{},
}
expiryWatcher := invpkg.NewInvoiceExpiryWatcher(