Skip to content

Commit a9e76cd

Browse files
jvsena42claude
andcommitted
test: update defensive check test for isRunning
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent badbdc3 commit a9e76cd

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

app/src/test/java/to/bitkit/repositories/LightningRepoTest.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ class LightningRepoTest : BaseUnitTest() {
649649
}
650650

651651
@Test
652-
fun `start should not retry when node lifecycle state is Starting`() = test {
652+
fun `start should not retry when node lifecycle state is Running`() = test {
653653
sut.setInitNodeLifecycleState()
654654
whenever(lightningService.node).thenReturn(null)
655655
whenever(lightningService.setup(any(), anyOrNull(), anyOrNull(), anyOrNull(), anyOrNull())).thenReturn(Unit)
@@ -658,14 +658,16 @@ class LightningRepoTest : BaseUnitTest() {
658658
whenever(coreService.blocktank).thenReturn(blocktank)
659659
whenever(blocktank.info(any())).thenReturn(null)
660660

661-
// Simulate: start throws (state will be Starting when onFailure is called)
662-
whenever(lightningService.start(anyOrNull(), any())).thenThrow(RuntimeException("error"))
661+
// lightningService.start() succeeds (state becomes Running at line 241)
662+
whenever(lightningService.start(anyOrNull(), any())).thenReturn(Unit)
663+
// lightningService.nodeId throws during syncState() (called at line 244, AFTER state = Running)
664+
whenever(lightningService.nodeId).thenThrow(RuntimeException("error during syncState"))
663665

664666
val result = sut.start()
665667

666-
// Defensive check: state is Starting, so don't retry, return success
668+
// Defensive check: state is Running, so don't retry, return success
667669
assertTrue(result.isSuccess)
668-
assertEquals(NodeLifecycleState.Starting, sut.lightningState.value.nodeLifecycleState)
670+
assertEquals(NodeLifecycleState.Running, sut.lightningState.value.nodeLifecycleState)
669671
// Verify start was only called once (no retry)
670672
verify(lightningService, times(1)).start(anyOrNull(), any())
671673
}

0 commit comments

Comments
 (0)