fix(home): catch recovery-gate failure + pin error surface in a test#713
Merged
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
try/catch(_onLoadCurrentWallet). In fix(bitbox): guard + self-heal empty wallet address (grey screen) #710 thecurrentWalletNeedsAddressRecovery()gate ran before thetry; an unexpected throw (e.g. aRangeErrorfrom a corrupttypeindex, or a DB read error) would propagate and leaveisLoadingWalletstucktrue. It now sits inside thetry, 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 recoveryreturnstays inside thetry, so the trailing balance/sync side-effects are still skipped exactly as before).ErrorWidget.builderlast-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@visibleForTestingfactory exposes the private view, and a widget test pins: the friendly copy renders with no surroundingMaterialApp, the error icon is present, and the debug-only exception text is surfaced underkDebugMode.Test plan
flutter analyzecleanflutter test --exclude-tags golden— full suite green (2336 tests)test/screens/home/home_bloc_test.dartstill green (recovery divert + clear-flag behavior unchanged)test/main_error_view_test.dartgreen