From 1987b1a4ea3c0e3d949d35aad5ae0cb80f755487 Mon Sep 17 00:00:00 2001 From: withtimezone Date: Mon, 20 Oct 2025 15:35:56 +0800 Subject: [PATCH] refactor: replace context.WithCancel with t.Context Signed-off-by: withtimezone --- eth/blockwatch/block_watcher_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/eth/blockwatch/block_watcher_test.go b/eth/blockwatch/block_watcher_test.go index 12c41d0556..9206d4b0ba 100644 --- a/eth/blockwatch/block_watcher_test.go +++ b/eth/blockwatch/block_watcher_test.go @@ -199,8 +199,7 @@ func TestGetMissedEventsToBackfillSomeMissed(t *testing.T) { config.Client = fakeClient watcher := New(config) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() events, err := watcher.getMissedEventsToBackfill(ctx, nil) require.NoError(t, err) assert.Len(t, events, 2) @@ -231,8 +230,7 @@ func TestGetMissedEventsToBackfillNoneMissed(t *testing.T) { config.Client = fakeClient watcher := New(config) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() events, err := watcher.getMissedEventsToBackfill(ctx, nil) require.NoError(t, err) assert.Len(t, events, 0) @@ -257,8 +255,7 @@ func TestGetMissedEventsToBackfill_NOOP(t *testing.T) { config.Client = fakeClient watcher := New(config) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() events, err := watcher.getMissedEventsToBackfill(ctx, nil) require.NoError(t, err) assert.Len(t, events, 1) @@ -487,8 +484,7 @@ func TestGetLogsInBlockRange(t *testing.T) { config.Store = &stubMiniHeaderStore{} - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() for _, testCase := range testCases { fakeLogClient, err := newFakeLogClient(testCase.RangeToFilterLogsResponse)