@@ -6,6 +6,7 @@ import com.synonym.bitkitcore.FeeRates
66import com.synonym.bitkitcore.IBtInfo
77import com.synonym.bitkitcore.ILspNode
88import kotlinx.coroutines.flow.flowOf
9+ import kotlinx.coroutines.runBlocking
910import org.junit.Before
1011import org.junit.Test
1112import org.lightningdevkit.ldknode.ChannelDetails
@@ -25,7 +26,6 @@ import org.mockito.kotlin.spy
2526import org.mockito.kotlin.verify
2627import org.mockito.kotlin.verifyBlocking
2728import org.mockito.kotlin.whenever
28- import org.mockito.kotlin.wheneverBlocking
2929import to.bitkit.data.AppCacheData
3030import to.bitkit.data.CacheStore
3131import to.bitkit.data.SettingsData
@@ -51,23 +51,21 @@ import kotlin.test.assertNull
5151import kotlin.test.assertTrue
5252
5353class LightningRepoTest : BaseUnitTest () {
54-
5554 private lateinit var sut: LightningRepo
5655
57- private val lightningService: LightningService = mock()
58- private val settingsStore: SettingsStore = mock()
59- private val coreService: CoreService = mock()
60- private val lspNotificationsService: LspNotificationsService = mock()
61- private val firebaseMessaging: FirebaseMessaging = mock()
62- private val keychain: Keychain = mock()
63- private val cacheStore: CacheStore = mock()
64- private val preActivityMetadataRepo: PreActivityMetadataRepo = mock()
65-
66- private val lnurlService: LnurlService = mock()
56+ private val lightningService = mock<LightningService >()
57+ private val settingsStore = mock<SettingsStore >()
58+ private val coreService = mock<CoreService >()
59+ private val lspNotificationsService = mock<LspNotificationsService >()
60+ private val firebaseMessaging = mock<FirebaseMessaging >()
61+ private val keychain = mock<Keychain >()
62+ private val cacheStore = mock<CacheStore >()
63+ private val preActivityMetadataRepo = mock<PreActivityMetadataRepo >()
64+ private val lnurlService = mock<LnurlService >()
6765
6866 @Before
69- fun setUp () {
70- wheneverBlocking { coreService.isGeoBlocked() } .thenReturn(false )
67+ fun setUp () = runBlocking {
68+ whenever( coreService.isGeoBlocked()) .thenReturn(false )
7169 sut = LightningRepo (
7270 bgDispatcher = testDispatcher,
7371 lightningService = lightningService,
@@ -381,9 +379,7 @@ class LightningRepoTest : BaseUnitTest() {
381379 )
382380 whenever(settingsStore.data).thenReturn(flowOf(mockSettingsData))
383381
384- wheneverBlocking {
385- preActivityMetadataRepo.addPreActivityMetadata(any())
386- }.thenReturn(Result .success(Unit ))
382+ whenever(preActivityMetadataRepo.addPreActivityMetadata(any())).thenReturn(Result .success(Unit ))
387383
388384 whenever(
389385 lightningService.send(
@@ -603,13 +599,13 @@ class LightningRepoTest : BaseUnitTest() {
603599 ILspNode (
604600 alias = " LSP1" ,
605601 pubkey = " node1pubkey" ,
606- connectionStrings = listOf (" node1.example.com:9735" ),
602+ connectionStrings = listOf (" node1pubkey@ node1.example.com:9735" ),
607603 readonly = null ,
608604 ),
609605 ILspNode (
610606 alias = " LSP2" ,
611607 pubkey = " node2pubkey" ,
612- connectionStrings = listOf (" node2.example.com:9735" ),
608+ connectionStrings = listOf (" node2pubkey@ node2.example.com:9735" ),
613609 readonly = null ,
614610 ),
615611 )
@@ -625,8 +621,8 @@ class LightningRepoTest : BaseUnitTest() {
625621 anyOrNull(),
626622 argThat { peers ->
627623 peers?.size == 2 &&
628- peers.any { it.nodeId == " node1pubkey" } &&
629- peers.any { it.nodeId == " node2pubkey" }
624+ peers.any { it.nodeId == " node1pubkey" && it.address == " node1.example.com:9735 " } &&
625+ peers.any { it.nodeId == " node2pubkey" && it.address == " node2.example.com:9735 " }
630626 }
631627 )
632628 }
0 commit comments