test: Make getblockstats fixture generation wallet-independent #35854

pull YingchenWang999 wants to merge 1 commits into bitcoin:master from YingchenWang999:fix-31838-getblockstats-gen-data changing 2 files +188 −179
  1. YingchenWang999 commented at 1:20 PM on July 31, 2026: none

    The rpc_getblockstats.py fixture generator currently relies on full wallet RPCs such as createwallet, sendtoaddress, and send. However, the functional test does not enable the full wallet environment by default, so running the test with --gen-test-data fails because those RPC methods are unavailable.

    Even when wallet support is enabled manually, using the full wallet makes the generated fixture dependent on wallet behavior such as coin selection, change scripts, and fee calculation. Changes to those components can alter the generated transactions and block statistics, making the fixture unnecessarily unstable.

    Replace the wallet RPC usage with the functional test framework's MiniWallet. MiniWallet does not depend on the production wallet module or wallet RPCs, and can construct deterministic transactions directly. This allows the fixture to be regenerated successfully in builds compiled with -DENABLE_WALLET=OFF and ensures that repeated runs produce byte-for-byte identical output.

    The generated block continues to include transactions with different fees:

    • Regular transactions: 1,000 sat
    • OP_RETURN transaction: 31,200 sat

    This preserves coverage for distinct fee statistics:

    • minfee = 1000
    • maxfee = 31200
    • avgfee = 8550

    The OP_RETURN output is also retained to verify the distinction between statistics that include all outputs and those that only include spendable UTXOs:

    • utxo_increase = 6
    • utxo_increase_actual = 4
    • utxo_size_inc = 444
    • utxo_size_inc_actual = 305

    Only the functional test and its generated fixture are changed:

    • test/functional/rpc_getblockstats.py
    • test/functional/data/rpc_getblockstats.json

    No production, consensus, wallet, or RPC implementation code is modified.

    Validation performed:

    • Ran rpc_getblockstats.py
    • Regenerated the fixture with --gen-test-data
    • Ran the test against the regenerated fixture
    • Confirmed byte-for-byte identical output across different random seeds
    • Built Bitcoin Core with ENABLE_WALLET=OFF
    • Ran both the normal test and fixture generation in the wallet-disabled build
    • Ran Python syntax checks
    • Ran Ruff
    • Ran Bitcoin Core Python lint
    • Validated the generated JSON
    • Ran git diff --check

    Fixes #31838.

    PR #35177 also addresses this issue using MiniWallet. After review, the Python changes in this patch match the current implementation in #35177; the fixture data was regenerated against a newer Bitcoin Core master. This PR is therefore not intended as an independent competing approach, but documents and validates the same solution on the current codebase.

  2. test: use MiniWallet for getblockstats data
    The getblockstats fixture generator relies on wallet RPCs and cannot run when the functional test starts without wallet support. Wallet transaction changes can also make the generated block statistics unstable.
    
    Generate deterministic transactions with MiniWallet instead, while preserving distinct minfee/maxfee values and OP_RETURN coverage.
    
    Fixes #31838.
    2cf9b49801
  3. DrahtBot added the label Tests on Jul 31, 2026
  4. DrahtBot commented at 1:21 PM on July 31, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35854.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. maflcko commented at 1:31 PM on July 31, 2026: member
  6. maflcko closed this on Jul 31, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-11 09:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me