@@ -23,6 +23,7 @@ import org.mockito.kotlin.inOrder
2323import org.mockito.kotlin.isNull
2424import org.mockito.kotlin.mock
2525import org.mockito.kotlin.spy
26+ import org.mockito.kotlin.times
2627import org.mockito.kotlin.verify
2728import org.mockito.kotlin.verifyBlocking
2829import org.mockito.kotlin.whenever
@@ -646,4 +647,26 @@ class LightningRepoTest : BaseUnitTest() {
646647 assertTrue(result.isSuccess)
647648 verify(lightningService).setup(any(), anyOrNull(), anyOrNull(), isNull(), anyOrNull())
648649 }
650+
651+ @Test
652+ fun `start should not retry when node lifecycle state is Starting` () = test {
653+ sut.setInitNodeLifecycleState()
654+ whenever(lightningService.node).thenReturn(null )
655+ whenever(lightningService.setup(any(), anyOrNull(), anyOrNull(), anyOrNull(), anyOrNull())).thenReturn(Unit )
656+ whenever(settingsStore.data).thenReturn(flowOf(SettingsData ()))
657+ val blocktank = mock<BlocktankService >()
658+ whenever(coreService.blocktank).thenReturn(blocktank)
659+ whenever(blocktank.info(any())).thenReturn(null )
660+
661+ // Simulate: start throws (state will be Starting when onFailure is called)
662+ whenever(lightningService.start(anyOrNull(), any())).thenThrow(RuntimeException (" error" ))
663+
664+ val result = sut.start()
665+
666+ // Defensive check: state is Starting, so don't retry, return success
667+ assertTrue(result.isSuccess)
668+ assertEquals(NodeLifecycleState .Starting , sut.lightningState.value.nodeLifecycleState)
669+ // Verify start was only called once (no retry)
670+ verify(lightningService, times(1 )).start(anyOrNull(), any())
671+ }
649672}
0 commit comments