Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import fr.acinq.eclair.channel._
import fr.acinq.eclair.channel.fsm.Channel
import fr.acinq.eclair.channel.publish.TxPublisher.{PublishFinalTx, PublishReplaceableTx}
import fr.acinq.eclair.channel.publish._
import fr.acinq.eclair.channel.states.ChannelStateTestsBase.FakeTxPublisherFactory
import fr.acinq.eclair.channel.states.ChannelStateTestsBase.{FakeTxPublisherFactory, PimpTestFSM}
import fr.acinq.eclair.payment.send.SpontaneousRecipient
import fr.acinq.eclair.payment.{Invoice, OutgoingPaymentPacket}
import fr.acinq.eclair.reputation.Reputation
Expand Down Expand Up @@ -373,7 +373,7 @@ trait ChannelStateTestsBase extends Assertions with Eventually {
val fundingTx = eventListener.expectMsgType[TransactionPublished].tx
eventually(assert(alice.stateName == WAIT_FOR_FUNDING_CONFIRMED))
eventually(assert(bob.stateName == WAIT_FOR_FUNDING_CONFIRMED))
if (channelParams.channelType.features.contains(Features.ZeroConf)) {
if (channelParams.channelType.features.contains(Features.ZeroConf) || alice.commitments.channelParams.zeroConf) {
alice2blockchain.expectMsgType[WatchPublished]
bob2blockchain.expectMsgType[WatchPublished]
alice ! WatchPublishedTriggered(fundingTx)
Expand Down Expand Up @@ -427,7 +427,7 @@ trait ChannelStateTestsBase extends Assertions with Eventually {
val fundingTx = eventListener.expectMsgType[TransactionPublished].tx
eventually(assert(alice.stateName == WAIT_FOR_DUAL_FUNDING_CONFIRMED))
eventually(assert(bob.stateName == WAIT_FOR_DUAL_FUNDING_CONFIRMED))
if (channelParams.channelType.features.contains(Features.ZeroConf)) {
if (channelParams.channelType.features.contains(Features.ZeroConf) || alice.commitments.channelParams.zeroConf) {
alice2blockchain.expectMsgType[WatchPublished]
bob2blockchain.expectMsgType[WatchPublished]
alice ! WatchPublishedTriggered(fundingTx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
bob2blockchain.expectNoMessage(100 millis)
}

private def checkWatchPublished(f: FixtureParam, spliceTx: Transaction): Unit = {
import f._

alice2blockchain.expectWatchPublished(spliceTx.txid)
alice2blockchain.expectNoMessage(100 millis)
bob2blockchain.expectWatchPublished(spliceTx.txid)
bob2blockchain.expectNoMessage(100 millis)
}

private def confirmSpliceTx(f: FixtureParam, spliceTx: Transaction): Unit = {
import f._

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

val localBalance = alice.commitments.latest.localCommit.spec.toLocal
val remoteBalance = alice.commitments.latest.localCommit.spec.toRemote

// Concurrently add htlcs in both directions so that commit indices don't match.
val adda1 = addHtlc(15_000_000 msat, alice, bob, alice2bob, bob2alice)
val adda2 = addHtlc(15_000_000 msat, alice, bob, alice2bob, bob2alice)
Expand All @@ -290,11 +302,9 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
bob2alice.expectMsgType[RevokeAndAck]
bob2alice.forward(alice)

val initialState = alice.stateData.asInstanceOf[DATA_NORMAL]
assert(initialState.commitments.localCommitIndex != initialState.commitments.remoteCommitIndex)
assert(initialState.commitments.latest.capacity == 1_500_000.sat)
assert(initialState.commitments.latest.localCommit.spec.toLocal == 770_000_000.msat)
assert(initialState.commitments.latest.localCommit.spec.toRemote == 665_000_000.msat)
assert(alice.commitments.localCommitIndex != alice.commitments.remoteCommitIndex)
assert(alice.commitments.latest.localCommit.spec.toLocal == localBalance - 30_000_000.msat)
assert(alice.commitments.latest.localCommit.spec.toRemote == remoteBalance - 35_000_000.msat)

alice2relayer.expectMsgType[Relayer.RelayForward]
alice2relayer.expectMsgType[Relayer.RelayForward]
Expand Down Expand Up @@ -2708,7 +2718,7 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
resendSpliceLockedOnReconnection(f)
}

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

Expand Down Expand Up @@ -2855,11 +2865,11 @@ class NormalSplicesStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik
}
}

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

val spliceTx = initiateSplice(f, spliceIn_opt = Some(SpliceIn(500_000 sat, pushAmount = 0 msat)))
checkWatchConfirmed(f, spliceTx)
checkWatchPublished(f, spliceTx)

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

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

val htlcs = setupHtlcs(f)

val fundingTx1 = initiateSplice(f, spliceIn_opt = Some(SpliceIn(500_000 sat)), spliceOut_opt = Some(SpliceOut(100_000 sat, defaultSpliceOutScriptPubKey)))
checkWatchConfirmed(f, fundingTx1)
checkWatchPublished(f, fundingTx1)

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

val fundingTx2 = initiateSplice(f, spliceIn_opt = Some(SpliceIn(500_000 sat)))
checkWatchConfirmed(f, fundingTx2)
checkWatchPublished(f, fundingTx2)
alice2bob.expectNoMessage(100 millis)
bob2alice.expectNoMessage(100 millis)

Expand Down