@@ -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,17 +1765,39 @@ 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 Bob has not implemented https://github.com/lightning/bolts/pull/1214, he 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)
1776+ bob2alice.forward(alice, channelReestablishBob1.copy(nextLocalCommitmentNumber = bobCommitIndex + 1 ))
1777+ // In that case Alice won't retransmit commit_sig and the splice won't complete since they haven't exchanged tx_signatures.
1778+ bob2alice.expectMsgType[CommitSig ]
1779+ bob2alice.forward(alice)
1780+ alice2bob.expectNoMessage(100 millis)
1781+ assert(alice.stateData.asInstanceOf [DATA_NORMAL ].spliceStatus.isInstanceOf [SpliceStatus .SpliceWaitingForSigs ])
1782+ assert(bob.stateData.asInstanceOf [DATA_NORMAL ].spliceStatus.isInstanceOf [SpliceStatus .SpliceWaitingForSigs ])
1783+ // The channel is thus stuck: updates cannot be processed, but the channel won't be immediately force-closed.
1784+ // If a pending HTLC times out, the channel will however be force-closed.
1785+ val probe = TestProbe ()
1786+ val (_, cmd) = makeCmdAdd(25_000_000 msat, bob.nodeParams.nodeId, bob.nodeParams.currentBlockHeight)
1787+ alice ! cmd.copy(replyTo = probe.ref)
1788+ probe.expectMsgType[RES_ADD_FAILED [ForbiddenDuringSplice ]]
1789+
1790+ // But when correctly setting their next_commitment_number, they're able to finalize the splice.
1791+ disconnect(f)
1792+ val (channelReestablishAlice2, channelReestablishBob2) = reconnect(f)
1793+ assert(channelReestablishAlice2.nextFundingTxId_opt.contains(spliceStatus.signingSession.fundingTx.txId))
1794+ assert(channelReestablishAlice2.nextLocalCommitmentNumber == aliceCommitIndex + 1 )
1795+ assert(channelReestablishBob2.nextFundingTxId_opt.contains(spliceStatus.signingSession.fundingTx.txId))
1796+ assert(channelReestablishBob2.nextLocalCommitmentNumber == bobCommitIndex)
17731797
17741798 // Alice and Bob retransmit commit_sig and tx_signatures.
17751799 alice2bob.expectMsgType[CommitSig ]
17761800 alice2bob.forward(bob)
1777- bob2alice.expectMsgType[CommitSig ]
1778- bob2alice.forward(alice)
17791801 bob2alice.expectMsgType[TxSignatures ]
17801802 bob2alice.forward(alice)
17811803 alice2bob.expectMsgType[TxSignatures ]
0 commit comments