Skip to content

test: split CreateNewBlock_validity into independent test cases - #36852

Open
yuvicc wants to merge 4 commits into
bitcoin:masterfrom
yuvicc:test-declarative-miner-basic
Open

yuvicc wants to merge 4 commits into
bitcoin:masterfrom
yuvicc:test-declarative-miner-basic

Conversation

@yuvicc

@yuvicc yuvicc commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

CreateNewBlock_validity mines a 110-block chain and then runs four subtests on it as member functions. The subtests share one chain, so each starts from whatever the previous one left behind, and the caller has to patch Tip()->nHeight between them. Inside TestBasicMining a single CMutableTransaction is reused across all sections, with each section overwriting some of its fields, so the transaction a section actually tests depends on every section before it.

This PR removes both kinds of hidden state.

@DrahtBot DrahtBot added the Tests label Nov 13, 2026
@DrahtBot

DrahtBot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36525 (mining: add Block interface, fix template data race by Sjors)
  • #36318 (validation: Ensure Invalid ValidationState has result by optout21)
  • #36156 (mining: include chunks that reach block limits by l0rinc)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@yuvicc yuvicc changed the title test: split CreateNewBlock_validity into independent test cases test: split CreateNewBlock_validity into independent test cases Nov 16, 2026
Construct the transactions of each TestBasicMining section in place
instead of reusing a single transaction across all sections and
overwriting some of its fields.
Move the loop that mines the hardcoded BLOCKINFO chain out of
CreateNewBlock_validity into a MineBlockInfoChain() helper on
MinerTestingSetup, returning txFirst and baseheight. The coinbase output
script becomes a file-level COINBASE_OUTPUT_SCRIPT constant so the
helper can use it.

This is a move-only refactor in preparation for splitting the
sub-tests into independent test cases.
The sub-tests ran as member functions on one shared chain, so each
started from the state the previous one left behind and the caller had
to patch `Tip()->nHeight` between them.

Make them independent test cases, each mining the BLOCKINFO chain via
`MineBlockInfoChain()`. The blocks use hardcoded nonces, so doing this
once per case is cheap.
Use `BOOST_CHECK_EXCEPTION` with HasReason instead of `BOOST_CHECK_THROW` so
the test asserts the specific deprecation error rather than any
`std::runtime_error`.
@yuvicc
yuvicc force-pushed the test-declarative-miner-basic branch from 7e81f50 to 13847d5 Compare November 20, 2026 05:24
@yuvicc

yuvicc commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

ralph review:

Separating the mining-loop extraction would let reviewers check the relocation independently before reviewing fresh fixtures and removal of the height adjustments; this is a review-flow improvement, not a final-tree defect.

Split the helper extraction into its own commit (71204c4). It's move-only.

Addressed the LLM linter comment: submitSolutionOld7 is now checked with BOOST_CHECK_EXCEPTION(..., HasReason{"Old submitSolution (@7) not supported"}) instead of BOOST_CHECK_THROW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants