@@ -136,7 +136,7 @@ class WalletRepoTest : BaseUnitTest() {
136136 }
137137
138138 @Test
139- fun `refreshBip21 should set receiveOnSpendingBalance as false if shouldBlockLightning is true` () = test {
139+ fun `refreshBip21 should set receiveOnSpendingBalance false when shouldBlockLightning is true` () = test {
140140 wheneverBlocking { coreService.checkGeoBlock() }.thenReturn(Pair (true , true ))
141141 whenever(lightningRepo.newAddress()).thenReturn(Result .success(" newAddress" ))
142142 whenever(addressChecker.getAddressInfo(any())).thenReturn(mock())
@@ -147,6 +147,18 @@ class WalletRepoTest : BaseUnitTest() {
147147 assertEquals(false , sut.walletState.value.receiveOnSpendingBalance)
148148 }
149149
150+ @Test
151+ fun `refreshBip21 should set receiveOnSpendingBalance true when shouldBlockLightning is false` () = test {
152+ wheneverBlocking { coreService.checkGeoBlock() }.thenReturn(Pair (true , false ))
153+ whenever(lightningRepo.newAddress()).thenReturn(Result .success(" newAddress" ))
154+ whenever(addressChecker.getAddressInfo(any())).thenReturn(mock())
155+
156+ val result = sut.refreshBip21()
157+
158+ assertTrue(result.isSuccess)
159+ assertEquals(true , sut.walletState.value.receiveOnSpendingBalance)
160+ }
161+
150162 @Test
151163 fun `refreshBip21 should generate new address when current has transactions` () = test {
152164 val testAddress = " testAddress"
@@ -246,10 +258,10 @@ class WalletRepoTest : BaseUnitTest() {
246258 }
247259
248260 @Test
249- fun `updateBip21Invoice should create bolt11 when channels exist ` () = test {
261+ fun `updateBip21Invoice should create bolt11 when node can receive ` () = test {
250262 val testInvoice = " testInvoice"
251- whenever(lightningRepo.hasChannels ()).thenReturn(true )
252- whenever(lightningRepo.createInvoice(1000uL , description = " test " )).thenReturn(Result .success(testInvoice))
263+ whenever(lightningRepo.canReceive ()).thenReturn(true )
264+ whenever(lightningRepo.createInvoice(anyOrNull(), any(), any() )).thenReturn(Result .success(testInvoice))
253265
254266 sut.updateBip21Invoice(amountSats = 1000uL , description = " test" ).let { result ->
255267 assertTrue(result.isSuccess)
@@ -258,9 +270,7 @@ class WalletRepoTest : BaseUnitTest() {
258270 }
259271
260272 @Test
261- fun `updateBip21Invoice should not create bolt11 when no channels exist` () = test {
262- whenever(lightningRepo.hasChannels()).thenReturn(false )
263-
273+ fun `updateBip21Invoice should not create bolt11 when node cannot receive` () = test {
264274 sut.updateBip21Invoice(amountSats = 1000uL , description = " test" ).let { result ->
265275 assertTrue(result.isSuccess)
266276 assertEquals(" " , sut.walletState.value.bolt11)
@@ -271,7 +281,7 @@ class WalletRepoTest : BaseUnitTest() {
271281 fun `updateBip21Invoice should build correct BIP21 URL` () = test {
272282 val testAddress = " testAddress"
273283 whenever(cacheStore.data).thenReturn(flowOf(AppCacheData (onchainAddress = testAddress)))
274- whenever(lightningRepo.hasChannels()) .thenReturn(false )
284+ whenever(lightningRepo.createInvoice(anyOrNull(), any(), any())) .thenReturn(Result .success( " testInvoice " ) )
275285 sut = createSut()
276286
277287 sut.updateBip21Invoice(amountSats = 1000uL , description = " test" ).let { result ->
0 commit comments