headertest: unify TestSuite constructors behind functional options - #5041
Conversation
Collapse NewTestSuite, NewTestSuiteWithGenesisTime, NewTestSuiteDefaults and NewTestSuiteWithTail into a single variadic NewTestSuite(t, ...Option) with WithValidators, WithBlockTime, WithStartTime and WithTail, and migrate all call sites. Behavior is preserved (e.g. block-time spacing is kept where the old constructors relied on it for monotonic timestamps). Closes celestiaorg#4037
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors the header/headertest NewTestSuite API from positional parameters / multiple constructors to an options-based configuration, and updates call sites accordingly.
Changes:
- Introduces
Optionpattern forheadertest.NewTestSuite(e.g.,WithValidators,WithBlockTime,WithStartTime,WithTail) and removes older helper constructors. - Updates multiple tests to use the new options-based API.
- Aligns some tests to explicitly set validator count and/or block time via options.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| share/availability/full/availability_test.go | Updates NewTestSuite usage to options-based configuration. |
| pruner/service_test.go | Updates suite construction to explicitly set validators and block time. |
| header/headertest/verify_test.go | Updates verifier tests to use WithValidators option. |
| header/headertest/testing.go | Introduces options-based NewTestSuite and removes older constructors/default helpers. |
| das/daser_test.go | Replaces removed default/tail constructors with options-based NewTestSuite. |
| core/routing_exchange_test.go | Replaces removed defaults constructor with options-based NewTestSuite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review: replace the unclear WithBlockTime(1) literal (1ns) with the explicit time.Nanosecond in the migrated call sites.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5041 +/- ##
==========================================
- Coverage 44.83% 36.60% -8.24%
==========================================
Files 265 311 +46
Lines 14620 21505 +6885
==========================================
+ Hits 6555 7871 +1316
- Misses 7313 12627 +5314
- Partials 752 1007 +255 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #4037.
Unifies the four
TestSuiteconstructors (NewTestSuite,NewTestSuiteWithGenesisTime,NewTestSuiteDefaults,NewTestSuiteWithTail) into a single variadicNewTestSuite(t, ...Option)withWithValidators,WithBlockTime,WithStartTimeandWithTail, and migrates all call sites.The migration is behavior-preserving — block-time spacing is retained at the call sites where the removed constructors set it to keep generated header timestamps monotonic. Voting power is standardized (it does not affect test outcomes since every validator signs each commit).
Verified:
header/headertest,pruner,core,dasandshare/availability/fulltests pass.