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 = 1000maxfee = 31200avgfee = 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 = 6utxo_increase_actual = 4utxo_size_inc = 444utxo_size_inc_actual = 305
Only the functional test and its generated fixture are changed:
test/functional/rpc_getblockstats.pytest/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.