testing: epoch range support for test builds and minor refactors to use them#7347
Merged
cylewitruk-stacks merged 3 commits intoJul 9, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes test-only epoch gating helpers by leveraging Rust’s standard Range/RangeBounds syntax for StacksEpochId, replacing the prior bespoke helpers and refactoring test call sites accordingly.
Changes:
- Introduces a test-only
StacksEpochRangeTestExttrait to convertStacksEpochIdranges (and otherRangeBounds) into&'static [StacksEpochId]via.as_slice()/.iter(). - Adds test-only ergonomics on
StacksEpochId(all_after,first,last) and unit tests covering range behaviors. - Refactors multiple test suites/macros to use range syntax instead of
StacksEpochId::since/between.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| stackslib/src/chainstate/tests/static_analysis_tests.rs | Updates deploy-epoch gating in static analysis tests to use range .as_slice(). |
| stackslib/src/chainstate/tests/runtime_tests.rs | Migrates runtime tests from since/between helpers to range-based epoch slices. |
| stackslib/src/chainstate/tests/runtime_analysis_tests.rs | Refactors runtime analysis tests to use range-based epoch gating slices. |
| stackslib/src/chainstate/tests/consensus.rs | Refactors consensus test macros to default deploy epochs via range-to-slice conversion and reduces variable shadowing risk. |
| stackslib/src/chainstate/tests/consensus_unit_tests.rs | Updates example consensus unit tests to use range .as_slice(). |
| stacks-common/src/types/tests.rs | Adds coverage for the new range extension behavior and first/last helpers. |
| stacks-common/src/types/mod.rs | Implements test-only range extension trait and adds StacksEpochId test helpers (all_after, first, last). |
| clarity/src/vm/tests/epoch_gating.rs | Updates epoch gating test to use range .as_slice() instead of since. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…h-id-range-ops-for-testing
Coverage Report for CI Build 28974827599Coverage increased (+0.5%) to 86.206%Details
Uncovered Changes
Coverage Regressions9238 previously-covered lines in 138 files lost coverage.
Coverage Stats
💛 - Coveralls |
federico-stacks
approved these changes
Jun 26, 2026
Merged
via the queue into
stacks-network:develop
with commit Jul 9, 2026
3f6771a
411 of 414 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds standard Rust
Range/RangeBoundsoperator support forStacksEpochIdfor test builds, replacing the explicit semantic functions:StacksEpochId::between(start, end)=(start..=end)StacksEpochId::since(epoch)=(start..)And adding:
StacksEpochId::all_after(epoch)- exclusive "after" for when future epochs aren't knownfirst()andlast(), aliases forALL.first()/last()but without theOption, for ergonomics.Just something that was nagging at me since Rust provides us with pretty expressive range syntax without needing to roll our own. There's similar use cases for e.g.
ClarityVersionetc., but just didStacksEpochIdhere.Also did some minor naming refactoring in the
contract_call_consensus_unit_test!macro as the expanded code shadowed the same variable at multiple layers, which was a bit difficult to read.Checklist