Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
We now require at least `option_static_remotekey`.
  • Loading branch information
t-bast committed Sep 26, 2023
1 parent 6765c85 commit 6c4618d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,15 @@ abstract class ChannelIntegrationSpec extends IntegrationSpec {
paymentSender.expectMsgType[PaymentSent](max = 60 seconds)
// we then generate enough blocks so that nodes get their main delayed output
generateBlocks(25, Some(minerAddress))
// F should have 2 recv transactions: the redeemed htlc and its main output
// C should have 1 recv transaction: its main output
val expectedTxCountC = 1 // C should have 1 recv transaction: its main output
val expectedTxCountF = commitmentFormat match {
case _: AnchorOutputsCommitmentFormat => 2 // F should have 2 recv transactions: the redeemed htlc and its main output
case Transactions.DefaultCommitmentFormat => 1 // F's main output uses static_remotekey
}
awaitCond({
val receivedByC = listReceivedByAddress(finalAddressC, sender)
val receivedByF = listReceivedByAddress(finalAddressF)
(receivedByF diff previouslyReceivedByF).size == 2 && (receivedByC diff previouslyReceivedByC).size == 1
(receivedByF diff previouslyReceivedByF).size == expectedTxCountF && (receivedByC diff previouslyReceivedByC).size == expectedTxCountC
}, max = 30 seconds, interval = 1 second)
// we generate blocks to make txs confirm
generateBlocks(2, Some(minerAddress))
Expand Down Expand Up @@ -221,12 +224,15 @@ abstract class ChannelIntegrationSpec extends IntegrationSpec {
paymentSender.expectMsgType[PaymentSent](max = 60 seconds)
// we then generate enough blocks so that F gets its htlc-success delayed output
generateBlocks(25, Some(minerAddress))
// F should have 2 recv transactions: the redeemed htlc and its main output
// C should have 1 recv transaction: its main output
val expectedTxCountC = commitmentFormat match {
case _: AnchorOutputsCommitmentFormat => 1 // C should have 1 recv transaction: its main output
case Transactions.DefaultCommitmentFormat => 0 // C's main output uses static_remotekey
}
val expectedTxCountF = 2 // F should have 2 recv transactions: the redeemed htlc and its main output
awaitCond({
val receivedByC = listReceivedByAddress(finalAddressC, sender)
val receivedByF = listReceivedByAddress(finalAddressF, sender)
(receivedByF diff previouslyReceivedByF).size == 2 && (receivedByC diff previouslyReceivedByC).size == 1
(receivedByF diff previouslyReceivedByF).size == expectedTxCountF && (receivedByC diff previouslyReceivedByC).size == expectedTxCountC
}, max = 30 seconds, interval = 1 second)
// we generate blocks to make txs confirm
generateBlocks(2, Some(minerAddress))
Expand Down Expand Up @@ -271,12 +277,15 @@ abstract class ChannelIntegrationSpec extends IntegrationSpec {
assert(failed.failures.head.asInstanceOf[RemoteFailure].e == DecryptedFailurePacket(nodes("C").nodeParams.nodeId, PermanentChannelFailure()))
// we then generate enough blocks to confirm all delayed transactions
generateBlocks(25, Some(minerAddress))
// C should have 2 recv transactions: its main output and the htlc timeout
// F should have 1 recv transaction: its main output
val expectedTxCountC = 2 // C should have 2 recv transactions: its main output and the htlc timeout
val expectedTxCountF = commitmentFormat match {
case _: AnchorOutputsCommitmentFormat => 1 // F should have 1 recv transaction: its main output
case Transactions.DefaultCommitmentFormat => 0 // F's main output uses static_remotekey
}
awaitCond({
val receivedByC = listReceivedByAddress(finalAddressC, sender)
val receivedByF = listReceivedByAddress(finalAddressF, sender)
(receivedByF diff previouslyReceivedByF).size == 1 && (receivedByC diff previouslyReceivedByC).size == 2
(receivedByF diff previouslyReceivedByF).size == expectedTxCountF && (receivedByC diff previouslyReceivedByC).size == expectedTxCountC
}, max = 30 seconds, interval = 1 second)
// we generate blocks to make txs confirm
generateBlocks(2, Some(minerAddress))
Expand Down Expand Up @@ -324,12 +333,15 @@ abstract class ChannelIntegrationSpec extends IntegrationSpec {
assert(failed.failures.head.asInstanceOf[RemoteFailure].e == DecryptedFailurePacket(nodes("C").nodeParams.nodeId, PermanentChannelFailure()))
// we then generate enough blocks to confirm all delayed transactions
generateBlocks(25, Some(minerAddress))
// C should have 2 recv transactions: its main output and the htlc timeout
// F should have 1 recv transaction: its main output
val expectedTxCountC = commitmentFormat match {
case _: AnchorOutputsCommitmentFormat => 2 // C should have 2 recv transactions: its main output and the htlc timeout
case Transactions.DefaultCommitmentFormat => 1 // C's main output uses static_remotekey
}
val expectedTxCountF = 1 // F should have 1 recv transaction: its main output
awaitCond({
val receivedByC = listReceivedByAddress(finalAddressC, sender)
val receivedByF = listReceivedByAddress(finalAddressF, sender)
(receivedByF diff previouslyReceivedByF).size == 1 && (receivedByC diff previouslyReceivedByC).size == 2
(receivedByF diff previouslyReceivedByF).size == expectedTxCountF && (receivedByC diff previouslyReceivedByC).size == expectedTxCountC
}, max = 30 seconds, interval = 1 second)
// we generate blocks to make tx confirm
generateBlocks(2, Some(minerAddress))
Expand Down Expand Up @@ -455,9 +467,9 @@ abstract class ChannelIntegrationSpec extends IntegrationSpec {
class StandardChannelIntegrationSpec extends ChannelIntegrationSpec {

test("start eclair nodes") {
instantiateEclairNode("A", ConfigFactory.parseMap(Map("eclair.node-alias" -> "A", "eclair.channel.expiry-delta-blocks" -> 40, "eclair.channel.fulfill-safety-before-timeout-blocks" -> 12, "eclair.server.port" -> 29740, "eclair.api.port" -> 28090).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig))
instantiateEclairNode("A", ConfigFactory.parseMap(Map("eclair.node-alias" -> "A", "eclair.channel.expiry-delta-blocks" -> 40, "eclair.channel.fulfill-safety-before-timeout-blocks" -> 12, "eclair.server.port" -> 29740, "eclair.api.port" -> 28090).asJava).withFallback(withStaticRemoteKey).withFallback(commonConfig))
instantiateEclairNode("C", ConfigFactory.parseMap(Map("eclair.node-alias" -> "C", "eclair.channel.expiry-delta-blocks" -> 40, "eclair.channel.fulfill-safety-before-timeout-blocks" -> 12, "eclair.server.port" -> 29741, "eclair.api.port" -> 28091).asJava).withFallback(withAnchorOutputs).withFallback(commonConfig))
instantiateEclairNode("F", ConfigFactory.parseMap(Map("eclair.node-alias" -> "F", "eclair.channel.expiry-delta-blocks" -> 40, "eclair.channel.fulfill-safety-before-timeout-blocks" -> 12, "eclair.server.port" -> 29742, "eclair.api.port" -> 28092).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig))
instantiateEclairNode("F", ConfigFactory.parseMap(Map("eclair.node-alias" -> "F", "eclair.channel.expiry-delta-blocks" -> 40, "eclair.channel.fulfill-safety-before-timeout-blocks" -> 12, "eclair.server.port" -> 29742, "eclair.api.port" -> 28092).asJava).withFallback(withStaticRemoteKey).withFallback(commonConfig))
}

test("connect nodes") {
Expand Down Expand Up @@ -614,10 +626,11 @@ class StandardChannelIntegrationSpec extends ChannelIntegrationSpec {
sender.expectMsg(htlcSuccess.head.txid)
bitcoinClient.publishTransaction(htlcTimeout.head).pipeTo(sender.ref)
sender.expectMsg(htlcTimeout.head.txid)
// at this point C should have 6 recv transactions: its previous main output, F's main output and all htlc outputs (taken as punishment)
// at this point C should have 5 recv transactions: F's main output and all htlc outputs (taken as punishment)
// C's main output uses static_remotekey, so C doesn't need to claim it
awaitCond({
val receivedByC = listReceivedByAddress(finalAddressC, sender)
(receivedByC diff previouslyReceivedByC).size == 6
(receivedByC diff previouslyReceivedByC).size == 5
}, max = 30 seconds, interval = 1 second)
// we generate blocks to make txs confirm
generateBlocks(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,12 @@ abstract class IntegrationSpec extends TestKitBaseClass with BitcoindService wit
s"eclair.features.${RouteBlinding.rfcName}" -> "optional",
).asJava)

val withDefaultCommitment = commonFeatures.withFallback(ConfigFactory.parseMap(Map(
s"eclair.features.${StaticRemoteKey.rfcName}" -> "disabled",
val withStaticRemoteKey = commonFeatures.withFallback(ConfigFactory.parseMap(Map(
s"eclair.features.${StaticRemoteKey.rfcName}" -> "mandatory",
s"eclair.features.${AnchorOutputs.rfcName}" -> "disabled",
s"eclair.features.${AnchorOutputsZeroFeeHtlcTx.rfcName}" -> "disabled",
).asJava))

val withStaticRemoteKey = ConfigFactory.parseMap(Map(
s"eclair.features.${StaticRemoteKey.rfcName}" -> "optional"
).asJava).withFallback(withDefaultCommitment)

val withAnchorOutputs = ConfigFactory.parseMap(Map(
s"eclair.features.${AnchorOutputs.rfcName}" -> "optional"
).asJava).withFallback(withStaticRemoteKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package fr.acinq.eclair.integration

import akka.actor.ActorRef
import akka.actor.testkit.typed.scaladsl.{TestProbe => TypedProbe}
import akka.actor.typed.scaladsl.adapter._
import akka.pattern.pipe
Expand Down Expand Up @@ -62,10 +61,10 @@ import scala.jdk.CollectionConverters._
class PaymentIntegrationSpec extends IntegrationSpec {

test("start eclair nodes") {
instantiateEclairNode("A", ConfigFactory.parseMap(Map("eclair.node-alias" -> "A", "eclair.channel.expiry-delta-blocks" -> 130, "eclair.server.port" -> 29730, "eclair.api.port" -> 28080, "eclair.channel.channel-flags.announce-channel" -> false).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig)) // A's channels are private
instantiateEclairNode("B", ConfigFactory.parseMap(Map("eclair.node-alias" -> "B", "eclair.channel.expiry-delta-blocks" -> 131, "eclair.server.port" -> 29731, "eclair.api.port" -> 28081, "eclair.trampoline-payments-enable" -> true, "eclair.onion-messages.relay-policy" -> "relay-all").asJava).withFallback(withDefaultCommitment).withFallback(commonConfig))
instantiateEclairNode("A", ConfigFactory.parseMap(Map("eclair.node-alias" -> "A", "eclair.channel.expiry-delta-blocks" -> 130, "eclair.server.port" -> 29730, "eclair.api.port" -> 28080, "eclair.channel.channel-flags.announce-channel" -> false).asJava).withFallback(withStaticRemoteKey).withFallback(commonConfig)) // A's channels are private
instantiateEclairNode("B", ConfigFactory.parseMap(Map("eclair.node-alias" -> "B", "eclair.channel.expiry-delta-blocks" -> 131, "eclair.server.port" -> 29731, "eclair.api.port" -> 28081, "eclair.trampoline-payments-enable" -> true, "eclair.onion-messages.relay-policy" -> "relay-all").asJava).withFallback(withStaticRemoteKey).withFallback(commonConfig))
instantiateEclairNode("C", ConfigFactory.parseMap(Map("eclair.node-alias" -> "C", "eclair.channel.expiry-delta-blocks" -> 132, "eclair.server.port" -> 29732, "eclair.api.port" -> 28082, "eclair.trampoline-payments-enable" -> true).asJava).withFallback(withDualFunding).withFallback(commonConfig))
instantiateEclairNode("D", ConfigFactory.parseMap(Map("eclair.node-alias" -> "D", "eclair.channel.expiry-delta-blocks" -> 133, "eclair.server.port" -> 29733, "eclair.api.port" -> 28083, "eclair.trampoline-payments-enable" -> true).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig))
instantiateEclairNode("D", ConfigFactory.parseMap(Map("eclair.node-alias" -> "D", "eclair.channel.expiry-delta-blocks" -> 133, "eclair.server.port" -> 29733, "eclair.api.port" -> 28083, "eclair.trampoline-payments-enable" -> true).asJava).withFallback(withStaticRemoteKey).withFallback(commonConfig))
instantiateEclairNode("E", ConfigFactory.parseMap(Map("eclair.node-alias" -> "E", "eclair.channel.expiry-delta-blocks" -> 134, "eclair.server.port" -> 29734, "eclair.api.port" -> 28084).asJava).withFallback(withDualFunding).withFallback(commonConfig))
instantiateEclairNode("F", ConfigFactory.parseMap(Map("eclair.node-alias" -> "F", "eclair.channel.expiry-delta-blocks" -> 135, "eclair.server.port" -> 29735, "eclair.api.port" -> 28085, "eclair.trampoline-payments-enable" -> true).asJava).withFallback(commonConfig))
instantiateEclairNode("G", ConfigFactory.parseMap(Map("eclair.node-alias" -> "G", "eclair.channel.expiry-delta-blocks" -> 136, "eclair.server.port" -> 29736, "eclair.api.port" -> 28086, "eclair.relay.fees.public-channels.fee-base-msat" -> 1010, "eclair.relay.fees.public-channels.fee-proportional-millionths" -> 102, "eclair.trampoline-payments-enable" -> true).asJava).withFallback(commonConfig))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ import scala.jdk.CollectionConverters._
class StartupIntegrationSpec extends IntegrationSpec {

test("no bitcoind wallet configured and one wallet loaded") {
instantiateEclairNode("A", ConfigFactory.parseMap(Map("eclair.bitcoind.wallet" -> "", "eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig))
instantiateEclairNode("A", ConfigFactory.parseMap(Map("eclair.bitcoind.wallet" -> "", "eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withStaticRemoteKey).withFallback(commonConfig))
}

test("no bitcoind wallet configured and two wallets loaded") {
val sender = TestProbe()
sender.send(bitcoincli, BitcoinReq("createwallet", ""))
sender.expectMsgType[Any]
val thrown = intercept[BitcoinDefaultWalletException] {
instantiateEclairNode("C", ConfigFactory.parseMap(Map("eclair.bitcoind.wallet" -> "", "eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig))
instantiateEclairNode("C", ConfigFactory.parseMap(Map("eclair.bitcoind.wallet" -> "", "eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withStaticRemoteKey).withFallback(commonConfig))
}
assert(thrown == BitcoinDefaultWalletException(List(defaultWallet, "")))
}
Expand All @@ -48,23 +48,23 @@ class StartupIntegrationSpec extends IntegrationSpec {
val sender = TestProbe()
sender.send(bitcoincli, BitcoinReq("createwallet", ""))
sender.expectMsgType[Any]
instantiateEclairNode("D", ConfigFactory.parseMap(Map("eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig))
instantiateEclairNode("D", ConfigFactory.parseMap(Map("eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withStaticRemoteKey).withFallback(commonConfig))
}

test("explicit bitcoind wallet configured but not loaded") {
val sender = TestProbe()
sender.send(bitcoincli, BitcoinReq("createwallet", ""))
sender.expectMsgType[Any]
val thrown = intercept[BitcoinWalletNotLoadedException] {
instantiateEclairNode("E", ConfigFactory.parseMap(Map("eclair.bitcoind.wallet" -> "notloaded", "eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig))
instantiateEclairNode("E", ConfigFactory.parseMap(Map("eclair.bitcoind.wallet" -> "notloaded", "eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withStaticRemoteKey).withFallback(commonConfig))
}
assert(thrown == BitcoinWalletNotLoadedException("notloaded", List(defaultWallet, "")))
}

test("bitcoind started with wallets disabled") {
restartBitcoind(startupFlags = "-disablewallet", loadWallet = false)
val thrown = intercept[BitcoinWalletDisabledException] {
instantiateEclairNode("F", ConfigFactory.load().getConfig("eclair").withFallback(withDefaultCommitment).withFallback(commonConfig))
instantiateEclairNode("F", ConfigFactory.load().getConfig("eclair").withFallback(withStaticRemoteKey).withFallback(commonConfig))
}
assert(thrown == BitcoinWalletDisabledException(e = JsonRPCError(Error(-32601, "Method not found"))))
}
Expand Down

0 comments on commit 6c4618d

Please sign in to comment.