Skip to content

Conversation

QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Sep 4, 2025

Updated the integration test script to support Dash instead of Bitcoin. The changes include renaming variables and commands to reflect the Dash environment, such as changing bitcoind to dashd and updating the test directory name. This ensures that the integration tests are correctly set up for testing Dash-related functionalities.

Summary by CodeRabbit

  • Tests
    • Updated RPC integration tests to run a mixed-node setup (first node unchanged, second now Dash daemon on regtest) with revised ports, connection, and authentication paths.
    • Improved cleanup to terminate the correct processes reliably.
    • Removed obsolete version-conditional flags to simplify test configuration.
  • Chores
    • Standardized temporary test directory naming to reflect Dashcore.

Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

The integration test script updates the second regtest node to use dashd instead of bitcoind, adjusts datadir, ports, connection wiring, RPC URL, and cookie paths, removes version-based argument blocks, and updates cleanup to terminate dashd. The test still launches two nodes, runs cargo via RPC, and kills both processes.

Changes

Cohort / File(s) Summary
RPC integration test script
rpc-integration-test/run.sh
Switch second node from bitcoind to dashd; change test dir prefix to /tmp/rust_dashcore_rpc_test; wire dashd with -connect to first node, rpcport 12349, regtest datadir 2; update RPC_URL and cookie path to node 2; remove BLOCKFILTERARG/FALLBACKFEEARG logic; adjust cleanup to kill dashd and bitcoind PIDs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant T as Test Runner
  participant N1 as bitcoind (node 1)
  participant N2 as dashd (node 2)

  T->>N1: Start bitcoind -regtest -rpcport 12348 -server -txindex
  T->>N2: Start dashd -regtest -rpcport 12349 -connect 127.0.0.1:12348 -server -txindex
  Note over N2: Uses datadir ./2 and regtest cookie

  T->>N2: RPC calls via http://localhost:12349
  Note over T,N2: Cargo tests exercise RPC on node 2

  T-->>N1: On completion/failure: kill -9 PID1
  T-->>N2: On completion/failure: kill -9 PID2
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I spun up twin chains in a moonlit dash,
One speaks in bits, the other hums in cash.
Ports aligned, cookies crisp and sweet,
Tests hop through RPC on bunny feet.
When the checks are done—thump, thump—goodnight,
I tuck the daemons in, and kill the light. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch featupdate-integration-test-for-dash

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rpc-integration-test/run.sh (1)

21-28: dashd cannot peer with bitcoind; replace the first node or drop the P2P wiring.

Dash Core and Bitcoin Core are wire-incompatible; dashd -connect=127.0.0.1:12348 will never handshake with the bitcoind node. The test won’t form a network and the second node’s p2p won’t connect. Either:

  • run both nodes as dashd, or
  • simplify to a single dashd and remove the -connect requirement if P2P isn’t needed for the RPC test.

Minimal change within this hunk (decouple from the Bitcoin peer):

 dashd -regtest \
     -datadir=${TESTDIR}/2 \
-    -connect=127.0.0.1:12348 \
     -rpcport=12349 \
     -server=1 \
     -txindex=1 \
     -printtoconsole=0 &

If you want a two-node Dash regtest, update the earlier node to dashd and wire with -addnode/-connect between the two dashd instances. Example (outside selected lines, full context for clarity):

# Node A
dashd -regtest -datadir="${TESTDIR}/1" -port=12348 -server=0 -printtoconsole=0 &
PID1=$!

# Node B
dashd -regtest -datadir="${TESTDIR}/2" -port=12350 -connect=127.0.0.1:12348 -rpcport=12349 -server=1 -txindex=1 -printtoconsole=0 &
PID2=$!
🧹 Nitpick comments (2)
rpc-integration-test/run.sh (2)

3-3: Use a unique temp dir and quote expansions.

Hard-coding /tmp/rust_dashcore_rpc_test risks collisions across runs/CI shards. Prefer mktemp -d and quote ${TESTDIR} where used.

Example (outside selected lines):

TESTDIR="$(mktemp -d -t rust_dashcore_rpc_test.XXXXXX)"
mkdir -p "${TESTDIR}/1" "${TESTDIR}/2"

33-35: Replace fixed sleeps with RPC readiness checks.

Polling for readiness is more robust than sleep. Use dash-cli -rpcwait if available, or a small curl loop against getblockcount.

Example (outside selected lines):

# Wait for RPC to be ready
dash-cli -regtest -datadir="${TESTDIR}/2" -rpcwait getblockcount >/dev/null 2>&1 || true
# Fallback if dash-cli isn’t present:
# until curl -s --fail --user "$(cat "${TESTDIR}/2/regtest/.cookie")" \
#   --data-binary '{"jsonrpc":"1.0","id":"ping","method":"getblockcount","params":[]}' \
#   http://127.0.0.1:12349 >/dev/null; do sleep 0.5; done
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cb46f84 and 819b652.

📒 Files selected for processing (1)
  • rpc-integration-test/run.sh (2 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/**/*.rs : Keep test vectors in sync with Dash Core releases
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T04:00:14.154Z
Learning: Applies to {dash-spv,rpc-integration-test}/tests/**/*.rs : Provide integration tests for network operations
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/tests/integration_real_node_test.rs : Integration tests that connect to a live Dash Core node must gracefully skip when the node at 127.0.0.1:9999 is unavailable
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/tests/**/*.rs : Place integration tests under the `tests/` directory
📚 Learning: 2025-08-29T04:01:18.111Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.111Z
Learning: Applies to key-wallet/tests/**/*.rs : Keep test vectors in sync with Dash Core releases

Applied to files:

  • rpc-integration-test/run.sh
📚 Learning: 2025-08-29T04:00:14.154Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T04:00:14.154Z
Learning: Applies to {dash-spv,rpc-integration-test}/tests/**/*.rs : Provide integration tests for network operations

Applied to files:

  • rpc-integration-test/run.sh
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/tests/integration_real_node_test.rs : Integration tests that connect to a live Dash Core node must gracefully skip when the node at 127.0.0.1:9999 is unavailable

Applied to files:

  • rpc-integration-test/run.sh
📚 Learning: 2025-09-01T14:44:53.683Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: AGENTS.md:0-0
Timestamp: 2025-09-01T14:44:53.683Z
Learning: Applies to **/tests/**/*.rs : Use descriptive test names (e.g., test_parse_address_mainnet) for integration tests

Applied to files:

  • rpc-integration-test/run.sh
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/tests/**/*.rs : Place integration tests under the `tests/` directory

Applied to files:

  • rpc-integration-test/run.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: fuzz (dash_deserialize_script)
  • GitHub Check: fuzz (hashes_ripemd160)
  • GitHub Check: fuzz (dash_outpoint_string)
  • GitHub Check: RPC Tests (stable, true)
  • GitHub Check: fuzz (hashes_sha256)
  • GitHub Check: Strict Warnings and Clippy Checks
  • GitHub Check: fuzz (dash_script_bytes_to_asm_fmt)
  • GitHub Check: fuzz (hashes_sha512_256)
  • GitHub Check: fuzz (hashes_cbor)
  • GitHub Check: fuzz (hashes_sha512)
  • GitHub Check: fuzz (dash_deserialize_witness)
  • GitHub Check: Clippy (Non-strict)
  • GitHub Check: fuzz (dash_deserialize_address)
  • GitHub Check: fuzz (dash_deserialize_amount)
  • GitHub Check: SPV Components Tests

Comment on lines +8 to +9
# To kill any remaining open dashd.
killall -9 dashd
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid killall -9 dashd; scope cleanup to this script.

killall -9 may nuke a developer’s local node. Remove this and rely on PID-scoped cleanup with TERM + forced KILL fallback in a trap.

-# To kill any remaining open dashd.
-killall -9 dashd

Add a trap after spawning processes (outside selected lines):

cleanup() {
  # Try graceful shutdown first
  kill -TERM ${PID2:-} ${PID1:-} 2>/dev/null || true
  wait ${PID2:-} ${PID1:-} 2>/dev/null || true
}
trap cleanup EXIT INT TERM
🤖 Prompt for AI Agents
In rpc-integration-test/run.sh around lines 8 to 9, remove the unconditional
global killall -9 dashd and instead implement PID-scoped cleanup: after you
spawn background processes capture their PIDs, add a trap for EXIT/INT/TERM that
first attempts a graceful kill -TERM on those PIDs, waits for them, and if they
do not exit escalate to kill -9 as a fallback; place the trap setup after the
processes are spawned so it can reference the actual PID variables and suppress
errors on missing PIDs.

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