Skip to content

test: replace the stateful mining RPC tests with regtest coverage - #11246

Open
oxarbitrage wants to merge 4 commits into
mainfrom
track-a-mining-rpc-regtest
Open

test: replace the stateful mining RPC tests with regtest coverage#11246
oxarbitrage wants to merge 4 commits into
mainfrom
track-a-mining-rpc-regtest

Conversation

@oxarbitrage

Copy link
Copy Markdown
Contributor

Motivation

Over the last 40 main runs, rpc-submit-block failed 64% of the time and
rpc-get-block-template 46% — every failure I sampled a one hour timeout with zero panics and zero
assertion failures. Both sync a cached mainnet state to the tip before testing anything, so they
die in that prologue on Transaction(TransparentInputNotFound) (#11168) and never reach their own
assertions. They test a sync bug that already has an issue, not the mining RPCs.

Implements Track A of #9941.

Solution

Two commits adding coverage, then two removing what they replace.

Added — unit tests for LongPollId::submit_old(), which had none, and
getblocktemplate_long_poll_returns_submit_old_false_on_new_tip on Regtest: start a long poll,
advance the tip with generate, require a prompt submit_old: false and a template that validates
in proposal mode.

Removedstateful::rpc::rpc_submit_block and stateful::rpc::rpc_get_block_template, with
their GCP jobs.

submitblock is already better covered on Regtest, on every PR, in seconds: 200 submissions with
typed Accepted in submit_blocks_test, plus typed Rejected assertions in
nu6_funding_streams_and_coinbase_balance that the deleted test never made. getblocktemplate's
only unique coverage was long-poll invalidation, and the deleted test never asserted it — it
pushed to a channel if let Some(false) = ...submit_old() and passed anyway when that never fired.
So this is the first real assertion of that path, triggered deterministically.

Two deliberate trade-offs: no GCP job covers mining RPCs after this (intended; ten others still gate
integration-tests-success), and Regtest disables PoW and submits coinbase-only blocks, which
reaches no code inside submit_block. Residual gap in Follow-up Work.

Tests

zebra-rpc --lib 91/91, clippy and fmt clean, new Regtest test stable over 4 runs at ~25s, all four
commits compile standalone. Mutating submit_old() to always return true fails the new tests —
the deleted test would still have passed. No changelog needed for a test: PR.

Specifications & References

#9941 (Track A plan), #11168 (the sync bug these jobs actually failed on), and BIP 22 long polling,
origin of submitold: https://en.bitcoin.it/wiki/BIP_0022#Optional:_Long_Polling

Follow-up Work

AI Disclosure

  • No AI tools were used in this PR
  • AI tools were used: Claude Code, for the CI failure analysis and drafting the tests and this
    description. Findings were verified against the code and CI logs.

PR Checklist

  • The PR title follows conventional commits format: type(scope): description
  • The PR follows the contribution guidelines.
  • This change was discussed in an issue or with the team beforehand.
  • The solution is tested.
  • The documentation and changelogs are up to date.

@v12-auditor

v12-auditor Bot commented Aug 11, 2026

Copy link
Copy Markdown

Warning

No auditable source files found in this PR's diff.

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.

1 participant