Updated on 2026-08-14
This commit is contained in:
parent
21418379dd
commit
3c48cdf744
5 changed files with 33 additions and 13 deletions
|
|
@ -78,9 +78,10 @@ data class ExchangeItemResponse(
|
||||||
@Json(name = "createdAt")
|
@Json(name = "createdAt")
|
||||||
val createdAt: String,
|
val createdAt: String,
|
||||||
|
|
||||||
/** Transaction last-update timestamp in ISO-8601 format */
|
// todo txHistory backend does not send `updatedAt` yet — uncomment once it does.
|
||||||
@Json(name = "updatedAt")
|
// /** Transaction last-update timestamp in ISO-8601 format */
|
||||||
val updatedAt: String,
|
// @Json(name = "updatedAt")
|
||||||
|
// val updatedAt: String,
|
||||||
|
|
||||||
/** Pay-in expiration timestamp in ISO-8601 format */
|
/** Pay-in expiration timestamp in ISO-8601 format */
|
||||||
@Json(name = "payTill")
|
@Json(name = "payTill")
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,10 @@ data class OnrampItemResponse(
|
||||||
@Json(name = "createdAt")
|
@Json(name = "createdAt")
|
||||||
val createdAt: String,
|
val createdAt: String,
|
||||||
|
|
||||||
/** Transaction last-update timestamp in ISO-8601 format */
|
// todo txHistory backend does not send `updatedAt` yet — uncomment once it does.
|
||||||
@Json(name = "updatedAt")
|
// /** Transaction last-update timestamp in ISO-8601 format */
|
||||||
val updatedAt: String,
|
// @Json(name = "updatedAt")
|
||||||
|
// val updatedAt: String,
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region fromAsset (fiat) info
|
// region fromAsset (fiat) info
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@ import com.tangem.datasource.api.express.models.response.ExchangeItemResponse
|
||||||
import com.tangem.datasource.api.onramp.models.response.OnrampItemResponse
|
import com.tangem.datasource.api.onramp.models.response.OnrampItemResponse
|
||||||
import com.tangem.datasource.local.txhistory.db.entity.express.ExpressExchangeEntity
|
import com.tangem.datasource.local.txhistory.db.entity.express.ExpressExchangeEntity
|
||||||
import com.tangem.datasource.local.txhistory.db.entity.express.ExpressOnrampEntity
|
import com.tangem.datasource.local.txhistory.db.entity.express.ExpressOnrampEntity
|
||||||
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
|
// todo txHistory backend does not send `updatedAt` yet — drop this placeholder and map the real
|
||||||
|
// ExchangeItemResponse.updatedAt / OnrampItemResponse.updatedAt once it does.
|
||||||
|
private fun updatedAtPlaceholder(): String = DateTime.now().toString()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps API history items into their persisted [androidx.room.Entity] representations.
|
* Maps API history items into their persisted [androidx.room.Entity] representations.
|
||||||
|
|
@ -30,7 +35,7 @@ fun ExchangeItemResponse.toEntity(): ExpressExchangeEntity? {
|
||||||
refundNetwork = refundNetwork,
|
refundNetwork = refundNetwork,
|
||||||
refundContractAddress = refundContractAddress,
|
refundContractAddress = refundContractAddress,
|
||||||
createdAt = createdAt,
|
createdAt = createdAt,
|
||||||
updatedAt = updatedAt,
|
updatedAt = updatedAtPlaceholder(),
|
||||||
payTill = payTill,
|
payTill = payTill,
|
||||||
averageDuration = averageDuration,
|
averageDuration = averageDuration,
|
||||||
from = ExpressExchangeEntity.AssetEmbedded(
|
from = ExpressExchangeEntity.AssetEmbedded(
|
||||||
|
|
@ -61,7 +66,7 @@ fun OnrampItemResponse.toEntity(): ExpressOnrampEntity {
|
||||||
externalTxUrl = externalTxUrl,
|
externalTxUrl = externalTxUrl,
|
||||||
payoutHash = payoutHash,
|
payoutHash = payoutHash,
|
||||||
createdAt = createdAt,
|
createdAt = createdAt,
|
||||||
updatedAt = updatedAt,
|
updatedAt = updatedAtPlaceholder(),
|
||||||
fromCurrencyCode = fromCurrencyCode,
|
fromCurrencyCode = fromCurrencyCode,
|
||||||
fromAmount = fromAmount,
|
fromAmount = fromAmount,
|
||||||
fromPrecision = fromPrecision,
|
fromPrecision = fromPrecision,
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ internal class ExpressHistoryConverterTest {
|
||||||
Truth.assertThat(entity.refundNetwork).isEqualTo(item.refundNetwork)
|
Truth.assertThat(entity.refundNetwork).isEqualTo(item.refundNetwork)
|
||||||
Truth.assertThat(entity.refundContractAddress).isEqualTo(item.refundContractAddress)
|
Truth.assertThat(entity.refundContractAddress).isEqualTo(item.refundContractAddress)
|
||||||
Truth.assertThat(entity.createdAt).isEqualTo(item.createdAt)
|
Truth.assertThat(entity.createdAt).isEqualTo(item.createdAt)
|
||||||
Truth.assertThat(entity.updatedAt).isEqualTo(item.updatedAt)
|
// todo txHistory uncomment
|
||||||
|
// Truth.assertThat(entity.updatedAt).isEqualTo(item.updatedAt)
|
||||||
Truth.assertThat(entity.payTill).isEqualTo(item.payTill)
|
Truth.assertThat(entity.payTill).isEqualTo(item.payTill)
|
||||||
Truth.assertThat(entity.averageDuration).isEqualTo(item.averageDuration)
|
Truth.assertThat(entity.averageDuration).isEqualTo(item.averageDuration)
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +233,8 @@ internal class ExpressHistoryConverterTest {
|
||||||
refundNetwork = refundNetwork,
|
refundNetwork = refundNetwork,
|
||||||
refundContractAddress = refundContractAddress,
|
refundContractAddress = refundContractAddress,
|
||||||
createdAt = "2026-06-01T00:00:00Z",
|
createdAt = "2026-06-01T00:00:00Z",
|
||||||
updatedAt = "2026-06-01T00:05:00Z",
|
// todo txHistory uncomment
|
||||||
|
// updatedAt = "2026-06-01T00:05:00Z",
|
||||||
payTill = payTill,
|
payTill = payTill,
|
||||||
averageDuration = averageDuration,
|
averageDuration = averageDuration,
|
||||||
fromContractAddress = "0xfromContract",
|
fromContractAddress = "0xfromContract",
|
||||||
|
|
@ -264,7 +266,8 @@ internal class ExpressHistoryConverterTest {
|
||||||
externalTxUrl = externalTxUrl,
|
externalTxUrl = externalTxUrl,
|
||||||
payoutHash = payoutHash,
|
payoutHash = payoutHash,
|
||||||
createdAt = "2026-06-01T00:00:00Z",
|
createdAt = "2026-06-01T00:00:00Z",
|
||||||
updatedAt = "2026-06-01T00:05:00Z",
|
// todo txHistory uncomment
|
||||||
|
// updatedAt = "2026-06-01T00:05:00Z",
|
||||||
fromCurrencyCode = "USD",
|
fromCurrencyCode = "USD",
|
||||||
fromAmount = "100.0",
|
fromAmount = "100.0",
|
||||||
fromPrecision = 2,
|
fromPrecision = 2,
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import io.mockk.slot
|
||||||
import io.mockk.unmockkStatic
|
import io.mockk.unmockkStatic
|
||||||
import kotlinx.coroutines.flow.flowOf
|
import kotlinx.coroutines.flow.flowOf
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.joda.time.DateTimeUtils
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
@ -67,6 +68,9 @@ internal class DefaultExpressHistoryRepositoryTest {
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setup() {
|
fun setup() {
|
||||||
clearMocks(exchangeApi, onrampApi, expressHistoryDao, historyIndexDao, expressSyncStateDao, tokenInfoRepository)
|
clearMocks(exchangeApi, onrampApi, expressHistoryDao, historyIndexDao, expressSyncStateDao, tokenInfoRepository)
|
||||||
|
// todo txHistory the persisted `updatedAt` is a `DateTime.now()` placeholder until the backend sends it;
|
||||||
|
// freeze the clock so the entity built inside the repository matches the one rebuilt in verify blocks.
|
||||||
|
DateTimeUtils.setCurrentMillisFixed(FIXED_NOW_MILLIS)
|
||||||
// Run the withTransaction block inline so the DAO writes inside it actually happen and can be verified.
|
// Run the withTransaction block inline so the DAO writes inside it actually happen and can be verified.
|
||||||
mockkStatic("androidx.room.RoomDatabaseKt")
|
mockkStatic("androidx.room.RoomDatabaseKt")
|
||||||
val block = slot<suspend () -> Any?>()
|
val block = slot<suspend () -> Any?>()
|
||||||
|
|
@ -75,6 +79,7 @@ internal class DefaultExpressHistoryRepositoryTest {
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
fun tearDown() {
|
fun tearDown() {
|
||||||
|
DateTimeUtils.setCurrentMillisSystem()
|
||||||
unmockkStatic("androidx.room.RoomDatabaseKt")
|
unmockkStatic("androidx.room.RoomDatabaseKt")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -333,7 +338,8 @@ internal class DefaultExpressHistoryRepositoryTest {
|
||||||
refundNetwork = null,
|
refundNetwork = null,
|
||||||
refundContractAddress = null,
|
refundContractAddress = null,
|
||||||
createdAt = "2026-06-01T00:00:00Z",
|
createdAt = "2026-06-01T00:00:00Z",
|
||||||
updatedAt = "2026-06-01T00:00:00Z",
|
// todo txHistory uncomment
|
||||||
|
// updatedAt = "2026-06-01T00:00:00Z",
|
||||||
payTill = null,
|
payTill = null,
|
||||||
averageDuration = null,
|
averageDuration = null,
|
||||||
fromContractAddress = "0xfromContract",
|
fromContractAddress = "0xfromContract",
|
||||||
|
|
@ -357,7 +363,8 @@ internal class DefaultExpressHistoryRepositoryTest {
|
||||||
externalTxUrl = null,
|
externalTxUrl = null,
|
||||||
payoutHash = "payout-hash",
|
payoutHash = "payout-hash",
|
||||||
createdAt = "2026-06-01T00:00:00Z",
|
createdAt = "2026-06-01T00:00:00Z",
|
||||||
updatedAt = "2026-06-01T00:00:00Z",
|
// todo txHistory uncomment
|
||||||
|
// updatedAt = "2026-06-01T00:00:00Z",
|
||||||
fromCurrencyCode = "USD",
|
fromCurrencyCode = "USD",
|
||||||
fromAmount = "100.0",
|
fromAmount = "100.0",
|
||||||
fromPrecision = 2,
|
fromPrecision = 2,
|
||||||
|
|
@ -377,5 +384,8 @@ internal class DefaultExpressHistoryRepositoryTest {
|
||||||
const val AFTER_CURSOR = "after-cursor"
|
const val AFTER_CURSOR = "after-cursor"
|
||||||
const val DELTA_CURSOR = "delta-cursor"
|
const val DELTA_CURSOR = "delta-cursor"
|
||||||
const val DEFAULT_LIMIT = 100
|
const val DEFAULT_LIMIT = 100
|
||||||
|
|
||||||
|
// Fixed instant the Joda clock is pinned to during each test (2026-06-01T00:00:00Z).
|
||||||
|
const val FIXED_NOW_MILLIS = 1_780_272_000_000L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue