@@ -30,7 +30,6 @@ import org.robolectric.annotation.Config
3030import to.bitkit.App
3131import to.bitkit.CurrentActivity
3232import to.bitkit.R
33- import to.bitkit.androidServices.LightningNodeService
3433import to.bitkit.data.CacheStore
3534import to.bitkit.domain.commands.ReceivedNotificationContent
3635import to.bitkit.ext.createChannelDetails
@@ -42,6 +41,7 @@ import to.bitkit.repositories.ActivityRepo
4241import to.bitkit.repositories.BlocktankRepo
4342import to.bitkit.repositories.LightningRepo
4443import to.bitkit.services.NodeEventHandler
44+ import to.bitkit.services.NodeServiceState
4545import to.bitkit.test.BaseUnitTest
4646import kotlin.test.assertEquals
4747import kotlin.test.assertNotNull
@@ -57,6 +57,7 @@ class WakeNodeWorkerTest : BaseUnitTest() {
5757 private val activityRepo = mock<ActivityRepo >()
5858 private val cacheStore = mock<CacheStore >()
5959 private val receivedNotificationContent = mock<ReceivedNotificationContent >()
60+ private val nodeServiceState = NodeServiceState ()
6061
6162 private val channelId = " channel-1"
6263 private val receivedTitle by lazy { context.getString(R .string.notification__received__title) }
@@ -70,15 +71,13 @@ class WakeNodeWorkerTest : BaseUnitTest() {
7071 val app = context as Application
7172 Shadows .shadowOf(app).grantPermissions(Manifest .permission.POST_NOTIFICATIONS )
7273
73- // Default: app killed (no foreground activity), no foreground service running
74+ // Default: app killed (no foreground activity); nodeServiceState defaults to not- running
7475 App .currentActivity = CurrentActivity ()
75- LightningNodeService .isRunning = false
7676 }
7777
7878 @After
7979 fun tearDown () {
8080 App .currentActivity = null
81- LightningNodeService .isRunning = false
8281 }
8382
8483 @Test
@@ -114,7 +113,7 @@ class WakeNodeWorkerTest : BaseUnitTest() {
114113
115114 @Test
116115 fun `cjit channel ready skips notification when foreground service is running` () = test {
117- LightningNodeService .isRunning = true
116+ nodeServiceState.setForegroundServiceRunning( true )
118117 val channel = cjitChannel(sats = 48_064 )
119118 stubChannel(channel, cjitEntry = IcJitEntry .mock())
120119 stubStartFiring(channelReadyEvent())
@@ -179,7 +178,7 @@ class WakeNodeWorkerTest : BaseUnitTest() {
179178
180179 @Test
181180 fun `payment received skips notification when foreground service is running` () = test {
182- LightningNodeService .isRunning = true
181+ nodeServiceState.setForegroundServiceRunning( true )
183182 whenever(workerParams.inputData).thenReturn(
184183 workDataOf(" type" to BlocktankNotificationType .incomingHtlc.name),
185184 )
@@ -205,6 +204,7 @@ class WakeNodeWorkerTest : BaseUnitTest() {
205204 activityRepo = activityRepo,
206205 cacheStore = cacheStore,
207206 receivedNotificationContent = receivedNotificationContent,
207+ nodeServiceState = nodeServiceState,
208208 )
209209
210210 private fun channelReadyEvent () = mock<Event .ChannelReady > {
0 commit comments