Skip to content

Commit a901707

Browse files
committed
fix: Wallet viewmodel tests
1 parent 2805c94 commit a901707

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

app/src/test/java/to/bitkit/ui/WalletViewModelTest.kt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import to.bitkit.viewmodels.MainUiState
2727
import to.bitkit.models.NodeLifecycleState
2828
import to.bitkit.services.CoreService
2929
import to.bitkit.services.LdkNodeEventBus
30+
import to.bitkit.utils.AddressChecker
31+
import to.bitkit.utils.AddressInfo
32+
import to.bitkit.utils.AddressStats
3033
import to.bitkit.viewmodels.WalletViewModel
3134
import kotlin.test.assertEquals
3235

@@ -42,6 +45,7 @@ class WalletViewModelTest : BaseUnitTest() {
4245
private var appStorage: AppStorage = mock()
4346
private val ldkNodeEventBus: LdkNodeEventBus = mock()
4447
private val settingsStore: SettingsStore = mock()
48+
private val addressChecker: AddressChecker = mock()
4549

4650
private lateinit var sut: WalletViewModel
4751

@@ -75,7 +79,7 @@ class WalletViewModelTest : BaseUnitTest() {
7579
firebaseMessaging = firebaseMessaging,
7680
ldkNodeEventBus = ldkNodeEventBus,
7781
settingsStore = settingsStore,
78-
addressChecker = mock(),
82+
addressChecker = addressChecker,
7983
)
8084
}
8185

@@ -142,5 +146,24 @@ class WalletViewModelTest : BaseUnitTest() {
142146
whenever(appStorage.onchainAddress).thenReturn("onchainAddress")
143147
whenever(appStorage.bolt11).thenReturn("bolt11")
144148
whenever(appStorage.bip21).thenReturn("bitcoin:onchainAddress")
149+
wheneverBlocking { addressChecker.getAddressInfo(anyString()) }.thenReturn(mockAddressInfo)
145150
}
146151
}
152+
153+
val mockAddressInfo = AddressInfo(
154+
address = "bc1qar...",
155+
chain_stats = AddressStats(
156+
funded_txo_count = 15,
157+
funded_txo_sum = 0,
158+
spent_txo_count = 10,
159+
spent_txo_sum = 0,
160+
tx_count = 25
161+
),
162+
mempool_stats = AddressStats(
163+
funded_txo_count = 1,
164+
funded_txo_sum = 100000,
165+
spent_txo_count = 0,
166+
spent_txo_sum = 0,
167+
tx_count = 1
168+
)
169+
)

0 commit comments

Comments
 (0)