Skip to content

test(dash-spv): add multi-wallet integration tests#697

Open
xdustinface wants to merge 1 commit intov0.42-devfrom
test/multi-wallet-integration-tests
Open

test(dash-spv): add multi-wallet integration tests#697
xdustinface wants to merge 1 commit intov0.42-devfrom
test/multi-wallet-integration-tests

Conversation

@xdustinface
Copy link
Copy Markdown
Collaborator

@xdustinface xdustinface commented Apr 28, 2026

Adds tests_multi_wallet.rs plus extensions to tests_basic.rs and tests_restart.rs covering per-wallet sync behavior:

  • Two wallets in one WalletManager sync independently.
  • Runtime wallet-add with birth_height before, at, and beyond tip, asserting existing wallets' synced_height and last_processed_height never regress.
  • Deep historical rescan triggered by a birth_height = 0 runtime add.
  • A block funding two wallets is attributed correctly to each after both are added at runtime.
  • Runtime add against a Syncing-state FiltersManager.
  • Runtime-add rescan composed with a live tip advance.
  • Restart of a fully-synced client emits no rescan, then runtime-adding a second wallet only catches up the new wallet.

Based on:

Summary by CodeRabbit

  • Tests
    • Added a comprehensive multi-wallet SPV test suite covering six end-to-end scenarios for per-wallet isolation, rescans, runtime wallet addition, and concurrency with tip advancement
    • Added integration test validating runtime wallet add after restart without regressions
    • Added an async helper to await wallet sync progress
    • Removed an obsolete basic multi-wallet test and trimmed imports accordingly

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5210f278-6a0c-4ecc-a041-ad3b772ad650

📥 Commits

Reviewing files that changed from the base of the PR and between 34c27d9 and 348c570.

📒 Files selected for processing (5)
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/tests/dashd_sync/main.rs
  • dash-spv/tests/dashd_sync/tests_basic.rs
  • dash-spv/tests/dashd_sync/tests_multi_wallet.rs
  • dash-spv/tests/dashd_sync/tests_restart.rs
✅ Files skipped from review due to trivial changes (1)
  • dash-spv/tests/dashd_sync/tests_restart.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/tests/dashd_sync/tests_multi_wallet.rs

📝 Walkthrough

Walkthrough

Adds extensive multi-wallet SPV synchronization tests and a test helper: new multi-wallet test module with six end-to-end scenarios, a runtime-after-restart test, a helper to wait for wallet sync via WalletEvent subscriptions, and test harness wiring to include the new module; some basic test imports and a legacy two-wallet test were removed.

Changes

Multi-Wallet SPV Sync Testing

Layer / File(s) Summary
Test Helper
dash-spv/tests/dashd_sync/helpers.rs
Adds pub(super) async fn wait_for_wallet_synced(...) which subscribes to per-wallet WalletEvent, checks current synced_height, and polls for SyncHeightAdvanced up to a 30s deadline; panics on timeout/closed receiver.
New Tests Module
dash-spv/tests/dashd_sync/tests_multi_wallet.rs
New comprehensive module with reserve_first_address(mnemonic) and six #[tokio::test] scenarios covering: pre-created multi-wallet sync, staged runtime wallet additions, deep historical rescan, shared-block funding for two wallets, add-during-initial-filter-download, and add-during-rescan+tip-advance. Tests assert per-wallet isolation, non-regression of heights, expected tx counts and balances, and use deadlines/timeouts.
Test Harness Wiring
dash-spv/tests/dashd_sync/main.rs
Adds mod tests_multi_wallet; so the new module is included in the dashd sync test harness.
Basic Tests Cleanup
dash-spv/tests/dashd_sync/tests_basic.rs
Removes the old test_sync_two_wallets_same_client and prunes unused wallet-related imports and helpers.
Restart Scenario
dash-spv/tests/dashd_sync/tests_restart.rs
Expands imports and adds test_runtime_add_after_restart, which syncs W1, restarts reusing storage, ensures no spurious FiltersSyncComplete or height regressions, adds W2 at runtime, waits for W2 catch-up (<=120s), and verifies W1 unchanged while W2 remains empty.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐇 I hopped through filters, blocks, and logs so spry,

wallets woke and caught the tip-up in the sky.
No regress, no leak, each tx found its lane,
testers and rabbits celebrate the gain! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(dash-spv): add multi-wallet integration tests' clearly and concisely summarizes the main change: adding new multi-wallet integration tests to the dash-spv test suite. It directly matches the primary changeset content (new tests_multi_wallet.rs file with extensive test coverage) and follows conventional commit formatting.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/multi-wallet-integration-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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.62%. Comparing base (ca507a9) to head (348c570).
⚠️ Report is 7 commits behind head on v0.42-dev.

Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #697      +/-   ##
=============================================
+ Coverage      70.58%   70.62%   +0.03%     
=============================================
  Files            320      319       -1     
  Lines          68243    68211      -32     
=============================================
+ Hits           48168    48171       +3     
+ Misses         20075    20040      -35     
Flag Coverage Δ
core 75.81% <ø> (ø)
ffi 43.37% <ø> (ø)
rpc 20.00% <ø> (ø)
spv 87.41% <ø> (+0.15%) ⬆️
wallet 69.64% <ø> (+<0.01%) ⬆️
see 13 files with indirect coverage changes

@github-actions github-actions Bot added the merge-conflict The PR conflicts with the target branch. label Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@xdustinface xdustinface force-pushed the test/multi-wallet-integration-tests branch from bbf4de5 to 6514b12 Compare May 3, 2026 12:01
@github-actions github-actions Bot removed the merge-conflict The PR conflicts with the target branch. label May 3, 2026
@xdustinface xdustinface force-pushed the test/multi-wallet-integration-tests branch from 6514b12 to 34c27d9 Compare May 3, 2026 12:21
@xdustinface xdustinface marked this pull request as ready for review May 3, 2026 12:22
@xdustinface xdustinface force-pushed the test/multi-wallet-integration-tests branch from 34c27d9 to 943eec3 Compare May 3, 2026 12:23
Copy link
Copy Markdown
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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@dash-spv/tests/dashd_sync/tests_multi_wallet.rs`:
- Around line 50-51: Add the #[ignore] attribute to network-dependent
integration tests so they don't run by default: place #[ignore] immediately
above each #[tokio::test] declaration in this file (including the test function
test_sync_two_wallets_same_client and the other four network-dependent test
cases mentioned) so they are excluded from regular runs and can be executed
explicitly with -- --ignored in the dedicated integration job.

In `@dash-spv/tests/dashd_sync/tests_restart.rs`:
- Around line 212-213: Add the #[ignore] attribute to the test function
declaration for test_runtime_add_after_restart so the test is not run by
default; specifically, place #[ignore] above the existing #[tokio::test] on the
test_runtime_add_after_restart function so it will only run when invoked with --
--ignored.
- Around line 247-263: Mark the network-dependent test (tests_restart.rs) with
#[ignore] and change the sync-event draining/watch logic to explicitly handle
broadcast lag: when draining client_handle.sync_event_receiver use try_recv()
but detect and handle RecvError::Lagged (don't silently ignore it), and in the
watch loop match recv() errors so that Err(RecvError::Lagged) is handled
separately (e.g., fail or increment a spurious counter) rather than treating all
recv errors the same as a timeout/break; reference the
SyncEvent::FiltersSyncComplete variant, client_handle.sync_event_receiver,
try_recv, recv, and RecvError::Lagged, and consider starting the receiver
observation before returning from wait_for_sync()/the function that spawns the
upstream rescan to avoid missing early events.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b4412e3d-697d-4715-918c-f636c88383a5

📥 Commits

Reviewing files that changed from the base of the PR and between ca507a9 and 34c27d9.

📒 Files selected for processing (5)
  • dash-spv/tests/dashd_sync/helpers.rs
  • dash-spv/tests/dashd_sync/main.rs
  • dash-spv/tests/dashd_sync/tests_basic.rs
  • dash-spv/tests/dashd_sync/tests_multi_wallet.rs
  • dash-spv/tests/dashd_sync/tests_restart.rs

Comment thread dash-spv/tests/dashd_sync/tests_multi_wallet.rs
Comment thread dash-spv/tests/dashd_sync/tests_restart.rs
Comment thread dash-spv/tests/dashd_sync/tests_restart.rs
Adds `tests_multi_wallet.rs` plus extensions to `tests_basic.rs` and `tests_restart.rs` covering per-wallet sync behavior:

- Two wallets in one `WalletManager` sync independently.
- Runtime wallet-add with `birth_height` before, at, and beyond tip, asserting existing wallets' `synced_height` and `last_processed_height` never regress.
- Deep historical rescan triggered by a `birth_height = 0` runtime add.
- A block funding two wallets is attributed correctly to each after both are added at runtime.
- Runtime add against a `Syncing`-state `FiltersManager`.
- Runtime-add rescan composed with a live tip advance.
- Restart of a fully-synced client emits no rescan, then runtime-adding a second wallet only catches up the new wallet.
@xdustinface xdustinface force-pushed the test/multi-wallet-integration-tests branch from 943eec3 to 348c570 Compare May 3, 2026 23:23
@github-actions github-actions Bot added the ready-for-review CodeRabbit has approved this PR label May 4, 2026
@xdustinface xdustinface requested review from ZocoLini May 5, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review CodeRabbit has approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant