169 lines
7.9 KiB
Kotlin
169 lines
7.9 KiB
Kotlin
package co.electriccoin.zcash.ui.fixture
|
|
|
|
import cash.z.ecc.android.sdk.CloseableSynchronizer
|
|
import cash.z.ecc.android.sdk.Synchronizer
|
|
import cash.z.ecc.android.sdk.block.CompactBlockProcessor
|
|
import cash.z.ecc.android.sdk.model.Account
|
|
import cash.z.ecc.android.sdk.model.BlockHeight
|
|
import cash.z.ecc.android.sdk.model.PendingTransaction
|
|
import cash.z.ecc.android.sdk.model.Transaction
|
|
import cash.z.ecc.android.sdk.model.TransactionOverview
|
|
import cash.z.ecc.android.sdk.model.TransactionRecipient
|
|
import cash.z.ecc.android.sdk.model.UnifiedSpendingKey
|
|
import cash.z.ecc.android.sdk.model.WalletBalance
|
|
import cash.z.ecc.android.sdk.model.Zatoshi
|
|
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
|
import cash.z.ecc.android.sdk.type.AddressType
|
|
import cash.z.ecc.android.sdk.type.ConsensusMatchType
|
|
import kotlinx.coroutines.flow.Flow
|
|
import kotlinx.coroutines.flow.StateFlow
|
|
import kotlinx.coroutines.flow.emptyFlow
|
|
|
|
/**
|
|
* Mocked Synchronizer that can be used instead of the production SdkSynchronizer e.g. for tests.
|
|
*/
|
|
@Suppress("TooManyFunctions", "UNUSED_PARAMETER")
|
|
internal class MockSynchronizer : CloseableSynchronizer {
|
|
|
|
override val clearedTransactions: Flow<List<TransactionOverview>>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val latestBirthdayHeight: BlockHeight
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val latestHeight: BlockHeight
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val network: ZcashNetwork
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val networkHeight: StateFlow<BlockHeight?>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override var onChainErrorHandler: ((BlockHeight, BlockHeight) -> Any)?
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
set(value) {}
|
|
|
|
override var onCriticalErrorHandler: ((Throwable?) -> Boolean)?
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
set(value) {}
|
|
|
|
override var onProcessorErrorHandler: ((Throwable?) -> Boolean)?
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
set(value) {}
|
|
|
|
override var onSetupErrorHandler: ((Throwable?) -> Boolean)?
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
set(value) {}
|
|
|
|
override var onSubmissionErrorHandler: ((Throwable?) -> Boolean)?
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
set(value) {}
|
|
|
|
override val orchardBalances: StateFlow<WalletBalance?>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val pendingTransactions: Flow<List<PendingTransaction>>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val processorInfo: Flow<CompactBlockProcessor.ProcessorInfo>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val progress: Flow<Int>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val receivedTransactions: Flow<List<Transaction.Received>>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val saplingBalances: StateFlow<WalletBalance?>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val sentTransactions: Flow<List<Transaction.Sent>>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val status: Flow<Synchronizer.Status>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override val transparentBalances: StateFlow<WalletBalance?>
|
|
get() = error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
|
|
override fun close() {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override fun getMemos(transactionOverview: TransactionOverview): Flow<String> {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun getNearestRewindHeight(height: BlockHeight): BlockHeight {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override fun getRecipients(transactionOverview: TransactionOverview): Flow<TransactionRecipient> {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun getSaplingAddress(account: Account): String {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun getTransparentAddress(account: Account): String {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun getTransparentBalance(tAddr: String): WalletBalance {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun getUnifiedAddress(account: Account): String {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun isValidShieldedAddr(address: String): Boolean {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun isValidTransparentAddr(address: String): Boolean {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun isValidUnifiedAddr(address: String): Boolean {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun quickRewind() {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun refreshUtxos(account: Account, since: BlockHeight): Int? {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun rewindToNearestHeight(height: BlockHeight, alsoClearBlockCache: Boolean) {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
/**
|
|
* This method intentionally returns empty flow, as the PendingTransaction is only an SDK internal class.
|
|
*/
|
|
override fun sendToAddress(usk: UnifiedSpendingKey, amount: Zatoshi, toAddress: String, memo: String): Flow<PendingTransaction> {
|
|
return emptyFlow()
|
|
}
|
|
|
|
override fun shieldFunds(usk: UnifiedSpendingKey, memo: String): Flow<PendingTransaction> {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun validateAddress(address: String): AddressType {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
override suspend fun validateConsensusBranch(): ConsensusMatchType {
|
|
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
|
|
}
|
|
|
|
companion object {
|
|
fun new() = MockSynchronizer()
|
|
}
|
|
}
|