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 @@ -31,7 +31,7 @@ import fr.acinq.eclair.transactions.Transactions
import fr.acinq.eclair.{TimestampSecond, randomBytes32}
import scodec.bits._

import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.{ExecutionContext, Future, Promise}
import scala.util.{Failure, Random, Success}

/**
Expand Down Expand Up @@ -229,6 +229,14 @@ class SingleKeyOnChainWallet extends OnChainWallet with OnChainAddressCache {
override def getReceivePublicKeyScript(renew: Boolean): Seq[ScriptElt] = p2trScript
}

/** A wallet that blocks when called to fund transactions (useful to test events happening while funding). */
class BlockingOnChainWallet extends SingleKeyOnChainWallet {
override def makeFundingTx(pubkeyScript: ByteVector, amount: Satoshi, feeRatePerKw: FeeratePerKw, feeBudget_opt: Option[Satoshi])(implicit ec: ExecutionContext): Future[MakeFundingTxResponse] = {
// We create a dummy promise that will never be completed.
Promise().future
}
}

object DummyOnChainWallet {
val dummyReceivePubkey: PublicKey = PublicKey(hex"028feba10d0eafd0fad8fe20e6d9206e6bd30242826de05c63f459a00aced24b12")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import akka.testkit.{TestFSMRef, TestProbe}
import com.softwaremill.quicklens.ModifyPimp
import fr.acinq.bitcoin.scalacompat.{ByteVector32, SatoshiLong, TxId}
import fr.acinq.eclair.TestConstants.{Alice, Bob}
import fr.acinq.eclair.blockchain.BlockingOnChainWallet
import fr.acinq.eclair.channel._
import fr.acinq.eclair.channel.fsm.Channel
import fr.acinq.eclair.channel.fsm.Channel.TickChannelOpenTimeout
Expand All @@ -40,6 +41,7 @@ import scala.concurrent.duration._

class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with ChannelStateTestsBase {

private val BlockingOnChainWallet = "blocking_on_chain_wallet"
private val HighRemoteDustLimit = "high_remote_dust_limit"

case class FixtureParam(alice: TestFSMRef[ChannelState, ChannelData, Channel], bob: TestFSMRef[ChannelState, ChannelData, Channel], aliceOpenReplyTo: TestProbe, alice2bob: TestProbe, bob2alice: TestProbe, alice2blockchain: TestProbe, listener: TestProbe)
Expand All @@ -48,7 +50,8 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS
import com.softwaremill.quicklens._

val aliceNodeParams = Alice.nodeParams.modify(_.channelConf.maxRemoteDustLimit).setToIf(test.tags.contains(HighRemoteDustLimit))(15_000 sat)
val setup = init(aliceNodeParams, Bob.nodeParams, tags = test.tags)
val wallet_opt = if (test.tags.contains(BlockingOnChainWallet)) Some(new BlockingOnChainWallet()) else None
val setup = init(aliceNodeParams, Bob.nodeParams, tags = test.tags, walletA_opt = wallet_opt)
import setup._

val channelParams = computeChannelParams(setup, test.tags)
Expand All @@ -64,7 +67,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS
}
}

test("recv AcceptChannel (anchor outputs zero fee htlc txs)") { f =>
test("recv AcceptChannel (anchor outputs zero fee htlc txs)", Tag(BlockingOnChainWallet)) { f =>
import f._
val accept = bob2alice.expectMsgType[AcceptChannel]
// Since https://github.com/lightningnetwork/lightning-rfc/pull/714 we must include an empty upfront_shutdown_script.
Expand All @@ -76,7 +79,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS
aliceOpenReplyTo.expectNoMessage()
}

test("recv AcceptChannel (anchor outputs zero fee htlc txs and scid alias)", Tag(ChannelStateTestsTags.ScidAlias)) { f =>
test("recv AcceptChannel (anchor outputs zero fee htlc txs and scid alias)", Tag(ChannelStateTestsTags.ScidAlias), Tag(BlockingOnChainWallet)) { f =>
import f._
val accept = bob2alice.expectMsgType[AcceptChannel]
assert(accept.channelType_opt.contains(ChannelTypes.AnchorOutputsZeroFeeHtlcTx(scidAlias = true)))
Expand All @@ -86,7 +89,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS
aliceOpenReplyTo.expectNoMessage()
}

test("recv AcceptChannel (simple taproot channels phoenix)", Tag(ChannelStateTestsTags.OptionSimpleTaprootPhoenix)) { f =>
test("recv AcceptChannel (simple taproot channels phoenix)", Tag(ChannelStateTestsTags.OptionSimpleTaprootPhoenix), Tag(BlockingOnChainWallet)) { f =>
import f._
val accept = bob2alice.expectMsgType[AcceptChannel]
assert(accept.channelType_opt.contains(ChannelTypes.SimpleTaprootChannelsPhoenix))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package fr.acinq.eclair.channel.states.b
import akka.actor.Status
import akka.testkit.{TestFSMRef, TestProbe}
import fr.acinq.bitcoin.scalacompat.ByteVector32
import fr.acinq.eclair.blockchain.BlockingOnChainWallet
import fr.acinq.eclair.channel._
import fr.acinq.eclair.channel.fsm.Channel
import fr.acinq.eclair.channel.fsm.Channel.TickChannelOpenTimeout
Expand All @@ -40,7 +41,8 @@ class WaitForFundingInternalStateSpec extends TestKitBaseClass with FixtureAnyFu
case class FixtureParam(alice: TestFSMRef[ChannelState, ChannelData, Channel], aliceOpenReplyTo: TestProbe, alice2bob: TestProbe, bob2alice: TestProbe, alice2blockchain: TestProbe, listener: TestProbe)

override def withFixture(test: OneArgTest): Outcome = {
val setup = init(tags = test.tags)
// Note that we use a dummy wallet that doesn't complete its transaction funding.
val setup = init(tags = test.tags, walletA_opt = Some(new BlockingOnChainWallet()))
import setup._
val channelParams = computeChannelParams(setup, test.tags)
val listener = TestProbe()
Expand Down