From 222bb4309b7fd47406affde9c65106eea4ee7ce1 Mon Sep 17 00:00:00 2001 From: Milan Cerovsky Date: Mon, 19 Aug 2024 13:53:09 +0200 Subject: [PATCH] Test hotfixes --- .../zcash/ui/fixture/MockSynchronizer.kt | 34 +++++++++++++++---- .../integration/AccountViewIntegrationTest.kt | 5 ++- .../zcash/ui/screen/send/SendViewTestSetup.kt | 4 ++- .../integration/SendViewIntegrationTest.kt | 11 ------ 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/fixture/MockSynchronizer.kt b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/fixture/MockSynchronizer.kt index c50f9cf0..9b06f8eb 100644 --- a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/fixture/MockSynchronizer.kt +++ b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/fixture/MockSynchronizer.kt @@ -6,6 +6,8 @@ import cash.z.ecc.android.sdk.Synchronizer import cash.z.ecc.android.sdk.block.processor.CompactBlockProcessor import cash.z.ecc.android.sdk.model.Account import cash.z.ecc.android.sdk.model.BlockHeight +import cash.z.ecc.android.sdk.model.FastestServersResult +import cash.z.ecc.android.sdk.model.ObserveFiatCurrencyResult import cash.z.ecc.android.sdk.model.PercentDecimal import cash.z.ecc.android.sdk.model.Proposal import cash.z.ecc.android.sdk.model.TransactionOverview @@ -30,6 +32,13 @@ internal class MockSynchronizer : CloseableSynchronizer { override val latestBirthdayHeight: BlockHeight get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") + override suspend fun getFastestServers( + context: Context, + servers: List + ): Flow { + TODO("Not yet implemented") + } + override val latestHeight: BlockHeight get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") @@ -64,6 +73,7 @@ internal class MockSynchronizer : CloseableSynchronizer { override val processorInfo: Flow get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") + override val progress: Flow get() = TODO("Not yet implemented") @@ -72,12 +82,16 @@ internal class MockSynchronizer : CloseableSynchronizer { override val status: Flow get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") + override val transactions: Flow> get() = TODO("Not yet implemented") override val transparentBalance: StateFlow get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") + override val exchangeRateUsd: StateFlow + get() = TODO("Not yet implemented") + override fun close() { error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") } @@ -109,6 +123,10 @@ internal class MockSynchronizer : CloseableSynchronizer { error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") } + override suspend fun refreshExchangeRateUsd() { + TODO("Not yet implemented") + } + override suspend fun getTransparentBalance(tAddr: String): Zatoshi { error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") } @@ -129,6 +147,10 @@ internal class MockSynchronizer : CloseableSynchronizer { error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") } + override suspend fun isValidTexAddr(address: String): Boolean { + TODO("Not yet implemented") + } + override suspend fun proposeShielding( account: Account, shieldingThreshold: Zatoshi, @@ -165,9 +187,9 @@ internal class MockSynchronizer : CloseableSynchronizer { @Deprecated( "Upcoming SDK 2.1 will create multiple transactions at once for some recipients.", replaceWith = - ReplaceWith( - "createProposedTransactions(proposeTransfer(usk.account, toAddress, amount, memo), usk)" - ) + ReplaceWith( + "createProposedTransactions(proposeTransfer(usk.account, toAddress, amount, memo), usk)" + ) ) override suspend fun sendToAddress( usk: UnifiedSpendingKey, @@ -181,9 +203,9 @@ internal class MockSynchronizer : CloseableSynchronizer { @Deprecated( "Upcoming SDK 2.1 will create multiple transactions at once for some recipients.", replaceWith = - ReplaceWith( - "proposeShielding(usk.account, shieldingThreshold, memo)?.let { createProposedTransactions(it, usk) }" - ) + ReplaceWith( + "proposeShielding(usk.account, shieldingThreshold, memo)?.let { createProposedTransactions(it, usk) }" + ) ) override suspend fun shieldFunds( usk: UnifiedSpendingKey, diff --git a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/account/integration/AccountViewIntegrationTest.kt b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/account/integration/AccountViewIntegrationTest.kt index 9813055f..e2f76799 100644 --- a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/account/integration/AccountViewIntegrationTest.kt +++ b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/account/integration/AccountViewIntegrationTest.kt @@ -9,6 +9,7 @@ import androidx.compose.ui.unit.dp import androidx.test.filters.MediumTest import co.electriccoin.zcash.test.UiTestPrerequisites import co.electriccoin.zcash.ui.common.model.WalletSnapshot +import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture import co.electriccoin.zcash.ui.screen.account.AccountTag import co.electriccoin.zcash.ui.screen.account.AccountTestSetup @@ -40,7 +41,9 @@ class AccountViewIntegrationTest : UiTestPrerequisites() { val testSetup = newTestSetup(walletSnapshot) restorationTester.setContent { - testSetup.DefaultContent(isHideBalances = false) + ZcashTheme { + testSetup.DefaultContent(isHideBalances = false) + } } assertEquals(WalletSnapshotFixture.SAPLING_BALANCE, testSetup.getWalletSnapshot().saplingBalance) diff --git a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/SendViewTestSetup.kt b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/SendViewTestSetup.kt index a6d0ebc3..7023f7fd 100644 --- a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/SendViewTestSetup.kt +++ b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/SendViewTestSetup.kt @@ -12,6 +12,7 @@ import cash.z.ecc.android.sdk.model.Zatoshi import cash.z.ecc.android.sdk.model.ZecSend import cash.z.ecc.android.sdk.type.AddressType import co.electriccoin.zcash.ui.common.model.TopAppBarSubTitleState +import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.fixture.BalanceStateFixture import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture @@ -130,7 +131,7 @@ class SendViewTestSetup( value = "", fiatValue = "", isTransparentRecipient = false, - exchangeRateState = null + exchangeRateState = ExchangeRateState.OptedOut ), setMemoState = {}, memoState = MemoState.new(""), @@ -142,6 +143,7 @@ class SendViewTestSetup( available = Zatoshi(Zatoshi.MAX_INCLUSIVE.div(100)) ) ), + exchangeRateState = ExchangeRateState.OptedOut ) } } diff --git a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/integration/SendViewIntegrationTest.kt b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/integration/SendViewIntegrationTest.kt index a252cad8..470896b0 100644 --- a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/integration/SendViewIntegrationTest.kt +++ b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/integration/SendViewIntegrationTest.kt @@ -10,8 +10,6 @@ import cash.z.ecc.android.sdk.model.MonetarySeparators import cash.z.ecc.android.sdk.model.Zatoshi import cash.z.ecc.android.sdk.model.ZcashNetwork import cash.z.ecc.sdk.fixture.ZecSendFixture -import co.electriccoin.zcash.ui.common.model.TopAppBarSubTitleState -import co.electriccoin.zcash.ui.fixture.BalanceStateFixture import co.electriccoin.zcash.ui.fixture.MockSynchronizer import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture import co.electriccoin.zcash.ui.screen.send.WrapSend @@ -65,21 +63,12 @@ class SendViewIntegrationTest { restorationTester.setContent { WrapSend( - balanceState = BalanceStateFixture.new(), sendArguments = null, - synchronizer = synchronizer, - walletSnapshot = walletSnapshot, - spendingKey = spendingKey, goToQrScanner = {}, goBack = {}, goBalances = {}, goSettings = {}, goSendConfirmation = {}, - isHideBalances = false, - onHideBalances = {}, - hasCameraFeature = true, - monetarySeparators = monetarySeparators, - topAppBarSubTitleState = TopAppBarSubTitleState.None, ) }