Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Manual Test Scenarios: SPV Sync Error Status

## Context

When SPV sync encounters a fatal error (e.g., masternode sync failure), the app
should transition from "Syncing" to an error state, with the connectivity icon
turning red and the tooltip/status panel reflecting the failure.

## Prerequisites

- Dash Evo Tool built with the fix applied
- Access to Testnet (or a network where SPV sync can be triggered)
- SPV backend mode enabled (not RPC mode)

## Scenario 1: Verify error state on sync failure

**Goal:** Confirm the connectivity icon transitions to red (Disconnected) when
SPV sync fails.

### Steps

1. Launch Dash Evo Tool and connect to Testnet in SPV mode.
2. Observe the top-left connectivity icon during sync — it should pulse orange
(Syncing state).
3. If sync completes successfully, the icon should turn green (Running state).
4. If sync fails (e.g., masternode QRInfo failure visible in logs), observe:
- The connectivity icon turns **red** (static, no pulsation).
- Hovering over the icon shows tooltip: **"Disconnected"** with
**"SPV: Error"** detail.
5. Open the Network Chooser screen and check the SPV status detail — it should
display the error message (e.g., "Sync manager Masternode failed: ...").

### Expected Result

- Icon transitions from orange (Syncing) to red (Disconnected) on error.
- Tooltip shows "Disconnected / SPV: Error".
- Error message is visible in the status detail panel.

## Scenario 2: Verify normal sync still works

**Goal:** Confirm the fix doesn't break the happy path.

### Steps

1. Launch Dash Evo Tool and connect to Testnet in SPV mode.
2. Wait for sync to complete (may take several minutes on first sync).
3. Observe the connectivity icon transitions:
- Orange (Syncing) during sync.
- Green (Running) after sync completes.
4. Hover over the icon — tooltip should show "Ready" with "SPV: Running".

### Expected Result

- Sync completes normally, icon turns green.
- No false error transitions during normal sync.

## Scenario 3: Verify error message content

**Goal:** Confirm the error message stored in `last_error` contains useful
diagnostic information.

### Steps

1. Trigger an SPV sync that fails (e.g., by connecting to a network with
known chain lock propagation issues).
2. Check application logs for the error:
- Look for `SPV manager ... reported error: ...` log line.
3. On the Network Chooser screen, verify the status detail shows the same
error message (not a generic "Sync failed" without context).

### Expected Result

- Log contains `SPV manager "Masternode" reported error: Masternode sync failed: ...`.
- UI status detail shows the specific error from the sync manager, including
the block hash reference.

## Notes

- The actual QRInfo chain lock error is an upstream issue
(dashpay/rust-dashcore#470). This fix ensures the app **reports** the error
correctly rather than silently staying stuck in "Syncing".
- A separate upstream issue (dashpay/rust-dashcore#469) tracks the missing
`try_emit_progress()` call on error paths in dash-spv.
25 changes: 25 additions & 0 deletions src/spv/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use dash_sdk::dash_spv::network::PeerNetworkManager;
use dash_sdk::dash_spv::storage::DiskStorageManager;
use dash_sdk::dash_spv::sync::SyncEvent;
use dash_sdk::dash_spv::sync::SyncProgress as SpvSyncProgress;
use dash_sdk::dash_spv::sync::SyncState;
use dash_sdk::dash_spv::types::ValidationMode;
use dash_sdk::dash_spv::{ClientConfig, DashSpvClient, Hash, LLMQType, QuorumHash};
use dash_sdk::dpp::dashcore::{Address, InstantLock, Network, Transaction, Txid};
Expand Down Expand Up @@ -1049,6 +1050,7 @@ impl SpvManager {
mut progress_rx: tokio::sync::watch::Receiver<SpvSyncProgress>,
) {
let status = Arc::clone(&self.status);
let last_error = Arc::clone(&self.last_error);
let sync_progress_state = Arc::clone(&self.sync_progress_state);
let progress_updated_at = Arc::clone(&self.progress_updated_at);
let cancel = self.subtasks.cancellation_token.clone();
Expand All @@ -1063,6 +1065,7 @@ impl SpvManager {
}
let watch_progress = progress_rx.borrow().clone();
let is_synced = watch_progress.is_synced();
let is_error = watch_progress.state() == SyncState::Error;

// Update sync progress state
if let Ok(mut stored_sync) = sync_progress_state.write() {
Expand All @@ -1076,6 +1079,12 @@ impl SpvManager {
if let Ok(mut status_guard) = status.write() {
if is_synced {
*status_guard = SpvStatus::Running;
} else if is_error {
*status_guard = SpvStatus::Error;
if let Ok(mut err_guard) = last_error.write() {
*err_guard =
Some("Sync failed (reported by SPV library)".into());
}
Comment thread
lklimek marked this conversation as resolved.
Resolved
} else if !matches!(*status_guard, SpvStatus::Stopping | SpvStatus::Stopped | SpvStatus::Error) {
*status_guard = SpvStatus::Syncing;
}
Expand All @@ -1091,6 +1100,7 @@ impl SpvManager {
let reconcile_tx = self.reconcile_tx.lock().ok().and_then(|g| g.clone());
let finality_tx = self.finality_tx.lock().ok().and_then(|g| g.clone());
let status = Arc::clone(&self.status);
let last_error = Arc::clone(&self.last_error);
let cancel = self.subtasks.cancellation_token.clone();

self.subtasks.spawn_sync("spv_sync_event_handler", async move {
Expand Down Expand Up @@ -1135,6 +1145,21 @@ impl SpvManager {
{
*guard = SpvStatus::Running;
}

// Transition to Error when a sync manager reports a
// fatal failure. The dash-spv library emits this event
// but does NOT update the progress channel on the error
// path, so we must react to the event directly.
if let SyncEvent::ManagerError { ref manager, ref error } = event {
tracing::error!("SPV manager {:?} reported error: {}", manager, error);
if let Ok(mut guard) = status.write() {
*guard = SpvStatus::Error;
}
if let Ok(mut err_guard) = last_error.write() {
*err_guard = Some(format!("Sync manager {} failed: {}", manager, error));
}
}

if should_signal
&& let Some(ref tx) = reconcile_tx
{
Expand Down
Loading