Skip to content

Commit 9cda2c3

Browse files
committed
fix: propagate vss failure
1 parent 5206cda commit 9cda2c3

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

app/src/main/java/to/bitkit/repositories/LightningRepo.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,14 @@ class LightningRepo @Inject constructor(
483483
if (lightningService.node != null) {
484484
lightningService.stop()
485485
}
486-
clearNetworkGraph(walletIndex)
486+
// Propagate VSS failures: a manual reset that leaves the graph in VSS is ineffective.
487+
clearNetworkGraph(walletIndex).getOrThrow()
487488
}
488489
}
489490

490-
private suspend fun clearNetworkGraph(walletIndex: Int) {
491+
private suspend fun clearNetworkGraph(walletIndex: Int): Result<Unit> {
491492
lightningService.resetNetworkGraph(walletIndex)
492-
runCatching {
493+
return runCatching {
493494
vssBackupClientLdk.setup(walletIndex).getOrThrow()
494495
vssBackupClientLdk.deleteObject("network_graph").getOrThrow()
495496
Logger.info("Cleared network graph from VSS", context = TAG)

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,18 @@ class LightningRepoTest : BaseUnitTest() {
188188
verify(vssBackupClientLdk).deleteObject(eq("network_graph"), any())
189189
}
190190

191+
@Test
192+
fun `resetNetworkGraph fails when VSS delete fails`() = test {
193+
whenever(vssBackupClientLdk.setup(any())).thenReturn(Result.success(Unit))
194+
whenever(vssBackupClientLdk.deleteObject(any(), any()))
195+
.thenReturn(Result.failure(RuntimeException("vss unavailable")))
196+
197+
val result = sut.resetNetworkGraph()
198+
199+
assertTrue(result.isFailure)
200+
verify(lightningService).resetNetworkGraph(0)
201+
}
202+
191203
@Test
192204
fun `newAddress should fail when node is not running`() = test {
193205
val result = sut.newAddress()

0 commit comments

Comments
 (0)