Skip to content

Commit be61b2e

Browse files
committed
Test that non-upgraded nodes are stuck
If nodes don't upgrade, they can be stuck waiting for splice signatures. The channel isn't force-closed in that case, but they won't be able to make any payment until they upgrade and reconnect.
1 parent 31cc8f1 commit be61b2e

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalSplicesStateSpec.scala

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
8787
r2s.expectMsgType[TxComplete]
8888
r2s.forward(s)
8989
if (spliceIn_opt.isDefined) {
90-
s2r.expectMsgType[TxAddInput]
91-
s2r.forward(r)
92-
r2s.expectMsgType[TxComplete]
93-
r2s.forward(s)
94-
s2r.expectMsgType[TxAddOutput]
95-
s2r.forward(r)
96-
r2s.expectMsgType[TxComplete]
97-
r2s.forward(s)
90+
s2r.expectMsgType[TxAddInput]
91+
s2r.forward(r)
92+
r2s.expectMsgType[TxComplete]
93+
r2s.forward(s)
94+
s2r.expectMsgType[TxAddOutput]
95+
s2r.forward(r)
96+
r2s.expectMsgType[TxComplete]
97+
r2s.forward(s)
9898
}
9999
if (spliceOut_opt.isDefined) {
100100
s2r.expectMsgType[TxAddOutput]
@@ -1765,11 +1765,34 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
17651765
val spliceStatus = alice.stateData.asInstanceOf[DATA_NORMAL].spliceStatus.asInstanceOf[SpliceStatus.SpliceWaitingForSigs]
17661766

17671767
disconnect(f)
1768-
val (channelReestablishAlice, channelReestablishBob) = reconnect(f)
1769-
assert(channelReestablishAlice.nextFundingTxId_opt.contains(spliceStatus.signingSession.fundingTx.txId))
1770-
assert(channelReestablishAlice.nextLocalCommitmentNumber == aliceCommitIndex)
1771-
assert(channelReestablishBob.nextFundingTxId_opt.contains(spliceStatus.signingSession.fundingTx.txId))
1772-
assert(channelReestablishBob.nextLocalCommitmentNumber == bobCommitIndex)
1768+
1769+
// If Alice and Bob have not implemented https://github.com/lightning/bolts/pull/1214, they will send an incorrect next_commitment_number.
1770+
val (channelReestablishAlice1, channelReestablishBob1) = reconnect(f, sendReestablish = false)
1771+
assert(channelReestablishAlice1.nextFundingTxId_opt.contains(spliceStatus.signingSession.fundingTx.txId))
1772+
assert(channelReestablishAlice1.nextLocalCommitmentNumber == aliceCommitIndex)
1773+
assert(channelReestablishBob1.nextFundingTxId_opt.contains(spliceStatus.signingSession.fundingTx.txId))
1774+
assert(channelReestablishBob1.nextLocalCommitmentNumber == bobCommitIndex)
1775+
alice2bob.forward(bob, channelReestablishAlice1.copy(nextLocalCommitmentNumber = aliceCommitIndex + 1))
1776+
bob2alice.forward(alice, channelReestablishBob1.copy(nextLocalCommitmentNumber = bobCommitIndex + 1))
1777+
// In that case they won't retransmit commit_sig and the splice won't complete since they haven't exchanged tx_signatures.
1778+
alice2bob.expectNoMessage(100 millis)
1779+
bob2alice.expectNoMessage(100 millis)
1780+
assert(alice.stateData.asInstanceOf[DATA_NORMAL].spliceStatus.isInstanceOf[SpliceStatus.SpliceWaitingForSigs])
1781+
assert(bob.stateData.asInstanceOf[DATA_NORMAL].spliceStatus.isInstanceOf[SpliceStatus.SpliceWaitingForSigs])
1782+
// The channel is thus stuck: updates cannot be processed, but the channel won't be immediately force-closed.
1783+
// If a pending HTLC times out, the channel will however be force-closed.
1784+
val probe = TestProbe()
1785+
val (_, cmd) = makeCmdAdd(25_000_000 msat, bob.nodeParams.nodeId, bob.nodeParams.currentBlockHeight)
1786+
alice ! cmd.copy(replyTo = probe.ref)
1787+
probe.expectMsgType[RES_ADD_FAILED[ForbiddenDuringSplice]]
1788+
1789+
// But when correctly setting their next_commitment_number, they're able to finalize the splice.
1790+
disconnect(f)
1791+
val (channelReestablishAlice2, channelReestablishBob2) = reconnect(f)
1792+
assert(channelReestablishAlice2.nextFundingTxId_opt.contains(spliceStatus.signingSession.fundingTx.txId))
1793+
assert(channelReestablishAlice2.nextLocalCommitmentNumber == aliceCommitIndex)
1794+
assert(channelReestablishBob2.nextFundingTxId_opt.contains(spliceStatus.signingSession.fundingTx.txId))
1795+
assert(channelReestablishBob2.nextLocalCommitmentNumber == bobCommitIndex)
17731796

17741797
// Alice and Bob retransmit commit_sig and tx_signatures.
17751798
alice2bob.expectMsgType[CommitSig]

0 commit comments

Comments
 (0)