Skip to content

test: replace feature_masternode_params.py with C++ unit coverage#7386

Draft
thepastaclaw wants to merge 2 commits into
dashpay:developfrom
thepastaclaw:test/masternode-params-unit
Draft

test: replace feature_masternode_params.py with C++ unit coverage#7386
thepastaclaw wants to merge 2 commits into
dashpay:developfrom
thepastaclaw:test/masternode-params-unit

Conversation

@thepastaclaw

Copy link
Copy Markdown

Issue being fixed or feature implemented

test/functional/feature_masternode_params.py exercised the
-masternodeblsprivkey parameter interaction by spinning up two full
nodes and restarting them three times. Every assertion the test made is
really about argument-state after InitParameterInteraction runs —
which is plain C++ logic and is much cheaper to cover as a unit test.

What was done?

  • Added src/test/masternode_params_tests.cpp with three cases against
    InitParameterInteraction:
    • no -masternodeblsprivkey → defaults untouched
    • -masternodeblsprivkey-disablewallet, -peerblockfilters and
      -blockfilterindex=basic are soft-set
    • -masternodeblsprivkey + explicit -disablewallet=0 /
      -peerblockfilters=0 / -blockfilterindex=0 → user values win
      (SoftSet semantics)
  • Wired the new suite into src/Makefile.test.include.
  • Removed test/functional/feature_masternode_params.py and its entry
    in test/functional/test_runner.py.

The unit tests are strictly stronger than the functional test: the
functional test had to weaken its first masternode assertion to just
"node is running" because filter advertisement timing is asynchronous,
while the unit test asserts the actual contract directly on
ArgsManager.

The downstream effect of -peerblockfilters=1 / -blockfilterindex=basic
(advertising NODE_COMPACT_FILTERS, instantiating the basic filter
index) is not Dash-specific and is already covered upstream by
blockfilter_index_tests and the rest of init validation, so dropping
the functional check there is not a coverage regression.

How Has This Been Tested?

Local timings on Apple M-series, debug build
(--enable-debug --disable-hardening):

Coverage Command Real time
Old functional (base) /usr/bin/time -p test/functional/feature_masternode_params.py 5.70 s
New unit (this PR) /usr/bin/time -p ./src/test/test_dash --run_test=masternode_params_tests 0.35 s

New suite output:

Running 3 test cases...
*** No errors detected

CI savings: every PR build runs the functional suite, so removing a
~6 s node-spinning test in favor of a 0.35 s unit test is a small but
consistent win, and removes one process-spawn/restart cycle from
parallel functional shards.

Breaking Changes

None. Test-only change.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

Cover the InitParameterInteraction behavior triggered by
-masternodeblsprivkey directly: -disablewallet, -peerblockfilters and
-blockfilterindex=basic are soft-set, while explicit user values win.

This replaces the much slower node-spinning checks in
feature_masternode_params.py, removed in a follow-up commit.
The functional test only verified -masternodeblsprivkey parameter
interactions (auto -disablewallet, -peerblockfilters, -blockfilterindex,
plus user override semantics). All of these are now covered directly in
masternode_params_tests, which is faster and exercises the soft-set
logic without spinning up nodes.

Local timings (Apple M-series, debug build):
- feature_masternode_params.py: real 5.70s
- test_dash --run_test=masternode_params_tests: real 0.35s
@thepastaclaw

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 460d8c10-e6e4-49c1-81ca-ae6dcd184fe0

📥 Commits

Reviewing files that changed from the base of the PR and between ebfdb8b and b900880.

📒 Files selected for processing (4)
  • src/Makefile.test.include
  • src/test/masternode_params_tests.cpp
  • test/functional/feature_masternode_params.py
  • test/functional/test_runner.py
💤 Files with no reviewable changes (2)
  • test/functional/test_runner.py
  • test/functional/feature_masternode_params.py

Walkthrough

The functional test test/functional/feature_masternode_params.py and its entry in test/functional/test_runner.py are removed. An equivalent unit test suite, src/test/masternode_params_tests.cpp, is added using Boost.Test with BasicTestingSetup. It contains three test cases: one verifying no defaults are set without -masternodeblsprivkey, one verifying -disablewallet, -peerblockfilters, and -blockfilterindex=basic are auto-enabled when the key is set, and one verifying explicit user overrides take precedence. The new file is added to BITCOIN_TESTS in src/Makefile.test.include.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes replacing the functional masternode params test with C++ unit coverage.
Description check ✅ Passed The description is directly related to the code changes and explains the replacement test coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Jun 27, 2026

Copy link
Copy Markdown
Author

✅ Review complete (commit b900880)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Code Review

Test-only PR replacing a slow functional test with a focused unit test for the -masternodeblsprivkey parameter interaction. Both agents converged on a single valid suggestion: the new Dash-specific test file should be registered in non-backported.txt for Dash cppcheck lint coverage. No correctness or scope issues.

🟡 1 suggestion(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `test/util/data/non-backported.txt`:
- [SUGGESTION] test/util/data/non-backported.txt:60-68: Register the new Dash-specific test file for Dash lint coverage
  The new `src/test/masternode_params_tests.cpp` is Dash-specific (it exercises the `-masternodeblsprivkey` parameter interaction added in Dash's `InitParameterInteraction`, which has no upstream counterpart), but no pattern in `non-backported.txt` matches it. `test/lint/lint-cppcheck-dash.py` derives its cppcheck target list from this file via `git ls-files -- <patterns>`, so without an entry the new test source will be excluded from the Dash-specific cppcheck pass. Other Dash-specific test files in `src/test/` are explicitly registered (e.g. `evo*.cpp`, `llmq*.cpp`, `governance*.cpp`, `block_reward_reallocation_tests.cpp`). Add a matching entry alongside the existing `src/test/...` lines.

Note: GitHub does not allow me to approve my own PR, so this is posted as a COMMENT while preserving the verified review result.

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