Skip to content

testing: epoch range support for test builds and minor refactors to use them#7347

Merged
cylewitruk-stacks merged 3 commits into
stacks-network:developfrom
cylewitruk-stacks:feat/stacks-epoch-id-range-ops-for-testing
Jul 9, 2026
Merged

testing: epoch range support for test builds and minor refactors to use them#7347
cylewitruk-stacks merged 3 commits into
stacks-network:developfrom
cylewitruk-stacks:feat/stacks-epoch-id-range-ops-for-testing

Conversation

@cylewitruk-stacks

@cylewitruk-stacks cylewitruk-stacks commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Description

Adds standard Rust Range/RangeBounds operator support for StacksEpochId for 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 known
  • first() and last(), aliases for ALL.first()/last() but without the Option, 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. ClarityVersion etc., but just did StacksEpochId here.

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

  • Test coverage for new or modified code paths

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 StacksEpochRangeTestExt trait to convert StacksEpochId ranges (and other RangeBounds) 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.

Comment thread clarity/src/vm/tests/epoch_gating.rs
@coveralls

coveralls commented Jun 24, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28974827599

Coverage increased (+0.5%) to 86.206%

Details

  • Coverage increased (+0.5%) from the base build.
  • Patch coverage: 3 uncovered changes across 1 file (23 of 26 lines covered, 88.46%).
  • 9238 coverage regressions across 138 files.

Uncovered Changes

File Changed Covered %
stacks-common/src/types/mod.rs 26 23 88.46%

Coverage Regressions

9238 previously-covered lines in 138 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
stackslib/src/chainstate/burn/db/sortdb.rs 504 90.2%
stackslib/src/chainstate/stacks/db/blocks.rs 501 89.95%
stackslib/src/chainstate/nakamoto/mod.rs 437 84.72%
stackslib/src/net/mod.rs 310 78.16%
stackslib/src/config/mod.rs 292 77.47%
stackslib/src/chainstate/stacks/index/storage.rs 277 82.41%
clarity/src/vm/database/clarity_db.rs 268 82.11%
stackslib/src/chainstate/stacks/miner.rs 264 83.29%
stackslib/src/chainstate/stacks/db/transactions.rs 253 97.15%
stackslib/src/net/inv/epoch2x.rs 215 79.84%

Coverage Stats

Coverage Status
Relevant Lines: 226674
Covered Lines: 195406
Line Coverage: 86.21%
Coverage Strength: 19564421.41 hits per line

💛 - Coveralls

@francesco-stacks francesco-stacks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@cylewitruk-stacks
cylewitruk-stacks added this pull request to the merge queue Jul 9, 2026
Merged via the queue into stacks-network:develop with commit 3f6771a Jul 9, 2026
411 of 414 checks passed
@cylewitruk-stacks
cylewitruk-stacks deleted the feat/stacks-epoch-id-range-ops-for-testing branch July 9, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants