Skip to content

test(pruner): use t.Context() in test functions#3077

Merged
julienrbrt merged 3 commits intojulien/pruning-2from
copilot/update-test-context-and-add-regression-test
Feb 17, 2026
Merged

test(pruner): use t.Context() in test functions#3077
julienrbrt merged 3 commits intojulien/pruning-2from
copilot/update-test-context-and-add-regression-test

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Overview

Implements review feedback from PR #3075:

Context usage: Replaced context.Background() with t.Context() in TestPrunerPruneMetadata, TestPrunerPruneBlocksWithoutDA, and TestPrunerPruneBlocksWithDAEnabled for proper test lifecycle management.

This change ensures tests can be properly cancelled and follows Go testing best practices by using the test-scoped context instead of a background context.

Original prompt

Overview

Implement the review comments from @alpe on PR #3075 (#3075).

Required Changes

1. Update test context usage in block/internal/pruner/pruner_test.go

In both TestPrunerPruneBlocksWithoutDA and TestPrunerPruneBlocksWithDAEnabled functions:

  • Replace ctx := context.Background() with ctx := t.Context()
  • This applies to line 70 in TestPrunerPruneBlocksWithoutDA and the corresponding line in TestPrunerPruneBlocksWithDAEnabled

Reference: #3075 (comment)

2. Add regression test for store height < DA inclusion height

Add a new test function TestPrunerPruneBlocksWithDAWhenStoreHeightLessThanDAHeight (or similar name) in block/internal/pruner/pruner_test.go that tests the scenario where:

  • DA is enabled (non-empty DA address)
  • Store height is LESS than DA inclusion height
  • This is a regression test to ensure proper pruning behavior in this edge case

The test should:

  1. Create blocks (e.g., up to height 100)
  2. Set a DA inclusion height that is HIGHER than some store height (e.g., DA inclusion height = 150, store height = 100)
  3. Verify that pruning works correctly and respects the minimum of (store height, DA inclusion height)
  4. Use t.Context() instead of context.Background()

Reference: #3075 (comment)

Implementation Notes

  • Follow the existing test patterns in the file
  • Use t.Parallel() for the new test
  • Use t.Context() for context creation
  • Ensure proper error handling and assertions
  • Add clear comments explaining the test scenario

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

… regression test

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
Copilot AI changed the title [WIP] Update test context in pruner tests and add regression test test(pruner): use t.Context() and add regression test for DA height edge case Feb 17, 2026
Copilot AI requested a review from julienrbrt February 17, 2026 08:54
}

// TestPrunerPruneBlocksWithDAWhenStoreHeightLessThanDAHeight is a regression test that verifies
// pruning behavior when DA is enabled and store height is less than DA inclusion height.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot such state gap isn't possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct - removed the invalid test in 793ad72. DA inclusion height can only advance after GetBlockData(nextHeight) succeeds, so it can never exceed store height.

…ore height

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
Copilot AI changed the title test(pruner): use t.Context() and add regression test for DA height edge case test(pruner): use t.Context() in test functions Feb 17, 2026
Copilot AI requested a review from julienrbrt February 17, 2026 08:58
@julienrbrt julienrbrt marked this pull request as ready for review February 17, 2026 09:28
@julienrbrt julienrbrt merged commit 72f7c6c into julien/pruning-2 Feb 17, 2026
2 of 3 checks passed
@julienrbrt julienrbrt deleted the copilot/update-test-context-and-add-regression-test branch February 17, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants