Skip to content

fix(home): catch recovery-gate failure + pin error surface in a test#713

Merged
TaprootFreak merged 3 commits into
stagingfrom
fix/bitbox-recovery-followups
Jun 9, 2026
Merged

fix(home): catch recovery-gate failure + pin error surface in a test#713
TaprootFreak merged 3 commits into
stagingfrom
fix/bitbox-recovery-followups

Conversation

@TaprootFreak

Copy link
Copy Markdown
Contributor

Context

Follow-up to #710 (BitBox empty-address self-heal, already merged into staging). Closes the two non-blocking review items from that PR. No behavior change for any previously-working path.

What changed

  • Recovery-gate is now inside the load try/catch (_onLoadCurrentWallet). In fix(bitbox): guard + self-heal empty wallet address (grey screen) #710 the currentWalletNeedsAddressRecovery() gate ran before the try; an unexpected throw (e.g. a RangeError from a corrupt type index, or a DB read error) would propagate and leave isLoadingWallet stuck true. It now sits inside the try, so such a throw is handled as a normal load failure (spinner cleared, logged) — strictly better than before. The healthy-wallet success path and the recovery-divert path are byte-for-byte unchanged (the recovery return stays inside the try, so the trailing balance/sync side-effects are still skipped exactly as before).
  • Test for the ErrorWidget.builder last-resort surface. fix(bitbox): guard + self-heal empty wallet address (grey screen) #710 added _RealUnitErrorView (the on-brand replacement for the grey error box) but left it untested — the only untested new path. A @visibleForTesting factory exposes the private view, and a widget test pins: the friendly copy renders with no surrounding MaterialApp, the error icon is present, and the debug-only exception text is surfaced under kDebugMode.

Test plan

  • flutter analyze clean
  • flutter test --exclude-tags golden — full suite green (2336 tests)
  • test/screens/home/home_bloc_test.dart still green (recovery divert + clear-flag behavior unchanged)
  • New test/main_error_view_test.dart green

Follow-up to #710.

- Move the BitBox address-recovery gate inside _onLoadCurrentWallet's
  try/catch so an unexpected throw from currentWalletNeedsAddressRecovery
  is handled as a load failure (spinner cleared) instead of leaving
  isLoadingWallet stuck true. Success and recovery paths are unchanged.
- Add a widget test for the ErrorWidget.builder last-resort surface via a
  @VisibleForTesting factory, covering the friendly copy, the error icon,
  and the debug-only exception text.
@TaprootFreak TaprootFreak marked this pull request as ready for review June 9, 2026 13:16
Directly pins the behaviour the previous commit introduced: when
currentWalletNeedsAddressRecovery throws, _onLoadCurrentWallet clears the
spinner, leaves bitboxAddressRecoveryNeeded off, and skips the sync
side-effects instead of leaving isLoadingWallet stuck true.
Move RealUnitErrorView out of main.dart into lib/setup/error_handling/
so its widget test imports only the view, not main.dart. Importing
main.dart pulled fuck_firebase.dart — which is inside the coverage
scope (lib/packages/**) — into the report with its never-executed body,
dropping scoped line coverage to 99.9% and failing the Coverage Floor
Gate. The view now lives outside the coverage scope and is still tested
directly via the public RealUnitErrorView.
@TaprootFreak TaprootFreak merged commit 198cef5 into staging Jun 9, 2026
5 checks passed
@TaprootFreak TaprootFreak deleted the fix/bitbox-recovery-followups branch June 9, 2026 14:06
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