Updated on 2026-08-14
This commit is contained in:
commit
b0649c93df
9 changed files with 164 additions and 95 deletions
|
|
@ -19,6 +19,7 @@ import com.tangem.domain.demo.DemoConfig
|
|||
import com.tangem.domain.networks.single.SingleNetworkStatusFetcher
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.Network
|
||||
import com.tangem.domain.tokens.model.NetworkStatus
|
||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
|
|
@ -76,7 +77,16 @@ internal class DefaultSingleNetworkStatusFetcher @Inject constructor(
|
|||
currencies = networkCurrencies.toSet(),
|
||||
)
|
||||
|
||||
networksStatusesStore.storeActual(userWalletId = params.userWalletId, value = status)
|
||||
val statusValue = status.value
|
||||
if (statusValue is NetworkStatus.Unreachable) {
|
||||
networksStatusesStore.storeError(
|
||||
userWalletId = params.userWalletId,
|
||||
network = params.network,
|
||||
value = statusValue,
|
||||
)
|
||||
} else {
|
||||
networksStatusesStore.storeSuccess(userWalletId = params.userWalletId, value = status)
|
||||
}
|
||||
}
|
||||
.onLeft {
|
||||
Timber.e("Failed to fetch network status for $params: $it")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
internal typealias WalletIdWithSimpleStatus = Map<String, Set<SimpleNetworkStatus>>
|
||||
internal typealias WalletIdWithStatusDM = Map<String, Set<NetworkStatusDM>>
|
||||
|
|
@ -55,35 +56,33 @@ internal class DefaultNetworksStatusesStoreV2(
|
|||
}
|
||||
|
||||
override suspend fun refresh(userWalletId: UserWalletId, network: Network) {
|
||||
updateStatusSourceInRuntime(userWalletId = userWalletId, network = network, source = StatusSource.CACHE)
|
||||
refresh(userWalletId = userWalletId, networks = setOf(network))
|
||||
}
|
||||
|
||||
override suspend fun refresh(userWalletId: UserWalletId, networks: Set<Network>) {
|
||||
val simpleStatusIds = networks.map(SimpleNetworkStatus::Id)
|
||||
if (networks.isEmpty()) {
|
||||
Timber.d("Nothing to refresh: networks is empty")
|
||||
return
|
||||
}
|
||||
|
||||
runtimeStore.update(default = emptyMap()) { stored ->
|
||||
stored.toMutableMap().apply {
|
||||
val storedStatuses = this[userWalletId.stringValue].orEmpty()
|
||||
|
||||
val statuses = simpleStatusIds.mapTo(hashSetOf()) { simpleStatusId ->
|
||||
val status = storedStatuses.firstOrNull { it.id == simpleStatusId }
|
||||
?: createDefaultStatus(id = simpleStatusId)
|
||||
|
||||
status.copy(
|
||||
value = status.value.copySealed(source = StatusSource.CACHE),
|
||||
)
|
||||
}
|
||||
|
||||
val updatedStatuses = storedStatuses.addOrReplace(statuses) { old, new -> old.id == new.id }
|
||||
|
||||
put(key = userWalletId.stringValue, value = updatedStatuses)
|
||||
}
|
||||
updateInRuntime(userWalletId = userWalletId, networks = networks) { status ->
|
||||
status.copy(value = status.value.copySealed(source = StatusSource.CACHE))
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun storeActual(userWalletId: UserWalletId, value: NetworkStatus) {
|
||||
override suspend fun storeSuccess(userWalletId: UserWalletId, value: NetworkStatus) {
|
||||
if (value.value is NetworkStatus.Unreachable) {
|
||||
val message = "Use storeError method to save unreachable status"
|
||||
Timber.d(message)
|
||||
|
||||
error(message)
|
||||
}
|
||||
|
||||
if (value.value.source != StatusSource.ACTUAL) {
|
||||
error("Method storeActual can be called only with StatusSource.ACTUAL")
|
||||
val message = "Method storeActual can be called only with StatusSource.ACTUAL"
|
||||
Timber.d(message)
|
||||
|
||||
error(message)
|
||||
}
|
||||
|
||||
coroutineScope {
|
||||
|
|
@ -92,29 +91,41 @@ internal class DefaultNetworksStatusesStoreV2(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun storeError(userWalletId: UserWalletId, network: Network) {
|
||||
updateStatusSourceInRuntime(userWalletId = userWalletId, network = network, source = StatusSource.ONLY_CACHE)
|
||||
override suspend fun storeError(userWalletId: UserWalletId, network: Network, value: NetworkStatus.Unreachable?) {
|
||||
updateInRuntime(
|
||||
userWalletId = userWalletId,
|
||||
networks = setOf(network),
|
||||
ifNotFound = { id ->
|
||||
value?.let { SimpleNetworkStatus(id = id, value = value) }
|
||||
?: createUnreachableStatus(id = id)
|
||||
},
|
||||
update = { status ->
|
||||
status.copy(value = status.value.copySealed(source = StatusSource.ONLY_CACHE))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun updateStatusSourceInRuntime(
|
||||
private suspend fun updateInRuntime(
|
||||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
source: StatusSource,
|
||||
networks: Set<Network>,
|
||||
ifNotFound: (SimpleNetworkStatus.Id) -> SimpleNetworkStatus? = { null },
|
||||
update: (SimpleNetworkStatus) -> SimpleNetworkStatus,
|
||||
) {
|
||||
val simpleStatusId = SimpleNetworkStatus.Id(network)
|
||||
val simpleStatusIds = networks.map(SimpleNetworkStatus::Id)
|
||||
|
||||
runtimeStore.update(default = emptyMap()) { stored ->
|
||||
stored.toMutableMap().apply {
|
||||
val status = this[userWalletId.stringValue].orEmpty()
|
||||
.firstOrNull { it.id == simpleStatusId }
|
||||
?: createDefaultStatus(id = simpleStatusId)
|
||||
val storedStatuses = this[userWalletId.stringValue].orEmpty()
|
||||
|
||||
val updatedStatus = status.copy(
|
||||
value = status.value.copySealed(source = source),
|
||||
)
|
||||
val statuses = simpleStatusIds.mapNotNullTo(hashSetOf()) { simpleStatusId ->
|
||||
val status = storedStatuses.firstOrNull { it.id == simpleStatusId }
|
||||
?: ifNotFound(simpleStatusId)
|
||||
?: return@mapNotNullTo null
|
||||
|
||||
val updatedStatuses = this[userWalletId.stringValue].orEmpty()
|
||||
.addOrReplace(updatedStatus) { it.id == simpleStatusId }
|
||||
update(status)
|
||||
}
|
||||
|
||||
val updatedStatuses = storedStatuses.addOrReplace(statuses) { old, new -> old.id == new.id }
|
||||
|
||||
put(key = userWalletId.stringValue, value = updatedStatuses)
|
||||
}
|
||||
|
|
@ -151,7 +162,7 @@ internal class DefaultNetworksStatusesStoreV2(
|
|||
}
|
||||
}
|
||||
|
||||
private fun createDefaultStatus(id: SimpleNetworkStatus.Id): SimpleNetworkStatus {
|
||||
private fun createUnreachableStatus(id: SimpleNetworkStatus.Id): SimpleNetworkStatus {
|
||||
return SimpleNetworkStatus(id = id, value = NetworkStatus.Unreachable(address = null))
|
||||
}
|
||||
}
|
||||
|
|
@ -18,9 +18,13 @@ internal interface NetworksStatusesStoreV2 {
|
|||
/** Refresh statuses of [networks] by [userWalletId] */
|
||||
suspend fun refresh(userWalletId: UserWalletId, networks: Set<Network>)
|
||||
|
||||
/** Store actual [NetworkStatus] by [userWalletId] */
|
||||
suspend fun storeActual(userWalletId: UserWalletId, value: NetworkStatus)
|
||||
/** Store success [value] by [userWalletId]. If status's value is unreachable, throws exception */
|
||||
@Throws
|
||||
suspend fun storeSuccess(userWalletId: UserWalletId, value: NetworkStatus)
|
||||
|
||||
/** Store error by [userWalletId] and [network] */
|
||||
suspend fun storeError(userWalletId: UserWalletId, network: Network)
|
||||
/**
|
||||
* Store error [value] by [userWalletId] and [network].
|
||||
* If [value] is null, default unreachable status will be stored.
|
||||
*/
|
||||
suspend fun storeError(userWalletId: UserWalletId, network: Network, value: NetworkStatus.Unreachable? = null)
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ internal class DefaultSingleNetworkStatusFetcherTest {
|
|||
networksStatusesStore.refresh(userWalletId = userWalletId, network = network)
|
||||
userWalletsStore.getSyncStrict(key = userWalletId)
|
||||
walletManagersFacade.update(userWalletId, network, emptySet())
|
||||
networksStatusesStore.storeActual(
|
||||
networksStatusesStore.storeSuccess(
|
||||
userWalletId = userWalletId,
|
||||
value = NetworkStatus(network, NetworkStatus.MissedDerivation),
|
||||
)
|
||||
|
|
@ -82,7 +82,7 @@ internal class DefaultSingleNetworkStatusFetcherTest {
|
|||
|
||||
coVerify(inverse = true) {
|
||||
walletManagersFacade.update(userWalletId = any(), network = any(), extraTokens = any())
|
||||
networksStatusesStore.storeActual(userWalletId = any(), value = any())
|
||||
networksStatusesStore.storeSuccess(userWalletId = any(), value = any())
|
||||
}
|
||||
|
||||
Truth.assertThat(actual.isLeft()).isTrue()
|
||||
|
|
@ -105,7 +105,7 @@ internal class DefaultSingleNetworkStatusFetcherTest {
|
|||
coVerifyOrder {
|
||||
userWalletsStore.getSyncStrict(key = userWalletId)
|
||||
walletManagersFacade.update(userWalletId, network, emptySet())
|
||||
networksStatusesStore.storeActual(
|
||||
networksStatusesStore.storeSuccess(
|
||||
userWalletId = userWalletId,
|
||||
value = NetworkStatus(network, NetworkStatus.MissedDerivation),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -35,14 +35,7 @@ internal class NetworkStatusesStoreUpdateMethodsTest {
|
|||
fun `refresh the single network if runtime store is empty`() = runTest {
|
||||
store.refresh(userWalletId = userWalletId, network = network)
|
||||
|
||||
val runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(
|
||||
SimpleNetworkStatus(
|
||||
id = SimpleNetworkStatus.Id(network),
|
||||
value = NetworkStatus.Unreachable(address = null),
|
||||
),
|
||||
),
|
||||
)
|
||||
val runtimeExpected = mapOf(userWalletId.stringValue to emptySet<NetworkStatus>())
|
||||
|
||||
Truth.assertThat(runtimeStore.getSyncOrNull()).isEqualTo(runtimeExpected)
|
||||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(emptyMap<String, Set<NetworkStatusDM>>())
|
||||
|
|
@ -50,7 +43,7 @@ internal class NetworkStatusesStoreUpdateMethodsTest {
|
|||
|
||||
@Test
|
||||
fun `refresh the single network if runtime store contains status with this network`() = runTest {
|
||||
val status = MockNetworkStatusFactory.createVerified().toSimple()
|
||||
val status = MockNetworkStatusFactory.createVerified(network).toSimple()
|
||||
|
||||
runtimeStore.store(
|
||||
value = mapOf(userWalletId.stringValue to setOf(status)),
|
||||
|
|
@ -72,14 +65,7 @@ internal class NetworkStatusesStoreUpdateMethodsTest {
|
|||
fun `refresh the multi networks if runtime store is empty`() = runTest {
|
||||
store.refresh(userWalletId = userWalletId, networks = networks)
|
||||
|
||||
val runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to networks.mapTo(hashSetOf()) {
|
||||
SimpleNetworkStatus(
|
||||
id = SimpleNetworkStatus.Id(it),
|
||||
value = NetworkStatus.Unreachable(address = null),
|
||||
)
|
||||
},
|
||||
)
|
||||
val runtimeExpected = mapOf(userWalletId.stringValue to emptySet<NetworkStatus>())
|
||||
|
||||
Truth.assertThat(runtimeStore.getSyncOrNull()).isEqualTo(runtimeExpected)
|
||||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(emptyMap<String, Set<NetworkStatusDM>>())
|
||||
|
|
@ -112,41 +98,50 @@ internal class NetworkStatusesStoreUpdateMethodsTest {
|
|||
val expectedErrorMessage = "Method storeActual can be called only with StatusSource.ACTUAL"
|
||||
|
||||
// #1: StatusSource.ACTUAL
|
||||
val status = MockNetworkStatusFactory.createVerified().copy(
|
||||
value = MockNetworkStatusFactory.createVerified().value.copySealed(source = StatusSource.ACTUAL),
|
||||
val status = MockNetworkStatusFactory.createVerified(network).copy(
|
||||
value = MockNetworkStatusFactory.createVerified(network).value.copySealed(source = StatusSource.ACTUAL),
|
||||
)
|
||||
|
||||
val actual = runCatching { store.storeActual(userWalletId, status) }
|
||||
val actual = runCatching { store.storeSuccess(userWalletId, status) }
|
||||
|
||||
val runtimeExpected = mapOf(userWalletId.stringValue to setOf(status.toSimple()))
|
||||
val persistenceExpected = mapOf(userWalletId.stringValue to setOf(status.toDataModel()!!))
|
||||
|
||||
Truth.assertThat(actual.isSuccess).isTrue()
|
||||
Truth.assertThat(runtimeStore.getSyncOrNull()).isEqualTo(runtimeExpected)
|
||||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(persistenceExpected)
|
||||
|
||||
// #2: StatusSource.CACHE
|
||||
val cacheStatus = MockNetworkStatusFactory.createVerified().copy(
|
||||
value = MockNetworkStatusFactory.createVerified().value.copySealed(source = StatusSource.CACHE),
|
||||
val cacheStatus = MockNetworkStatusFactory.createVerified(network).copy(
|
||||
value = MockNetworkStatusFactory.createVerified(network).value.copySealed(source = StatusSource.CACHE),
|
||||
)
|
||||
|
||||
val cacheActual = runCatching { store.storeActual(userWalletId, cacheStatus) }
|
||||
val cacheActual = runCatching { store.storeSuccess(userWalletId, cacheStatus) }
|
||||
|
||||
Truth.assertThat(cacheActual.isFailure).isTrue()
|
||||
Truth.assertThat(cacheActual.exceptionOrNull()).isInstanceOf(IllegalStateException::class.java)
|
||||
Truth.assertThat(cacheActual.exceptionOrNull()).hasMessageThat().isEqualTo(expectedErrorMessage)
|
||||
Truth.assertThat(runtimeStore.getSyncOrNull()).isEqualTo(runtimeExpected)
|
||||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(persistenceExpected)
|
||||
|
||||
// #3: StatusSource.ONLY_CACHE
|
||||
val onlyCacheStatus = MockNetworkStatusFactory.createVerified().copy(
|
||||
value = MockNetworkStatusFactory.createVerified().value.copySealed(source = StatusSource.ONLY_CACHE),
|
||||
val onlyCacheStatus = MockNetworkStatusFactory.createVerified(network).copy(
|
||||
value = MockNetworkStatusFactory.createVerified(network).value.copySealed(source = StatusSource.ONLY_CACHE),
|
||||
)
|
||||
|
||||
val onlyCacheActual = runCatching { store.storeActual(userWalletId, onlyCacheStatus) }
|
||||
val onlyCacheActual = runCatching { store.storeSuccess(userWalletId, onlyCacheStatus) }
|
||||
|
||||
Truth.assertThat(onlyCacheActual.isFailure).isTrue()
|
||||
Truth.assertThat(onlyCacheActual.exceptionOrNull()).isInstanceOf(IllegalStateException::class.java)
|
||||
Truth.assertThat(onlyCacheActual.exceptionOrNull()).hasMessageThat().isEqualTo(expectedErrorMessage)
|
||||
Truth.assertThat(runtimeStore.getSyncOrNull()).isEqualTo(runtimeExpected)
|
||||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(persistenceExpected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `store actual if runtime and cache stores contain status with this network`() = runTest {
|
||||
val prevStatus = MockNetworkStatusFactory.createVerified().copy(
|
||||
value = MockNetworkStatusFactory.createVerified().value.copySealed(source = StatusSource.ONLY_CACHE),
|
||||
val prevStatus = MockNetworkStatusFactory.createVerified(network).copy(
|
||||
value = MockNetworkStatusFactory.createVerified(network).value.copySealed(source = StatusSource.ONLY_CACHE),
|
||||
)
|
||||
|
||||
runtimeStore.store(
|
||||
|
|
@ -159,11 +154,11 @@ internal class NetworkStatusesStoreUpdateMethodsTest {
|
|||
}
|
||||
}
|
||||
|
||||
val newStatus = MockNetworkStatusFactory.createVerified().copy(
|
||||
value = MockNetworkStatusFactory.createVerified().value.copySealed(source = StatusSource.ACTUAL),
|
||||
val newStatus = MockNetworkStatusFactory.createVerified(network).copy(
|
||||
value = MockNetworkStatusFactory.createVerified(network).value.copySealed(source = StatusSource.ACTUAL),
|
||||
)
|
||||
|
||||
store.storeActual(userWalletId, newStatus)
|
||||
store.storeSuccess(userWalletId, newStatus)
|
||||
|
||||
val runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(newStatus.toSimple()),
|
||||
|
|
@ -179,7 +174,7 @@ internal class NetworkStatusesStoreUpdateMethodsTest {
|
|||
|
||||
@Test
|
||||
fun `store actual unreachable status if cache store contains verified status`() = runTest {
|
||||
val prevStatus = MockNetworkStatusFactory.createVerified()
|
||||
val prevStatus = MockNetworkStatusFactory.createVerified(network)
|
||||
|
||||
runtimeStore.store(
|
||||
value = mapOf(userWalletId.stringValue to setOf(prevStatus.toSimple())),
|
||||
|
|
@ -191,18 +186,17 @@ internal class NetworkStatusesStoreUpdateMethodsTest {
|
|||
}
|
||||
}
|
||||
|
||||
val newStatus = MockNetworkStatusFactory.createUnreachable()
|
||||
val newStatus = MockNetworkStatusFactory.createUnreachable(network)
|
||||
|
||||
store.storeActual(userWalletId, newStatus)
|
||||
val actual = runCatching { store.storeSuccess(userWalletId, newStatus) }
|
||||
|
||||
val runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(newStatus.toSimple()),
|
||||
)
|
||||
|
||||
val persistenceExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(prevStatus.toDataModel()!!),
|
||||
)
|
||||
val expectedErrorMessage = "Use storeError method to save unreachable status"
|
||||
val runtimeExpected = mapOf(userWalletId.stringValue to setOf(prevStatus.toSimple()))
|
||||
val persistenceExpected = mapOf(userWalletId.stringValue to setOf(prevStatus.toDataModel()!!))
|
||||
|
||||
Truth.assertThat(actual.isFailure).isTrue()
|
||||
Truth.assertThat(actual.exceptionOrNull()).isInstanceOf(IllegalStateException::class.java)
|
||||
Truth.assertThat(actual.exceptionOrNull()).hasMessageThat().isEqualTo(expectedErrorMessage)
|
||||
Truth.assertThat(runtimeStore.getSyncOrNull()).isEqualTo(runtimeExpected)
|
||||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(persistenceExpected)
|
||||
}
|
||||
|
|
@ -226,7 +220,7 @@ internal class NetworkStatusesStoreUpdateMethodsTest {
|
|||
|
||||
@Test
|
||||
fun `store error if runtime store contains status with this network`() = runTest {
|
||||
val status = MockNetworkStatusFactory.createVerified().toSimple()
|
||||
val status = MockNetworkStatusFactory.createVerified(network).toSimple()
|
||||
|
||||
runtimeStore.store(
|
||||
value = mapOf(userWalletId.stringValue to setOf(status)),
|
||||
|
|
@ -244,6 +238,48 @@ internal class NetworkStatusesStoreUpdateMethodsTest {
|
|||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(emptyMap<String, Set<NetworkStatusDM>>())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `store error if runtime store is empty and unreachable status was passed`() = runTest {
|
||||
val status = MockNetworkStatusFactory.createUnreachable(network)
|
||||
|
||||
store.storeError(
|
||||
userWalletId = userWalletId,
|
||||
network = network,
|
||||
value = status.value as NetworkStatus.Unreachable,
|
||||
)
|
||||
|
||||
val runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(status.toSimple()),
|
||||
)
|
||||
|
||||
Truth.assertThat(runtimeStore.getSyncOrNull()).isEqualTo(runtimeExpected)
|
||||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(emptyMap<String, Set<NetworkStatusDM>>())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `store error if runtime store contains status with this network and unreachable status was passed`() = runTest {
|
||||
val status = MockNetworkStatusFactory.createVerified(network)
|
||||
|
||||
runtimeStore.store(
|
||||
value = mapOf(userWalletId.stringValue to setOf(status.toSimple())),
|
||||
)
|
||||
|
||||
store.storeError(
|
||||
userWalletId = userWalletId,
|
||||
network = network,
|
||||
value = MockNetworkStatusFactory.createUnreachable(network).value as NetworkStatus.Unreachable,
|
||||
)
|
||||
|
||||
val runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(
|
||||
status.copy(value = status.value.copySealed(source = StatusSource.ONLY_CACHE)).toSimple(),
|
||||
),
|
||||
)
|
||||
|
||||
Truth.assertThat(runtimeStore.getSyncOrNull()).isEqualTo(runtimeExpected)
|
||||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(emptyMap<String, Set<NetworkStatusDM>>())
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
val userWalletId = UserWalletId(stringValue = "011")
|
||||
|
|
|
|||
|
|
@ -33,15 +33,16 @@ internal class StoreActualNetworkStatusTest(private val model: Model) {
|
|||
|
||||
@Test
|
||||
fun `store actual`() = runTest {
|
||||
store.storeActual(userWalletId = userWalletId, value = model.status)
|
||||
val actual = runCatching { store.storeSuccess(userWalletId = userWalletId, value = model.status) }
|
||||
|
||||
Truth.assertThat(actual.isSuccess).isEqualTo(model.isSuccess)
|
||||
Truth.assertThat(runtimeStore.getSyncOrNull()).isEqualTo(model.runtimeExpected)
|
||||
|
||||
Truth.assertThat(persistenceStore.data.firstOrNull()).isEqualTo(model.persistenceExpected)
|
||||
}
|
||||
|
||||
data class Model(
|
||||
val status: NetworkStatus,
|
||||
val isSuccess: Boolean,
|
||||
val runtimeExpected: Map<String, Set<SimpleNetworkStatus>>,
|
||||
val persistenceExpected: WalletIdWithStatusDM,
|
||||
)
|
||||
|
|
@ -56,6 +57,7 @@ internal class StoreActualNetworkStatusTest(private val model: Model) {
|
|||
return listOf(
|
||||
Model(
|
||||
status = MockNetworkStatusFactory.createVerified(),
|
||||
isSuccess = true,
|
||||
runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(
|
||||
MockNetworkStatusFactory.createVerified().toSimple(),
|
||||
|
|
@ -69,6 +71,7 @@ internal class StoreActualNetworkStatusTest(private val model: Model) {
|
|||
),
|
||||
Model(
|
||||
status = MockNetworkStatusFactory.createNoAccount(),
|
||||
isSuccess = true,
|
||||
runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(
|
||||
MockNetworkStatusFactory.createNoAccount().toSimple(),
|
||||
|
|
@ -82,6 +85,7 @@ internal class StoreActualNetworkStatusTest(private val model: Model) {
|
|||
),
|
||||
Model(
|
||||
status = MockNetworkStatusFactory.createMissedDerivation(),
|
||||
isSuccess = true,
|
||||
runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(
|
||||
MockNetworkStatusFactory.createMissedDerivation().toSimple(),
|
||||
|
|
@ -91,11 +95,8 @@ internal class StoreActualNetworkStatusTest(private val model: Model) {
|
|||
),
|
||||
Model(
|
||||
status = MockNetworkStatusFactory.createUnreachable(),
|
||||
runtimeExpected = mapOf(
|
||||
userWalletId.stringValue to setOf(
|
||||
MockNetworkStatusFactory.createUnreachable().toSimple(),
|
||||
),
|
||||
),
|
||||
isSuccess = false,
|
||||
runtimeExpected = mapOf(),
|
||||
persistenceExpected = mapOf(),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ internal class UserWalletSaver @Inject constructor(
|
|||
scanCardProcessor.scan(
|
||||
analyticsSource = AnalyticsParam.ScreensSources.Settings,
|
||||
onWalletNotCreated = {
|
||||
/* no-op */
|
||||
continuation.resume(Either.Right(null))
|
||||
},
|
||||
disclaimerWillShow = {
|
||||
continuation.resume(Either.Right(null))
|
||||
|
|
|
|||
|
|
@ -859,7 +859,7 @@ internal class StateBuilder(
|
|||
add(
|
||||
resourceReference(
|
||||
id = R.string.swapping_alert_dex_description_with_slippage,
|
||||
formatArgs = wrappedList(token, slippage),
|
||||
formatArgs = wrappedList(slippage),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -374,6 +374,13 @@ internal class WalletModel @Inject constructor(
|
|||
coroutineScope = modelScope,
|
||||
)
|
||||
|
||||
if (action.selectedWallet.scanResponse.cardTypesResolver.isSingleWallet()) {
|
||||
modelScope.launch {
|
||||
fetchCurrencyStatusUseCase(userWalletId = action.selectedWallet.walletId)
|
||||
.onLeft { Timber.e(it.toString()) }
|
||||
}
|
||||
}
|
||||
|
||||
stateHolder.update(
|
||||
AddWalletTransformer(
|
||||
userWallet = action.selectedWallet,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue