Skip to content

Commit 1251b7d

Browse files
authored
aggregator/pkg/handlers: fix post-teardown log panic (#1167)
* aggregator/pkg/handlers: fix post-teardown log panic - Replace TestSugared(t) with Nop logger in cancelled-context test; worker goroutines outlive t in Go 1.26+ and panic if they log after teardown * lint * use logger.Nop() in rest of tests
1 parent 922617e commit 1251b7d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

aggregator/pkg/handlers/batch_write_commit_verifier_node_result_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestBatchWriteCommitCCVNodeDataHandler_BatchSizeValidation(t *testing.T) {
6464
t.Run(tc.name, func(t *testing.T) {
6565
t.Parallel()
6666

67-
lggr := logger.TestSugared(t)
67+
lggr := logger.Sugared(logger.Nop())
6868
store := mocks.NewMockCommitVerificationStore(t)
6969
agg := mocks.NewMockAggregationTriggerer(t)
7070
sig := mocks.NewMockSignatureValidator(t)
@@ -119,7 +119,7 @@ func TestBatchWriteCommitCCVNodeDataHandler_MixedSuccessAndInvalidArgument(t *te
119119
const testCallerID = "test-caller"
120120
const testChannelKey model.ChannelKey = "test-caller"
121121

122-
lggr := logger.TestSugared(t)
122+
lggr := logger.Sugared(logger.Nop())
123123
store := mocks.NewMockCommitVerificationStore(t)
124124
agg := mocks.NewMockAggregationTriggerer(t)
125125

@@ -174,7 +174,7 @@ func TestBatchWriteCommitCCVNodeDataHandler_NilRequestAtIndexReturnsInvalidArgum
174174
const testCallerID = "test-caller"
175175
const testChannelKey model.ChannelKey = "test-caller"
176176

177-
lggr := logger.TestSugared(t)
177+
lggr := logger.Sugared(logger.Nop())
178178
store := mocks.NewMockCommitVerificationStore(t)
179179
agg := mocks.NewMockAggregationTriggerer(t)
180180
sig := mocks.NewMockSignatureValidator(t)
@@ -225,7 +225,10 @@ func TestBatchWriteCommitCCVNodeDataHandler_CancelledContextReturnsImmediately(t
225225
const testChannelKey model.ChannelKey = "test-caller"
226226
blockDuration := 5 * time.Second
227227

228-
lggr := logger.TestSugared(t)
228+
// Use a nop logger: worker goroutines that are still running when the context
229+
// is canceled may log after this test's *testing.T is torn down, which
230+
// panics in Go. A nop logger avoids that without changing the handler.
231+
lggr := logger.Sugared(logger.Nop())
229232
store := mocks.NewMockCommitVerificationStore(t)
230233
agg := mocks.NewMockAggregationTriggerer(t)
231234
sig := mocks.NewMockSignatureValidator(t)

0 commit comments

Comments
 (0)