Skip to content

Commit

Permalink
PWN-8969 - renamed function
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardmaximovich committed Jun 23, 2023
1 parent 1cda84c commit 6e4f2d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ class StrigaSmsInputInteractor(
}

private fun isExceededVerificationAttempts(): Boolean {
return !DateTimeUtils.checkTimerIsOver(
return !DateTimeUtils.isTimestampExpired(
strigaStorage.smsExceededVerificationAttemptsMillis,
EXCEEDED_VERIFICATION_ATTEMPTS_TIMEOUT_MILLIS
)
}

private fun isExceededResendAttempts(): Boolean {
return !DateTimeUtils.checkTimerIsOver(
return !DateTimeUtils.isTimestampExpired(
strigaStorage.smsExceededResendAttemptsMillis,
EXCEEDED_RESEND_ATTEMPTS_TIMEOUT_MILLIS
)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/p2p/wallet/utils/DateTimeUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ object DateTimeUtils {
return String.format(Locale.US, "%02d:%02d", m, s)
}

fun checkTimerIsOver(timeMs: Long, expireDurationMs: Long): Boolean {
fun isTimestampExpired(timeMs: Long, expireDurationMs: Long): Boolean {
return timeMs == 0L || System.currentTimeMillis() - timeMs >= expireDurationMs
}

Expand Down
16 changes: 8 additions & 8 deletions app/src/test/java/org/p2p/wallet/utils/DateTimeUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ import kotlin.time.Duration.Companion.seconds
class DateTimeUtilsTest {

@Test
fun `GIVEN initial timer with 10 seconds expiration WHEN checkTimerIsOver THEN check time is not over`() {
fun `GIVEN initial timer with 10 seconds expiration WHEN isTimestampExpired THEN check time is not over`() {
val savedTime = System.currentTimeMillis()
val expiration = 10.seconds.inWholeMilliseconds

assertFalse(
DateTimeUtils.checkTimerIsOver(savedTime, expiration)
DateTimeUtils.isTimestampExpired(savedTime, expiration)
)
}

@Test
fun `GIVEN almost expired timer with 10 seconds expiration WHEN checkTimerIsOver THEN check time is not over`() {
fun `GIVEN almost expired timer with 10 seconds expiration WHEN isTimestampExpired THEN check time is not over`() {
val expiration = 10.seconds.inWholeMilliseconds
val savedTime = System.currentTimeMillis() - 9.5.seconds.inWholeMilliseconds

assertFalse(
DateTimeUtils.checkTimerIsOver(savedTime, expiration)
DateTimeUtils.isTimestampExpired(savedTime, expiration)
)
}

@Test
fun `GIVEN expired timer with 10 seconds expiration WHEN checkTimerIsOver THEN check time is over`() {
fun `GIVEN expired timer with 10 seconds expiration WHEN isTimestampExpired THEN check time is over`() {
val expiration = 10.seconds.inWholeMilliseconds
val savedTime = System.currentTimeMillis() - expiration

assertTrue(
DateTimeUtils.checkTimerIsOver(savedTime, expiration)
DateTimeUtils.isTimestampExpired(savedTime, expiration)
)
}

Expand All @@ -44,7 +44,7 @@ class DateTimeUtilsTest {
val savedTime = System.currentTimeMillis() - 1.days.inWholeMilliseconds

assertTrue(
DateTimeUtils.checkTimerIsOver(savedTime, expiration)
DateTimeUtils.isTimestampExpired(savedTime, expiration)
)
}

Expand All @@ -54,7 +54,7 @@ class DateTimeUtilsTest {
val savedTime = 0L

assertTrue(
DateTimeUtils.checkTimerIsOver(savedTime, expiration)
DateTimeUtils.isTimestampExpired(savedTime, expiration)
)
}
}

0 comments on commit 6e4f2d5

Please sign in to comment.