Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ class PaykitPaymentRequestRepoTest : BaseUnitTest(StandardTestDispatcher()) {
backgroundScope.launch { sut.expiredProposals.collect { reported += it } }
runCurrent()

// The clock passes expiry after the snapshot is parsed and before the pending list is replaced.
// The clock passes expiry after the refresh reads its time and before the pending list is replaced.
// Mockito answers with Result's unboxed value, as the compiled suspend call expects.
whenever(usdtPayments.verifiedReceipts(any())).thenAnswer {
clockJumpMillis = 10_000
Expand Down
25 changes: 25 additions & 0 deletions app/src/test/java/to/bitkit/viewmodels/AppViewModelSendFlowTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,31 @@ class AppViewModelSendFlowTest : BaseUnitTest() {
verify(paykitPaymentProofRepo, never()).prepare(any(), any(), any(), any(), anyOrNull())
}

@Test
fun `request being paid gets no expired toast when it expires`() = test {
val (request, _) = reopenRetainedHardwareRequest(balanceSats = 1_000_000uL, amountSats = 30_000uL)
val sheet = sut.currentSheet.value
sut.onSheetVisible(sheet)
sut.sendEffect.test {
sut.setSendEvent(SendEvent.SwipeToPay)
advanceUntilIdle()
sut.setSendEvent(SendEvent.PayConfirmed)
advanceUntilIdle()
assertEquals(SendEffect.NavigateToHardwareSign, awaitItem())
cancelAndIgnoreRemainingEvents()
}
clearInvocations(toastManager)

whenever(paykitPaymentRequestRepo.isExpired(request)).thenReturn(true)
pendingPaykitPaymentRequests.value = emptyList()
expiredPaykitProposals.emit(listOf(request))
runCurrent()

val toasts = argumentCaptor<Toast>()
verify(toastManager, atLeast(0)).enqueue(toasts.capture())
assertTrue(toasts.allValues.none { it.testTag == "PaymentRequestExpiredToast" })
}

@Test
fun `reopened refused hardware request locks terms and reaches hardware sign on swipe`() = test {
reopenRetainedHardwareRequest(balanceSats = 1_000_000uL, amountSats = 30_000uL)
Expand Down
Loading