Updated on 2026-08-14
This commit is contained in:
commit
50fe9e603d
1919 changed files with 94940 additions and 15178 deletions
|
|
@ -3,10 +3,23 @@ plugins {
|
|||
id("configuration")
|
||||
}
|
||||
dependencies {
|
||||
/** Domain modules */
|
||||
api(projects.domain.core)
|
||||
api(projects.domain.models)
|
||||
|
||||
/** Test libraries */
|
||||
testImplementation(projects.test.core)
|
||||
// region Other libraries
|
||||
api(deps.arrow.core)
|
||||
// endregion
|
||||
|
||||
// region Core modules
|
||||
implementation(projects.core.utils)
|
||||
// endregion
|
||||
|
||||
// region Domain models
|
||||
api(projects.domain.models)
|
||||
// endregion
|
||||
|
||||
// region Tests
|
||||
testImplementation(deps.test.coroutine)
|
||||
testImplementation(deps.test.junit5)
|
||||
testImplementation(deps.test.mockk)
|
||||
testImplementation(deps.test.truth)
|
||||
// endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.domain.offramp.model
|
||||
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* A locally-recorded marker that the app itself initiated a sell (off-ramp) flow.
|
||||
|
|
@ -19,4 +20,13 @@ data class PendingOfframp(
|
|||
val userWalletId: UserWalletId,
|
||||
val currencyId: String,
|
||||
val createdAt: Long,
|
||||
)
|
||||
) {
|
||||
|
||||
/** Whether the record is past its expiry at [nowMillis] and can no longer authenticate a redirect. */
|
||||
fun isExpired(nowMillis: Long): Boolean = nowMillis - createdAt >= EXPIRY_MS
|
||||
|
||||
companion object {
|
||||
/** How long a pending sell stays valid after registration. */
|
||||
val EXPIRY_MS: Long = TimeUnit.HOURS.toMillis(1)
|
||||
}
|
||||
}
|
||||
|
|
@ -45,4 +45,13 @@ interface OfframpRepository {
|
|||
userWalletId: UserWalletId,
|
||||
currencyId: String,
|
||||
): PendingOfframp?
|
||||
|
||||
/**
|
||||
* Returns every stored app-initiated sell — **including expired ones** that have not been pruned yet (read-only;
|
||||
* does not mutate the store). Use [PendingOfframp.isExpired] to tell them apart.
|
||||
*
|
||||
* Intended for QA/tester tooling that needs to reproduce a returning `redirect_sell` deeplink from a real,
|
||||
* app-registered sell and to inspect stale records.
|
||||
*/
|
||||
suspend fun getAllStoredOfframps(): List<PendingOfframp>
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.tangem.domain.offramp.model
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class PendingOfframpTest {
|
||||
|
||||
@Test
|
||||
fun `GIVEN record younger than expiry WHEN isExpired THEN returns false`() {
|
||||
// Arrange
|
||||
val now = 10_000_000L
|
||||
val offramp = createOfframp(createdAt = now - PendingOfframp.EXPIRY_MS + 1)
|
||||
|
||||
// Act & Assert
|
||||
assertThat(offramp.isExpired(now)).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN record exactly at expiry WHEN isExpired THEN returns true`() {
|
||||
// Arrange
|
||||
val now = 10_000_000L
|
||||
val offramp = createOfframp(createdAt = now - PendingOfframp.EXPIRY_MS)
|
||||
|
||||
// Act & Assert
|
||||
assertThat(offramp.isExpired(now)).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN record older than expiry WHEN isExpired THEN returns true`() {
|
||||
// Arrange
|
||||
val now = 10_000_000L
|
||||
val offramp = createOfframp(createdAt = now - PendingOfframp.EXPIRY_MS - 1)
|
||||
|
||||
// Act & Assert
|
||||
assertThat(offramp.isExpired(now)).isTrue()
|
||||
}
|
||||
|
||||
private fun createOfframp(createdAt: Long) = PendingOfframp(
|
||||
requestId = "request-id",
|
||||
userWalletId = UserWalletId("0011223344556677"),
|
||||
currencyId = "bitcoin",
|
||||
createdAt = createdAt,
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue