From 2ee91563a5b5ee34955ab833f4bfb09c0b64ccb8 Mon Sep 17 00:00:00 2001 From: Richard Myers Date: Mon, 13 Nov 2023 15:56:09 -0800 Subject: [PATCH] Change spliceStatus to `Aborted` after responding to `SpliceInit` with `TxAbort` --- .../kotlin/fr/acinq/lightning/channel/states/Normal.kt | 4 ++-- .../acinq/lightning/channel/states/QuiescenceTestsCommon.kt | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt index 5afd45942..c2e92ff62 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt @@ -448,7 +448,7 @@ data class Normal( is SpliceInit -> when (spliceStatus) { is SpliceStatus.None -> { logger.warning { "rejecting splice attempt: quiescence not negotiated" } - Pair(this@Normal, listOf(ChannelAction.Message.Send(TxAbort(channelId, InvalidSpliceNotQuiescent(channelId).message)))) + Pair(this@Normal.copy(spliceStatus = SpliceStatus.Aborted), listOf(ChannelAction.Message.Send(TxAbort(channelId, InvalidSpliceNotQuiescent(channelId).message)))) } is SpliceStatus.NonInitiatorQuiescent -> if (commitments.isQuiescent()) { @@ -485,7 +485,7 @@ data class Normal( Pair(nextState, listOf(ChannelAction.Message.Send(spliceAck))) } else { logger.warning { "rejecting splice attempt: channel is not quiescent" } - Pair(this@Normal, listOf(ChannelAction.Message.Send(TxAbort(channelId, InvalidSpliceNotQuiescent(channelId).message)))) + Pair(this@Normal.copy(spliceStatus = SpliceStatus.Aborted), listOf(ChannelAction.Message.Send(TxAbort(channelId, InvalidSpliceNotQuiescent(channelId).message)))) } is SpliceStatus.Aborted -> { logger.info { "rejecting splice attempt: our previous tx_abort was not acked" } diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/QuiescenceTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/QuiescenceTestsCommon.kt index e5b9e0273..170ec1031 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/QuiescenceTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/QuiescenceTestsCommon.kt @@ -403,9 +403,11 @@ class QuiescenceTestsCommon : LightningTestSuite() { fun `receive SpliceInit when channel is not quiescent` () { val (alice, _) = init() val spliceInit = SpliceInit(alice.channelId, 500_000.sat, FeeratePerKw(253.sat), 0, Lightning.randomKey().publicKey()) - val (_, actionsAlice) = alice.process(ChannelCommand.MessageReceived(spliceInit)) + val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(spliceInit)) // quiescence not negotiated - actionsAlice.hasOutgoingMessage() + actionsAlice1.hasOutgoingMessage() + assertIs>(alice1) + assertIs(alice1.state.spliceStatus) } companion object {