From 7da5e2d52d259f9caf34b35305be34f59cec2f6b Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Mon, 30 Oct 2023 10:45:24 -0700 Subject: [PATCH] tests: add mock of CoinJoinConfig --- .../wallet/util/services/SendCoinsTaskRunnerTest.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wallet/test/de/schildbach/wallet/util/services/SendCoinsTaskRunnerTest.kt b/wallet/test/de/schildbach/wallet/util/services/SendCoinsTaskRunnerTest.kt index ccb6696b66..5406e0a498 100644 --- a/wallet/test/de/schildbach/wallet/util/services/SendCoinsTaskRunnerTest.kt +++ b/wallet/test/de/schildbach/wallet/util/services/SendCoinsTaskRunnerTest.kt @@ -18,11 +18,16 @@ package de.schildbach.wallet.util.services import de.schildbach.wallet.WalletApplication +import de.schildbach.wallet.data.CoinJoinConfig import de.schildbach.wallet.payments.SendCoinsTaskRunner +import de.schildbach.wallet.service.CoinJoinMode +import io.mockk.coEvery import io.mockk.every import io.mockk.mockk import junit.framework.TestCase.assertTrue import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow import org.bitcoinj.core.Address import org.bitcoinj.core.Coin import org.bitcoinj.core.Context @@ -37,10 +42,12 @@ class SendCoinsTaskRunnerTest { @Test fun sendCoins_coinSelectorSet_correctCoinSelector() { val wallet = mockk() + val coinJoinConfig = mockk() every { wallet.context } returns Context(MainNetParams.get()) + coEvery { coinJoinConfig.observeMode() } returns MutableStateFlow(CoinJoinMode.NONE) val application = mockk() - val sendCoinsTaskRunner = SendCoinsTaskRunner(application, mockk(), mockk(), mockk()) + val sendCoinsTaskRunner = SendCoinsTaskRunner(application, mockk(), mockk(), mockk(), coinJoinConfig) val request = sendCoinsTaskRunner.createSendRequest( Address.fromBase58(MainNetParams.get(), "XjBya4EnibUyxubEA8D2Y8KSrBMW1oHq5U"), Coin.COIN, @@ -54,11 +61,13 @@ class SendCoinsTaskRunnerTest { @Test fun sendCoins_nullCoinSelector_zeroConfSelectorByDefault() { val wallet = mockk() + val coinJoinConfig = mockk() every { wallet.context } returns Context(MainNetParams.get()) + coEvery { coinJoinConfig.observeMode() } returns MutableStateFlow(CoinJoinMode.NONE) val application = mockk() every { application.wallet } returns wallet - val sendCoinsTaskRunner = SendCoinsTaskRunner(application, mockk(), mockk(), mockk()) + val sendCoinsTaskRunner = SendCoinsTaskRunner(application, mockk(), mockk(), mockk(), coinJoinConfig) val request = sendCoinsTaskRunner.createSendRequest( Address.fromBase58(MainNetParams.get(), "XjBya4EnibUyxubEA8D2Y8KSrBMW1oHq5U"), Coin.COIN,