multi: context.Background() -> t.Context()

Use the new feature of Go 1.24, fix linter warnings.

This change was produced by:
 - running golangci-lint run --fix
 - sed 's/context.Background/t.Context/' -i `git grep -l context.Background | grep test.go`
 - manually fixing broken tests
 - itest, lntest: use ht.Context() where ht or hn is available
 - in HarnessNode.Stop() we keep using context.Background(), because it is
   called from a cleanup handler in which t.Context() is canceled already.
This commit is contained in:
Boris Nagaev committed 2025-08-30 14:13:44 -03:00
1 parent 6ffe257004
commit dee8ad3754
71 files changed
+361 -393

No files matched your search

+2 -3
View File
@@ -121,8 +121,7 @@ func TestFetchBackupForChan(t *testing.T) {
}
for i, testCase := range testCases {
_, err := FetchBackupForChan(
context.Background(), testCase.chanPoint, chanSource,
chanSource,
t.Context(), testCase.chanPoint, chanSource, chanSource,
)
switch {
// If this is a valid test case, and we failed, then we'll
@@ -143,7 +142,7 @@ func TestFetchBackupForChan(t *testing.T) {
// channel source for all channels and construct a Single for each channel.
func TestFetchStaticChanBackups(t *testing.T) {
t.Parallel()
ctx := context.Background()
ctx := t.Context()
// First, we'll make the set of channels that we want to seed the
// channel source with. Both channels will be fully populated in the
+3 -4
View File
@@ -81,7 +81,7 @@ func (m *mockChannelNotifier) SubscribeChans(_ context.Context,
// channel subscription, then the entire sub-swapper will fail to start.
func TestNewSubSwapperSubscribeFail(t *testing.T) {
t.Parallel()
ctx := context.Background()
ctx := t.Context()
keyRing := &lnencrypt.MockKeyRing{}
@@ -159,7 +159,7 @@ func TestSubSwapperIdempotentStartStop(t *testing.T) {
swapper := newMockSwapper(keyRing)
subSwapper, err := NewSubSwapper(
context.Background(), nil, &chanNotifier, keyRing, swapper,
t.Context(), nil, &chanNotifier, keyRing, swapper,
)
require.NoError(t, err, "unable to init subSwapper")
@@ -226,8 +226,7 @@ func TestSubSwapperUpdater(t *testing.T) {
// With our channel set created, we'll make a fresh sub swapper
// instance to begin our test.
subSwapper, err := NewSubSwapper(
context.Background(), initialChanSet, chanNotifier, keyRing,
swapper,
t.Context(), initialChanSet, chanNotifier, keyRing, swapper,
)
require.NoError(t, err, "unable to make swapper")
if err := subSwapper.Start(); err != nil {