-
Notifications
You must be signed in to change notification settings - Fork 3
fix: prevent crash during wallet backup #1092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release-2.4.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ import to.bitkit.services.PaykitSdkService | |
| import to.bitkit.test.BaseUnitTest | ||
| import to.bitkit.utils.AppError | ||
| import javax.inject.Provider | ||
| import kotlin.test.assertFalse | ||
| import kotlin.test.assertTrue | ||
| import kotlin.time.Clock | ||
| import kotlin.time.ExperimentalTime | ||
|
|
@@ -111,6 +112,35 @@ class BackupRepoTest : BaseUnitTest() { | |
| verify(settingsStore, never()).update(any()) | ||
| } | ||
|
|
||
| @Test | ||
| fun `automatic wallet backup marks failure when Paykit snapshot fails`() = test { | ||
| whenever { privatePaykitRepo.backupSnapshot() } | ||
| .thenReturn(Result.failure(BackupRepoTestError("paykit session missing capabilities"))) | ||
| val backupStatuses = MutableStateFlow( | ||
| mapOf( | ||
| BackupCategory.WALLET to BackupItemStatus( | ||
| synced = 1_000, | ||
| required = 2_000, | ||
| ), | ||
| ) | ||
| ) | ||
| val allowWalletClear = CompletableDeferred<Unit>().apply { complete(Unit) } | ||
| stubBackupStatuses(backupStatuses, allowWalletClear) {} | ||
| stubBackupObservers() | ||
|
|
||
| try { | ||
| sut.startObservingBackups() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test still passes if |
||
| runCurrent() | ||
| advanceTimeBy(5_000) | ||
| runCurrent() | ||
|
|
||
| verify(vssBackupClient, never()).putObject(eq(BackupCategory.WALLET.name), any()) | ||
| assertFalse(backupStatuses.value.getValue(BackupCategory.WALLET).running) | ||
| } finally { | ||
| sut.stopObservingBackups() | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun `start observing backs up stale required status after clearing running flag`() = test { | ||
| val backupStatuses = MutableStateFlow( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixed a crash during automatic wallet backup when Paykit state could not be read. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
triggerBackupnow infersUnitbecause this path returns without a value, but it returnedResult<VssItem>before this change. That makes a snapshot failure look like successful completion to callers and changes the method signature. Could we return the snapshot failure as aResultand declare the return type explicitly?