Skip to content

Commit 56a3acd

Browse files
t-bastpm47
andauthored
Add zero-conf test tag for Phoenix taproot tests (#3181)
We ensure that tests using the Phoenix taproot commitment format correctly pass on feature branches without conflicts. Co-authored-by: pm47 <[email protected]>
1 parent 16a309e commit 56a3acd

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import fr.acinq.eclair.channel._
3232
import fr.acinq.eclair.channel.fsm.Channel
3333
import fr.acinq.eclair.channel.publish.TxPublisher.{PublishFinalTx, PublishReplaceableTx}
3434
import fr.acinq.eclair.channel.publish._
35-
import fr.acinq.eclair.channel.states.ChannelStateTestsBase.FakeTxPublisherFactory
35+
import fr.acinq.eclair.channel.states.ChannelStateTestsBase.{FakeTxPublisherFactory, PimpTestFSM}
3636
import fr.acinq.eclair.payment.send.SpontaneousRecipient
3737
import fr.acinq.eclair.payment.{Invoice, OutgoingPaymentPacket}
3838
import fr.acinq.eclair.reputation.Reputation
@@ -373,7 +373,7 @@ trait ChannelStateTestsBase extends Assertions with Eventually {
373373
val fundingTx = eventListener.expectMsgType[TransactionPublished].tx
374374
eventually(assert(alice.stateName == WAIT_FOR_FUNDING_CONFIRMED))
375375
eventually(assert(bob.stateName == WAIT_FOR_FUNDING_CONFIRMED))
376-
if (channelParams.channelType.features.contains(Features.ZeroConf)) {
376+
if (channelParams.channelType.features.contains(Features.ZeroConf) || alice.commitments.channelParams.zeroConf) {
377377
alice2blockchain.expectMsgType[WatchPublished]
378378
bob2blockchain.expectMsgType[WatchPublished]
379379
alice ! WatchPublishedTriggered(fundingTx)
@@ -427,7 +427,7 @@ trait ChannelStateTestsBase extends Assertions with Eventually {
427427
val fundingTx = eventListener.expectMsgType[TransactionPublished].tx
428428
eventually(assert(alice.stateName == WAIT_FOR_DUAL_FUNDING_CONFIRMED))
429429
eventually(assert(bob.stateName == WAIT_FOR_DUAL_FUNDING_CONFIRMED))
430-
if (channelParams.channelType.features.contains(Features.ZeroConf)) {
430+
if (channelParams.channelType.features.contains(Features.ZeroConf) || alice.commitments.channelParams.zeroConf) {
431431
alice2blockchain.expectMsgType[WatchPublished]
432432
bob2blockchain.expectMsgType[WatchPublished]
433433
alice ! WatchPublishedTriggered(fundingTx)

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
248248
bob2blockchain.expectNoMessage(100 millis)
249249
}
250250

251+
private def checkWatchPublished(f: FixtureParam, spliceTx: Transaction): Unit = {
252+
import f._
253+
254+
alice2blockchain.expectWatchPublished(spliceTx.txid)
255+
alice2blockchain.expectNoMessage(100 millis)
256+
bob2blockchain.expectWatchPublished(spliceTx.txid)
257+
bob2blockchain.expectNoMessage(100 millis)
258+
}
259+
251260
private def confirmSpliceTx(f: FixtureParam, spliceTx: Transaction): Unit = {
252261
import f._
253262

@@ -271,6 +280,9 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
271280
private def setupHtlcs(f: FixtureParam): TestHtlcs = {
272281
import f._
273282

283+
val localBalance = alice.commitments.latest.localCommit.spec.toLocal
284+
val remoteBalance = alice.commitments.latest.localCommit.spec.toRemote
285+
274286
// Concurrently add htlcs in both directions so that commit indices don't match.
275287
val adda1 = addHtlc(15_000_000 msat, alice, bob, alice2bob, bob2alice)
276288
val adda2 = addHtlc(15_000_000 msat, alice, bob, alice2bob, bob2alice)
@@ -290,11 +302,9 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
290302
bob2alice.expectMsgType[RevokeAndAck]
291303
bob2alice.forward(alice)
292304

293-
val initialState = alice.stateData.asInstanceOf[DATA_NORMAL]
294-
assert(initialState.commitments.localCommitIndex != initialState.commitments.remoteCommitIndex)
295-
assert(initialState.commitments.latest.capacity == 1_500_000.sat)
296-
assert(initialState.commitments.latest.localCommit.spec.toLocal == 770_000_000.msat)
297-
assert(initialState.commitments.latest.localCommit.spec.toRemote == 665_000_000.msat)
305+
assert(alice.commitments.localCommitIndex != alice.commitments.remoteCommitIndex)
306+
assert(alice.commitments.latest.localCommit.spec.toLocal == localBalance - 30_000_000.msat)
307+
assert(alice.commitments.latest.localCommit.spec.toRemote == remoteBalance - 35_000_000.msat)
298308

299309
alice2relayer.expectMsgType[Relayer.RelayForward]
300310
alice2relayer.expectMsgType[Relayer.RelayForward]
@@ -2708,7 +2718,7 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
27082718
resendSpliceLockedOnReconnection(f)
27092719
}
27102720

2711-
test("re-send splice_locked on reconnection (taproot channels)", Tag(ChannelStateTestsTags.OptionSimpleTaprootPhoenix)) { f =>
2721+
test("re-send splice_locked on reconnection (taproot channels)", Tag(ChannelStateTestsTags.OptionSimpleTaproot)) { f =>
27122722
resendSpliceLockedOnReconnection(f)
27132723
}
27142724

@@ -2855,11 +2865,11 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
28552865
}
28562866
}
28572867

2858-
test("disconnect while updating channel before receiving splice_locked", Tag(ChannelStateTestsTags.OptionSimpleTaprootPhoenix)) { f =>
2868+
test("disconnect while updating channel before receiving splice_locked", Tag(ChannelStateTestsTags.OptionSimpleTaproot), Tag(ChannelStateTestsTags.ZeroConf)) { f =>
28592869
import f._
28602870

28612871
val spliceTx = initiateSplice(f, spliceIn_opt = Some(SpliceIn(500_000 sat, pushAmount = 0 msat)))
2862-
checkWatchConfirmed(f, spliceTx)
2872+
checkWatchPublished(f, spliceTx)
28632873

28642874
alice2bob.ignoreMsg { case _: ChannelUpdate => true }
28652875
bob2alice.ignoreMsg { case _: ChannelUpdate => true }
@@ -3360,13 +3370,13 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
33603370
assert(bob.stateData.asInstanceOf[DATA_CLOSED].fundingTxId == fundingTx2.txid)
33613371
}
33623372

3363-
test("force-close with multiple splices (previous active remote)", Tag(ChannelStateTestsTags.OptionSimpleTaprootPhoenix)) { f =>
3373+
test("force-close with multiple splices (previous active remote)", Tag(ChannelStateTestsTags.OptionSimpleTaproot), Tag(ChannelStateTestsTags.ZeroConf)) { f =>
33643374
import f._
33653375

33663376
val htlcs = setupHtlcs(f)
33673377

33683378
val fundingTx1 = initiateSplice(f, spliceIn_opt = Some(SpliceIn(500_000 sat)), spliceOut_opt = Some(SpliceOut(100_000 sat, defaultSpliceOutScriptPubKey)))
3369-
checkWatchConfirmed(f, fundingTx1)
3379+
checkWatchPublished(f, fundingTx1)
33703380

33713381
// The first splice confirms on Bob's side.
33723382
bob ! WatchFundingConfirmedTriggered(BlockHeight(400000), 42, fundingTx1)
@@ -3375,7 +3385,7 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
33753385
bob2alice.forward(alice)
33763386

33773387
val fundingTx2 = initiateSplice(f, spliceIn_opt = Some(SpliceIn(500_000 sat)))
3378-
checkWatchConfirmed(f, fundingTx2)
3388+
checkWatchPublished(f, fundingTx2)
33793389
alice2bob.expectNoMessage(100 millis)
33803390
bob2alice.expectNoMessage(100 millis)
33813391

0 commit comments

Comments
 (0)