Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions src/context/wallet_lifecycle/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ async fn stop_spv_is_idempotent_without_a_wired_backend() {
/// Restart-in-place reconnect: a same-network Disconnect → Connect keeps the
/// SAME `WalletBackend` (and its `Arc<SqlitePersister>`) wired, so the
/// persister DB is never closed/reopened and `AlreadyOpen` is impossible by
/// construction — no release barrier needed. Drives the real production
/// path: `stop_spv()` (in-place) then `ensure_wallet_backend_and_start_spv()`.
/// construction — the retry below only absorbs a storage-lock timing window,
/// not a release barrier. Drives the real production path: `stop_spv()`
/// (in-place) then `ensure_wallet_backend_and_start_spv()`.
///
/// Validated offline (passes now): the backend pointer is identical across
/// disconnect→connect (reuse, not rebuild); `is_started()` is cleared by
Expand Down Expand Up @@ -307,9 +308,25 @@ async fn reconnect_restart_in_place_reuses_backend() {
// Reconnect: `ensure_wallet_backend` fast-paths on the populated slot
// (no `WalletBackend::new`, no `SqlitePersister::open`), so the SAME
// instance restarts — structurally immune to `AlreadyOpen`.
ctx.ensure_wallet_backend_and_start_spv(sender)
.await
.expect("reconnect should restart the SAME backend in place");
// dash-spv's storage flock can remain observable briefly after stop returns.
// This test-only retry is bounded so genuine restart regressions still fail.
let mut attempt = 0u32;
loop {
attempt += 1;
match ctx
.ensure_wallet_backend_and_start_spv(sender.clone())
.await
{
Ok(()) => break,
Err(_) if attempt < 6 => {
let backoff_ms = 25u64 * (1u64 << (attempt - 1));
tokio::time::sleep(std::time::Duration::from_millis(backoff_ms)).await;
}
Err(e) => panic!(
"reconnect should restart the SAME backend in place after {attempt} attempts: {e}"
),
}
}
let second = ctx
.wallet_backend()
.expect("backend still wired after reconnect");
Expand Down
Loading