Skip to content

Commit

Permalink
Merge pull request #444 from sora-xor/mwr-1031
Browse files Browse the repository at this point in the history
Mwr-1031
  • Loading branch information
arvifox authored Nov 1, 2024
2 parents d5ac6d4 + ed878d3 commit eb1c522
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 19 deletions.
10 changes: 6 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ kotlin {
jvmToolchain(17)
}

// soralution 142 3.8.6.2 2024.10.30
// soralution 143 3.8.6.3 2024.10.31
// sora dae 118 3.8.5.3 2024.10.23

android {
Expand All @@ -30,8 +30,8 @@ android {
applicationId = "jp.co.soramitsu.sora"
minSdk = 26
targetSdk = 34
versionCode = System.getenv("CI_BUILD_ID")?.toInt() ?: 142
versionName = "3.8.6.2"
versionCode = System.getenv("CI_BUILD_ID")?.toInt() ?: 143
versionName = "3.8.6.3"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
// resConfigs "en", "ru", "es", "fr", "de", "nb", "in", "tr", "ar"
Expand Down Expand Up @@ -172,7 +172,7 @@ play {
serviceAccountCredentials = file(System.getenv("CI_PLAY_KEY") ?: "../key/fake.json")
track = "internal"
releaseStatus = ReleaseStatus.DRAFT
releaseName = "3.8.6.2 - SORA Card Improvements"
releaseName = "3.8.6.3 - SORA Card Improvements"
defaultToAppBundles = true
}

Expand Down Expand Up @@ -239,11 +239,13 @@ dependencies {

implementation(libs.webSocketLibDep)

testImplementation(project(":test_data"))
testImplementation(libs.coroutineTestDep)
testImplementation(libs.junitDep)
testImplementation(libs.mockkDep)
testImplementation(libs.mockitoKotlinDep)
testImplementation(libs.archCoreTestDep)
testImplementation(libs.truthDep)

kover(project(":common"))
kover(project(":common_wallet"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class MigrationManager @Inject constructor(
FirebaseWrapper.log("Migration ma done")
}
}
userRepository.defaultGlobalCards()
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import jp.co.soramitsu.androidfoundation.coroutine.CoroutineManager
import jp.co.soramitsu.androidfoundation.fragment.SingleLiveEvent
import jp.co.soramitsu.androidfoundation.fragment.trigger
import jp.co.soramitsu.common.logger.FirebaseWrapper
Expand All @@ -49,6 +50,7 @@ import kotlinx.coroutines.launch
@HiltViewModel
class SplashViewModel @Inject constructor(
private val interactor: SplashInteractor,
coroutineManager: CoroutineManager,
) : BaseViewModel() {

private val _runtimeInitiated = MutableLiveData<Boolean>()
Expand All @@ -73,7 +75,7 @@ class SplashViewModel @Inject constructor(
loadingTextVisiblity.trigger()
}
}
viewModelScope.launch {
viewModelScope.launch(coroutineManager.io) {
interactor.checkMigration()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ package jp.co.soramitsu.sora.splash.presentation
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import io.mockk.every
import io.mockk.mockkObject
import jp.co.soramitsu.androidfoundation.coroutine.CoroutineManager
import jp.co.soramitsu.androidfoundation.testing.MainCoroutineRule
import jp.co.soramitsu.androidfoundation.testing.getOrAwaitValue
import jp.co.soramitsu.common.logger.FirebaseWrapper
import jp.co.soramitsu.feature_account_api.domain.model.OnboardingState
import jp.co.soramitsu.sora.splash.domain.SplashInteractor
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
Expand All @@ -53,6 +55,7 @@ import org.junit.runner.RunWith
import org.mockito.BDDMockito.given
import org.mockito.Mock
import org.mockito.junit.MockitoJUnitRunner
import org.mockito.kotlin.whenever

@ExperimentalCoroutinesApi
@RunWith(MockitoJUnitRunner::class)
Expand All @@ -68,13 +71,18 @@ class SplashViewModelTest {
@Mock
private lateinit var interactor: SplashInteractor

@Mock
private lateinit var coroutineManager: CoroutineManager

private lateinit var splashViewModel: SplashViewModel

@OptIn(ExperimentalStdlibApi::class)
@Before
fun setUp() {
fun setUp() = runTest {
mockkObject(FirebaseWrapper)
every { FirebaseWrapper.log("Splash next screen true") } returns Unit
splashViewModel = SplashViewModel(interactor)
whenever(coroutineManager.io).thenReturn(this.coroutineContext[CoroutineDispatcher]!!)
splashViewModel = SplashViewModel(interactor, coroutineManager)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class UserRepositoryImpl(
private val userDatasource: UserDatasource,
private val credentialsDatasource: CredentialsDatasource,
private val db: AppDatabase,
private val coroutineManager: CoroutineManager,
coroutineManager: CoroutineManager,
private val languagesHolder: LanguagesHolder,
) : UserRepository {

Expand Down Expand Up @@ -188,14 +188,14 @@ class UserRepositoryImpl(
val count = db.globalCardsHubDao().count()
if (count == 0) {
db.globalCardsHubDao().insert(
CardHubType.values()
CardHubType.entries
.filter { !it.boundToAccount }
.map { cardType ->
GlobalCardHubLocal(
cardId = cardType.hubName,
visibility = true,
sortOrder = cardType.order,
collapsed = false
collapsed = false,
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ class PinCodeInteractor @Inject constructor(
return if (isFetched) {
userRepository.needsMigration(soraAccount)
} else {
val irohaData = credentialsRepository.getIrohaData(soraAccount)
val needs = walletRepository.needsMigration(irohaData.address)
val needs = if (credentialsRepository.retrieveMnemonic(soraAccount).split(" ").size == 15) {
val irohaData = credentialsRepository.getIrohaData(soraAccount)
walletRepository.needsMigration(irohaData.address)
} else {
false
}
userRepository.saveNeedsMigration(needs, soraAccount)
userRepository.saveIsMigrationFetched(true, soraAccount)
userRepository.needsMigration(soraAccount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ class PinCodeViewModel @Inject constructor(
connectionManager: ConnectionManager,
) : BaseViewModel(), WithProgress by progress {

companion object {
private const val COMPLETE_PIN_CODE_DELAY: Long = 12
}

internal var state by mutableStateOf(
PinCodeScreenState(
maxDotsCount = PinCodeInteractor.PINCODE_LENGTH,
Expand Down Expand Up @@ -269,7 +265,6 @@ class PinCodeViewModel @Inject constructor(
private fun pinCodeEntered() {
viewModelScope.launch {
tryCatch {
delay(COMPLETE_PIN_CODE_DELAY)
if (PinCodeAction.CREATE_PIN_CODE == action) {
if (tempCode.isEmpty()) {
tempCode = inputedCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class PinCodeInteractorTest {
given(userRepository.getCurSoraAccount()).willReturn(account)
given(userRepository.isMigrationFetched(account)).willReturn(false)
given(credentialsRepository.getIrohaData(account)).willReturn(irohaData)
given(credentialsRepository.retrieveMnemonic(account)).willReturn("qwe asd zxc vbn tyu qwe asd zxc vbn tyu qwe asd zxc vbn tyu")
given(walletRepository.needsMigration(address)).willReturn(needsMigration)

interactor.needsMigration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,6 @@ class RuntimeManager @Inject constructor(

private sealed class MetadataSource {
data class Cache(val replaceCache: Boolean) : MetadataSource()
object SoraNet : MetadataSource()
data object SoraNet : MetadataSource()
}
}

0 comments on commit eb1c522

Please sign in to comment.