Skip to content

Commit

Permalink
tests: add mock of CoinJoinConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Oct 30, 2023
1 parent 4ec8988 commit 7da5e2d
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,10 +42,12 @@ class SendCoinsTaskRunnerTest {
@Test
fun sendCoins_coinSelectorSet_correctCoinSelector() {
val wallet = mockk<Wallet>()
val coinJoinConfig = mockk<CoinJoinConfig>()
every { wallet.context } returns Context(MainNetParams.get())
coEvery { coinJoinConfig.observeMode() } returns MutableStateFlow(CoinJoinMode.NONE)
val application = mockk<WalletApplication>()

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,
Expand All @@ -54,11 +61,13 @@ class SendCoinsTaskRunnerTest {
@Test
fun sendCoins_nullCoinSelector_zeroConfSelectorByDefault() {
val wallet = mockk<Wallet>()
val coinJoinConfig = mockk<CoinJoinConfig>()
every { wallet.context } returns Context(MainNetParams.get())
coEvery { coinJoinConfig.observeMode() } returns MutableStateFlow(CoinJoinMode.NONE)
val application = mockk<WalletApplication>()
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,
Expand Down

0 comments on commit 7da5e2d

Please sign in to comment.