Skip to content

Comments

test: add Dash-specific process_message target#7171

Closed
thepastaclaw wants to merge 4 commits intodashpay:developfrom
thepastaclaw:fuzz/tracker-108-dash-p2p
Closed

test: add Dash-specific process_message target#7171
thepastaclaw wants to merge 4 commits intodashpay:developfrom
thepastaclaw:fuzz/tracker-108-dash-p2p

Conversation

@thepastaclaw
Copy link

Summary

Adds a dedicated Dash-specific P2P fuzz target, process_message_dash, to cover Dash net message handling paths with structured random message payloads.

This target mirrors the existing process_message harness (TestingSetup + ConnmanTestMsg + ProcessMessagesOnce) but constrains message selection to Dash message types only (CoinJoin, governance, quorum/LLMQ, mnauth, etc.).

Changes

  • Added src/test/fuzz/process_message_dash.cpp
    • Uses a fixed allowlist of Dash NetMsgType commands
    • Injects randomized serialized payloads via ReceiveMsgFrom
    • Processes through the same message loop used by existing process-message fuzzing
    • Includes a bounded processing loop to avoid harness-level hangs
  • Wired target into src/Makefile.test.include

Validation

  1. What was tested

    • make -j16 -C src test/fuzz/fuzz
    • PRINT_ALL_FUZZ_TARGETS_AND_ABORT=1 src/test/fuzz/fuzz | rg '^process_message_dash$'
    • tmpfile=$(mktemp); head -c 4096 /dev/urandom > "$tmpfile"; timeout 20s env FUZZ=process_message_dash src/test/fuzz/fuzz "$tmpfile"; rc=$?; rm -f "$tmpfile"; exit $rc
  2. Results

    • Fuzz binary build: pass
    • Target registration check: pass (process_message_dash listed)
    • Bounded fuzz run: pass (process_message_dash: succeeded against 1 files in 0s.)
  3. Environment

    • Local macOS (Darwin arm64) in isolated worktree ~/Projects/dash/worktrees/tracker-108

Related tracker epic: thepastaclaw/tracker#108

@coderabbitai
Copy link

coderabbitai bot commented Feb 23, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

Adds a new fuzzing harness and test registration for Dash protocol message processing. A Makefile test include was updated to add the new source, and src/test/fuzz/process_message_dash.cpp implements a FUZZ_TARGET that initializes a REGTEST test node, mines blocks, creates and registers a mock peer, builds randomized CSerializedNetMsg instances from 41 Dash message types with random payloads, repeatedly calls ProcessMessagesOnce while handling exceptions, flushes/send buffers, synchronizes validation-interface callbacks, and shuts down the test node.

Sequence Diagram(s)

sequenceDiagram
  participant FuzzInput as Fuzz Input
  participant FDP as FuzzDataProvider
  participant Harness as Fuzz Harness
  participant Node as Test Node (REGTEST)
  participant Peer as Mock Peer (CNode)
  participant Proc as ProcessMessagesOnce
  participant VI as ValidationInterface

  FuzzInput->>FDP: provide bytes
  FDP->>Harness: produce message type + payload
  Harness->>Node: initialize, mine blocks, sync VI
  Harness->>Peer: create & attach peer
  Harness->>Peer: enqueue CSerializedNetMsg
  Peer->>Proc: trigger ProcessMessagesOnce
  Proc->>Node: validate/process message
  Node->>VI: emit validation callbacks / state changes
  loop until input exhausted
    FDP->>Harness: more message data
    Harness->>Peer: enqueue next message
    Peer->>Proc: ProcessMessagesOnce
  end
  Harness->>Node: synchronize VI queue & shutdown
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a Dash-specific process_message fuzzing target.
Description check ✅ Passed The description provides relevant context about the new fuzz target, its purpose, implementation details, and validation results.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/fuzz/process_message_dash.cpp (1)

25-67: Optional: use std::to_array to eliminate the hardcoded count 41

Although the compiler enforces the count, std::to_array (C++20, already required by the project) removes it entirely, making additions/removals to the list self-maintaining.

♻️ Proposed refactor
-const std::array<const char*, 41> DASH_MESSAGE_TYPES{
+constexpr auto DASH_MESSAGE_TYPES = std::to_array<const char*>({
     NetMsgType::SPORK,
     ...
     NetMsgType::PLATFORMBAN,
-};
+});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/fuzz/process_message_dash.cpp` around lines 25 - 67, Replace the
fixed-size std::array declaration for DASH_MESSAGE_TYPES with a
std::to_array-based initialization so the element count is inferred and
maintained automatically; locate the DASH_MESSAGE_TYPES variable and change its
definition from std::array<const char*, 41> DASH_MESSAGE_TYPES{ ... } to an auto
(or explicitly typed) variable initialized via std::to_array({
NetMsgType::SPORK, NetMsgType::GETSPORKS, ... }), ensuring the element type
matches (const char* or appropriate NetMsgType string type) so
additions/removals no longer require updating a hardcoded count.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/fuzz/process_message_dash.cpp`:
- Around line 1-3: Add the new Dash-specific fuzz test file
src/test/fuzz/process_message_dash.cpp to the exclusion list used by
clang-format by appending its relative path to
test/util/data/non-backported.txt; locate the new file name
process_message_dash.cpp and ensure an exact matching entry is added to the
non-backported.txt list so CI recognizes it as exempt from backport formatting
checks.

---

Nitpick comments:
In `@src/test/fuzz/process_message_dash.cpp`:
- Around line 25-67: Replace the fixed-size std::array declaration for
DASH_MESSAGE_TYPES with a std::to_array-based initialization so the element
count is inferred and maintained automatically; locate the DASH_MESSAGE_TYPES
variable and change its definition from std::array<const char*, 41>
DASH_MESSAGE_TYPES{ ... } to an auto (or explicitly typed) variable initialized
via std::to_array({ NetMsgType::SPORK, NetMsgType::GETSPORKS, ... }), ensuring
the element type matches (const char* or appropriate NetMsgType string type) so
additions/removals no longer require updating a hardcoded count.

@thepastaclaw thepastaclaw changed the title test(fuzz): add Dash-specific process_message target test: add Dash-specific process_message target Feb 23, 2026
Required for clang-format CI enforcement on Dash-specific files.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/util/data/non-backported.txt (1)

53-53: LGTM – correct registration of the new Dash-specific fuzz target.

src/test/fuzz/process_message_dash.cpp is a .cpp file and is properly added here so clang-format CI will enforce style on it. Based on learnings, this matches the requirement that all new non-backported .cpp/.h files be listed in this file.

One optional nit: alphabetically within the src/test/ block the entry (f) lands before bls_tests.cpp (b). The file's ordering is already loose (e.g., governance*.cpp appears after util/llmq_tests.h), so this is a pre-existing pattern and not a blocker, but placing it after bls_tests.cpp would be more consistent.

♻️ Suggested re-ordering within the src/test/ block
 src/test/block_reward_reallocation_tests.cpp
+src/test/bls_tests.cpp
+src/test/coinjoin_*.cpp
+src/test/dip0020opcodes_tests.cpp
+src/test/dynamic_activation*.cpp
+src/test/evo*.cpp
+src/test/fuzz/process_message_dash.cpp
-src/test/bls_tests.cpp
-src/test/coinjoin_*.cpp
-src/test/dip0020opcodes_tests.cpp
-src/test/dynamic_activation*.cpp
-src/test/evo*.cpp
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/util/data/non-backported.txt` at line 53, The non-backported file list
correctly includes src/test/fuzz/process_message_dash.cpp but its alphabetical
placement in the src/test/ block is inconsistent; move the entry
"src/test/fuzz/process_message_dash.cpp" so it appears after "bls_tests.cpp"
within the src/test/ block of non-backported.txt to keep ordering consistent (no
code changes required, just reorder the line).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/util/data/non-backported.txt`:
- Line 53: The non-backported file list correctly includes
src/test/fuzz/process_message_dash.cpp but its alphabetical placement in the
src/test/ block is inconsistent; move the entry
"src/test/fuzz/process_message_dash.cpp" so it appears after "bls_tests.cpp"
within the src/test/ block of non-backported.txt to keep ordering consistent (no
code changes required, just reorder the line).

@thepastaclaw
Copy link
Author

Superseded by consolidated fuzz branch in #7173 to avoid merge conflicts.

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