From e7086180754f4a5495e41a254c5589f7a85a173f Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 23 May 2022 17:07:02 +0200 Subject: [PATCH 01/15] update test dependencies --- eclair-core/pom.xml | 2 +- eclair-node/pom.xml | 2 +- pom.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eclair-core/pom.xml b/eclair-core/pom.xml index 676b1c7b11..86185396fa 100644 --- a/eclair-core/pom.xml +++ b/eclair-core/pom.xml @@ -302,7 +302,7 @@ org.mockito mockito-scala-scalatest_${scala.version.short} - 1.5.9 + 1.17.5 test diff --git a/eclair-node/pom.xml b/eclair-node/pom.xml index 6f75cdba85..5f6fe8f97b 100644 --- a/eclair-node/pom.xml +++ b/eclair-node/pom.xml @@ -135,7 +135,7 @@ org.mockito mockito-scala-scalatest_${scala.version.short} - 1.5.9 + 1.17.5 test diff --git a/pom.xml b/pom.xml index f6272e3e76..48f3e25e5f 100644 --- a/pom.xml +++ b/pom.xml @@ -132,7 +132,7 @@ net.alchim31.maven scala-maven-plugin - 3.4.2 + 4.6.1 -feature @@ -274,7 +274,7 @@ org.scalatest scalatest_${scala.version.short} - 3.1.1 + 3.2.12 test From f28bedd6ba0896d27c392c5d57ad398b9090e2eb Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 27 May 2022 14:06:01 +0200 Subject: [PATCH 02/15] add node alias to log MDC for tests --- eclair-core/src/main/scala/fr/acinq/eclair/Logs.scala | 9 ++++++--- .../scala/fr/acinq/eclair/channel/fsm/Channel.scala | 2 +- .../src/main/scala/fr/acinq/eclair/io/Peer.scala | 2 +- .../scala/fr/acinq/eclair/io/ReconnectionTask.scala | 2 +- .../main/scala/fr/acinq/eclair/router/Router.scala | 11 ++++++----- eclair-core/src/test/resources/logback-test.xml | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/Logs.scala b/eclair-core/src/main/scala/fr/acinq/eclair/Logs.scala index 4a045b61c3..46456d0521 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/Logs.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/Logs.scala @@ -49,15 +49,18 @@ object Logs { parentPaymentId_opt: Option[UUID] = None, paymentId_opt: Option[UUID] = None, paymentHash_opt: Option[ByteVector32] = None, - txPublishId_opt: Option[UUID] = None): Map[String, String] = + txPublishId_opt: Option[UUID] = None, + nodeAlias_opt: Option[String] = None): Map[String, String] = Seq( + // nb: we preformat MDC values so that there is no white spaces in logs when they are not defined category_opt.map(l => "category" -> s" ${l.category}"), - remoteNodeId_opt.map(n => "nodeId" -> s" n:$n"), // nb: we preformat MDC values so that there is no white spaces in logs when they are not defined + remoteNodeId_opt.map(n => "nodeId" -> s" n:$n"), channelId_opt.map(c => "channelId" -> s" c:$c"), parentPaymentId_opt.map(p => "parentPaymentId" -> s" p:$p"), paymentId_opt.map(i => "paymentId" -> s" i:$i"), paymentHash_opt.map(h => "paymentHash" -> s" h:$h"), - txPublishId_opt.map(t => "txPublishId" -> s" t:$t") + txPublishId_opt.map(t => "txPublishId" -> s" t:$t"), + nodeAlias_opt.map(a => "nodeAlias" -> s" a:$a"), ).flatten.toMap /** diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala index c63762c96c..4a0b02e5cb 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala @@ -1884,7 +1884,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder, val case INPUT_RESTORED(data) => data.channelId case _ => stateData.channelId } - Logs.mdc(category_opt, remoteNodeId_opt = Some(remoteNodeId), channelId_opt = Some(id)) + Logs.mdc(category_opt, remoteNodeId_opt = Some(remoteNodeId), channelId_opt = Some(id), nodeAlias_opt = Some(nodeParams.alias)) } // we let the peer decide what to do diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/io/Peer.scala b/eclair-core/src/main/scala/fr/acinq/eclair/io/Peer.scala index e6da8cf17e..0fa63ef102 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/io/Peer.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/io/Peer.scala @@ -410,7 +410,7 @@ class Peer(val nodeParams: NodeParams, remoteNodeId: PublicKey, wallet: OnChainA } override def mdc(currentMessage: Any): MDC = { - Logs.mdc(LogCategory(currentMessage), Some(remoteNodeId), Logs.channelId(currentMessage)) + Logs.mdc(LogCategory(currentMessage), Some(remoteNodeId), Logs.channelId(currentMessage), nodeAlias_opt = Some(nodeParams.alias)) } } diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/io/ReconnectionTask.scala b/eclair-core/src/main/scala/fr/acinq/eclair/io/ReconnectionTask.scala index 8946afeb54..a2c5602904 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/io/ReconnectionTask.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/io/ReconnectionTask.scala @@ -157,7 +157,7 @@ class ReconnectionTask(nodeParams: NodeParams, remoteNodeId: PublicKey) extends } override def mdc(currentMessage: Any): MDC = { - Logs.mdc(Some(LogCategory.CONNECTION), Some(remoteNodeId)) + Logs.mdc(Some(LogCategory.CONNECTION), Some(remoteNodeId), nodeAlias_opt = Some(nodeParams.alias)) } } diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala b/eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala index e1adb6a0a4..42caea67d0 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/router/Router.scala @@ -257,12 +257,13 @@ class Router(val nodeParams: NodeParams, watcher: typed.ActorRef[ZmqWatcher.Comm override def mdc(currentMessage: Any): MDC = { val category_opt = LogCategory(currentMessage) - currentMessage match { - case s: SendChannelQuery => Logs.mdc(category_opt, remoteNodeId_opt = Some(s.remoteNodeId)) - case prm: PeerRoutingMessage => Logs.mdc(category_opt, remoteNodeId_opt = Some(prm.remoteNodeId)) - case lcu: LocalChannelUpdate => Logs.mdc(category_opt, remoteNodeId_opt = Some(lcu.remoteNodeId)) - case _ => Logs.mdc(category_opt) + val remoteNodeId_opt = currentMessage match { + case s: SendChannelQuery => Some(s.remoteNodeId) + case prm: PeerRoutingMessage => Some(prm.remoteNodeId) + case lcu: LocalChannelUpdate => Some(lcu.remoteNodeId) + case _ => None } + Logs.mdc(category_opt, remoteNodeId_opt = remoteNodeId_opt, nodeAlias_opt = Some(nodeParams.alias)) } } diff --git a/eclair-core/src/test/resources/logback-test.xml b/eclair-core/src/test/resources/logback-test.xml index e3f0af56c7..91441698aa 100644 --- a/eclair-core/src/test/resources/logback-test.xml +++ b/eclair-core/src/test/resources/logback-test.xml @@ -20,7 +20,7 @@ System.out - %date{HH:mm:ss.SSS} %highlight(%-5level) %replace(%logger{24}){'\$.*',''}%X{category}%X{nodeId}%X{channelId}%X{paymentHash}%.-11X{parentPaymentId}%.-11X{paymentId}%.-11X{txPublishId} - %msg%ex{12}%n + %date{HH:mm:ss.SSS} %highlight(%-5level) %replace(%logger{24}){'\$.*',''}%X{category}%.-9X{nodeId}%.-11X{channelId}%.-11X{paymentHash}%.-11X{parentPaymentId}%.-11X{paymentId}%.-11X{txPublishId}%.-11X{nodeAlias} - %msg%ex{12}%n From 0428509503a163538bc65aad89ca528abc51c413 Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 27 May 2022 19:10:12 +0200 Subject: [PATCH 03/15] proper base class for fixture tests --- .../blockchain/DummyOnChainWallet.scala | 10 +- .../basic/ThreeNodesIntegrationSpec.scala | 91 +++++++ .../basic/TwoNodesIntegrationSpec.scala | 96 +++++++ .../basic/fixtures/MinimalNodeFixture.scala | 248 ++++++++++++++++++ .../basic/fixtures/ThreeNodesFixture.scala | 31 +++ .../basic/fixtures/TwoNodesFixture.scala | 27 ++ .../acinq/eclair/testutils/FixtureSpec.scala | 82 ++++++ 7 files changed, 582 insertions(+), 3 deletions(-) create mode 100644 eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala create mode 100644 eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala create mode 100644 eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala create mode 100644 eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/ThreeNodesFixture.scala create mode 100644 eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/TwoNodesFixture.scala create mode 100644 eclair-core/src/test/scala/fr/acinq/eclair/testutils/FixtureSpec.scala diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/DummyOnChainWallet.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/DummyOnChainWallet.scala index 9cbebadc3a..5476611fd6 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/DummyOnChainWallet.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/DummyOnChainWallet.scala @@ -16,9 +16,9 @@ package fr.acinq.eclair.blockchain +import fr.acinq.bitcoin.TxIn.SEQUENCE_FINAL import fr.acinq.bitcoin.scalacompat.Crypto.PublicKey import fr.acinq.bitcoin.scalacompat.{ByteVector32, Crypto, OutPoint, Satoshi, SatoshiLong, Transaction, TxIn, TxOut} -import fr.acinq.bitcoin.TxIn.SEQUENCE_FINAL import fr.acinq.eclair.blockchain.OnChainWallet.{MakeFundingTxResponse, OnChainBalance} import fr.acinq.eclair.blockchain.fee.FeeratePerKw import scodec.bits._ @@ -32,6 +32,7 @@ class DummyOnChainWallet extends OnChainWallet { import DummyOnChainWallet._ + val funded = collection.concurrent.TrieMap.empty[ByteVector32, Transaction] var rolledback = Set.empty[Transaction] override def onChainBalance()(implicit ec: ExecutionContext): Future[OnChainBalance] = Future.successful(OnChainBalance(1105 sat, 561 sat)) @@ -40,8 +41,11 @@ class DummyOnChainWallet extends OnChainWallet { override def getReceivePubkey(receiveAddress: Option[String] = None)(implicit ec: ExecutionContext): Future[Crypto.PublicKey] = Future.successful(dummyReceivePubkey) - override def makeFundingTx(pubkeyScript: ByteVector, amount: Satoshi, feeRatePerKw: FeeratePerKw)(implicit ec: ExecutionContext): Future[MakeFundingTxResponse] = - Future.successful(DummyOnChainWallet.makeDummyFundingTx(pubkeyScript, amount)) + override def makeFundingTx(pubkeyScript: ByteVector, amount: Satoshi, feeRatePerKw: FeeratePerKw)(implicit ec: ExecutionContext): Future[MakeFundingTxResponse] = { + val tx = DummyOnChainWallet.makeDummyFundingTx(pubkeyScript, amount) + funded += (tx.fundingTx.txid -> tx.fundingTx) + Future.successful(tx) + } override def commit(tx: Transaction)(implicit ec: ExecutionContext): Future[Boolean] = Future.successful(true) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala new file mode 100644 index 0000000000..ddc5dfc10f --- /dev/null +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala @@ -0,0 +1,91 @@ +package fr.acinq.eclair.integration.basic + +import com.softwaremill.quicklens.ModifyPimp +import fr.acinq.bitcoin.scalacompat.{Block, ByteVector32, SatoshiLong} +import fr.acinq.eclair.ShortChannelId.txIndex +import fr.acinq.eclair.crypto.keymanager.{LocalChannelKeyManager, LocalNodeKeyManager} +import fr.acinq.eclair.integration.basic.fixtures.ThreeNodesFixture +import fr.acinq.eclair.testutils.FixtureSpec +import fr.acinq.eclair.{BlockHeight, MilliSatoshiLong, TestConstants, TestDatabases} +import org.scalatest.TestData +import org.scalatest.concurrent.IntegrationPatience +import scodec.bits.HexStringSyntax + +import scala.concurrent.duration.DurationInt + + +/** + * This test checks the integration between Channel and Router (events, etc.) + */ +class ThreeNodesIntegrationSpec extends FixtureSpec with IntegrationPatience { + + type FixtureParam = ThreeNodesFixture + + import fr.acinq.eclair.integration.basic.fixtures.MinimalNodeFixture._ + + override def createFixture(testData: TestData): FixtureParam = { + val aliceParams = TestConstants.Alice.nodeParams + .modify(_.channelConf.dustLimit).setTo(1000 sat) + .modify(_.routerConf.routerBroadcastInterval).setTo(1 second) + .modifyAll(_.relayParams.privateChannelFees.feeBase, _.relayParams.publicChannelFees.feeBase).setTo(1_000 msat) + .modifyAll(_.relayParams.privateChannelFees.feeProportionalMillionths, _.relayParams.publicChannelFees.feeProportionalMillionths).setTo(10) + val bobParams = TestConstants.Bob.nodeParams + .modify(_.routerConf.routerBroadcastInterval).setTo(1 second) + .modifyAll(_.relayParams.privateChannelFees.feeBase, _.relayParams.publicChannelFees.feeBase).setTo(1_000 msat) + .modifyAll(_.relayParams.privateChannelFees.feeProportionalMillionths, _.relayParams.publicChannelFees.feeProportionalMillionths).setTo(10) + + val charlieSeed: ByteVector32 = ByteVector32(hex"ebd5a5d3abfb3ef73731eb3418d918f247445183180522674666db98a66411cc") // 02cccc... + val charlieNodeKeyManager = new LocalNodeKeyManager(charlieSeed, Block.RegtestGenesisBlock.hash) + val charlieChannelKeyManager = new LocalChannelKeyManager(charlieSeed, Block.RegtestGenesisBlock.hash) + val charlieParams = TestConstants.Bob.nodeParams + .modify(_.alias).setTo("charlie") + .modify(_.nodeKeyManager).setTo(charlieNodeKeyManager) + .modify(_.db).setTo(TestDatabases.inMemoryDb()) + .modify(_.channelKeyManager).setTo(charlieChannelKeyManager) + ThreeNodesFixture(aliceParams, bobParams, charlieParams) + } + + override def cleanupFixture(fixture: FixtureParam): Unit = { + fixture.cleanup() + } + + test("connect alice->bob and bob->charlie, pay alice->charlie") { f => + import f._ + connect(alice, bob) + connect(bob, charlie) + + val channelIdAB = openChannel(alice, bob, 100_000 sat).channelId + val channelIdBC = openChannel(bob, charlie, 100_000 sat).channelId + + val fundingTxAB = fundingTx(alice, channelIdAB) + val fundingTxBC = fundingTx(bob, channelIdBC) + + val shortIdAB = confirmChannel(alice, bob, channelIdAB, BlockHeight(420_000), 21) + val shortIdBC = confirmChannel(bob, charlie, channelIdBC, BlockHeight(420_001), 22) + + val fundingTxs = Map( + shortIdAB -> fundingTxAB, + shortIdBC -> fundingTxBC + ) + + // auto-validate channel announcements + alice.watcher.setAutoPilot(autoValidatePublicChannels(fundingTxs)) + bob.watcher.setAutoPilot(autoValidatePublicChannels(fundingTxs)) + + confirmChannelDeep(alice, bob, channelIdAB, shortIdAB.blockHeight, txIndex(shortIdAB)) + confirmChannelDeep(bob, charlie, channelIdBC, shortIdBC.blockHeight, txIndex(shortIdBC)) + + // alice now knows about bob-charlie + eventually { + val routerData = getRouterData(alice) + //prettyPrint(routerData, alice, bob, charlie) + assert(routerData.channels.size == 2) // 2 channels + assert(routerData.channels.values.flatMap(c => c.update_1_opt.toSeq ++ c.update_2_opt.toSeq).size == 3) // only 3 channel_updates because c->b is disabled (all funds on b) + } + + sendPayment(alice, charlie, 100_000 msat) + } + +} + + diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala new file mode 100644 index 0000000000..bd536bfa60 --- /dev/null +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala @@ -0,0 +1,96 @@ +package fr.acinq.eclair.integration.basic + +import com.softwaremill.quicklens.ModifyPimp +import fr.acinq.bitcoin.scalacompat.SatoshiLong +import fr.acinq.eclair.channel.{DATA_NORMAL, NORMAL} +import fr.acinq.eclair.integration.basic.fixtures.TwoNodesFixture +import fr.acinq.eclair.testutils.FixtureSpec +import fr.acinq.eclair.{BlockHeight, MilliSatoshiLong, TestConstants} +import org.scalatest.TestData +import org.scalatest.concurrent.IntegrationPatience + + +/** + * This test checks the integration between Channel and Router (events, etc.) + */ +class TwoNodesIntegrationSpec extends FixtureSpec with IntegrationPatience { + + type FixtureParam = TwoNodesFixture + + import fr.acinq.eclair.integration.basic.fixtures.MinimalNodeFixture._ + + override def createFixture(testData: TestData): FixtureParam = { + val aliceParams = TestConstants.Alice.nodeParams + .modify(_.channelConf.dustLimit).setTo(1000 sat) + val bobParams = TestConstants.Bob.nodeParams + TwoNodesFixture(aliceParams, bobParams) + } + + override def cleanupFixture(fixture: FixtureParam): Unit = { + fixture.cleanup() + } + + test("connect alice to bob") { f => + import f._ + connect(alice, bob) + } + + test("open a channel alice-bob") { f => + import f._ + connect(alice, bob) + val channelId = openChannel(alice, bob, 100_000 sat).channelId + confirmChannel(alice, bob, channelId, BlockHeight(420_000), 21) + assert(getChannelState(alice, channelId) == NORMAL) + assert(getChannelState(bob, channelId) == NORMAL) + } + + test("open a channel alice-bob (autoconfirm)") { f => + import f._ + alice.watcher.setAutoPilot(autoConfirmLocalChannels(alice.wallet.funded)) + bob.watcher.setAutoPilot(autoConfirmLocalChannels(alice.wallet.funded)) + connect(alice, bob) + val channelId = openChannel(alice, bob, 100_000 sat).channelId + eventually { + assert(getChannelState(alice, channelId) == NORMAL) + assert(getChannelState(bob, channelId) == NORMAL) + } + } + + test("open a channel alice-bob and confirm deeply") { f => + import f._ + connect(alice, bob) + val channelId = openChannel(alice, bob, 100_000 sat).channelId + confirmChannel(alice, bob, channelId, BlockHeight(420_000), 21) + confirmChannelDeep(alice, bob, channelId, BlockHeight(420_000), 21) + assert(getChannelData(alice, channelId).asInstanceOf[DATA_NORMAL].buried) + assert(getChannelData(bob, channelId).asInstanceOf[DATA_NORMAL].buried) + } + + test("open a channel alice-bob and confirm deeply (autoconfirm)") { f => + import f._ + alice.watcher.setAutoPilot(autoConfirmLocalChannels(alice.wallet.funded)) + bob.watcher.setAutoPilot(autoConfirmLocalChannels(alice.wallet.funded)) + connect(alice, bob) + val channelId = openChannel(alice, bob, 100_000 sat).channelId + eventually { + assert(getChannelData(alice, channelId).asInstanceOf[DATA_NORMAL].buried) + assert(getChannelData(bob, channelId).asInstanceOf[DATA_NORMAL].buried) + } + } + + test("open a channel alice-bob and make a payment alice->bob") { f => + import f._ + connect(alice, bob) + val channelId = openChannel(alice, bob, 100_000 sat).channelId + confirmChannel(alice, bob, channelId, BlockHeight(420_000), 21) + + eventually { + getRouterData(alice).privateChannels.size == 1 + } + + sendPayment(alice, bob, 10_000 msat) + } + +} + + diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala new file mode 100644 index 0000000000..72166ff5c2 --- /dev/null +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala @@ -0,0 +1,248 @@ +package fr.acinq.eclair.integration.basic.fixtures + +import akka.actor.typed.scaladsl.adapter.ClassicActorRefOps +import akka.actor.{ActorRef, ActorSystem, Props} +import akka.testkit.{TestActor, TestProbe} +import fr.acinq.bitcoin.scalacompat.{ByteVector32, Satoshi, Transaction} +import fr.acinq.eclair.blockchain.DummyOnChainWallet +import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher +import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher.{WatchFundingConfirmed, WatchFundingConfirmedTriggered, WatchFundingDeeplyBuried, WatchFundingDeeplyBuriedTriggered} +import fr.acinq.eclair.channel.ChannelOpenResponse.ChannelOpened +import fr.acinq.eclair.channel._ +import fr.acinq.eclair.channel.fsm.Channel +import fr.acinq.eclair.crypto.TransportHandler +import fr.acinq.eclair.io.PeerConnection.ConnectionResult +import fr.acinq.eclair.io.{Peer, PeerConnection, Switchboard} +import fr.acinq.eclair.payment.receive.{MultiPartHandler, PaymentHandler} +import fr.acinq.eclair.payment.relay.Relayer +import fr.acinq.eclair.payment.send.PaymentInitiator +import fr.acinq.eclair.payment.{Bolt11Invoice, PaymentSent} +import fr.acinq.eclair.router.Router +import fr.acinq.eclair.wire.protocol.IPAddress +import fr.acinq.eclair.{BlockHeight, MilliSatoshi, MilliSatoshiLong, NodeParams, ShortChannelId, TestBitcoinCoreClient} +import org.scalatest.Assertions + +import java.net.InetAddress +import scala.util.{Random, Try} + + +/** + * A minimal node setup, with real actors. + * + * Only the bitcoin watcher and wallet are mocked. + */ +case class MinimalNodeFixture private(nodeParams: NodeParams, + system: ActorSystem, + register: ActorRef, + router: ActorRef, + relayer: ActorRef, + switchboard: ActorRef, + paymentInitiator: ActorRef, + paymentHandler: ActorRef, + watcher: TestProbe, + wallet: DummyOnChainWallet) + +object MinimalNodeFixture extends Assertions { + def apply(nodeParams: NodeParams): MinimalNodeFixture = { + implicit val system: ActorSystem = ActorSystem(s"system-${nodeParams.alias}") + val bitcoinClient = new TestBitcoinCoreClient() + val wallet = new DummyOnChainWallet() + val watcher = TestProbe("watcher") + val watcherTyped = watcher.ref.toTyped[ZmqWatcher.Command] + val register = system.actorOf(Props(new Register), "register") + val router = system.actorOf(Router.props(nodeParams, watcherTyped), "router") + val paymentHandler = system.actorOf(PaymentHandler.props(nodeParams, register), "payment-handler") + val relayer = system.actorOf(Relayer.props(nodeParams, router, register, paymentHandler), "relayer") + val txPublisherFactory = Channel.SimpleTxPublisherFactory(nodeParams, watcherTyped, bitcoinClient) + val channelFactory = Peer.SimpleChannelFactory(nodeParams, watcherTyped, relayer, wallet, txPublisherFactory) + val peerFactory = Switchboard.SimplePeerFactory(nodeParams, wallet, channelFactory) + val switchboard = system.actorOf(Switchboard.props(nodeParams, peerFactory), "switchboard") + val paymentFactory = PaymentInitiator.SimplePaymentFactory(nodeParams, router, register) + val paymentInitiator = system.actorOf(PaymentInitiator.props(nodeParams, paymentFactory), "payment-initiator") + MinimalNodeFixture( + nodeParams, + system, + register = register, + router = router, + relayer = relayer, + switchboard = switchboard, + paymentInitiator = paymentInitiator, + paymentHandler = paymentHandler, + watcher = watcher, + wallet = wallet + ) + } + + def connect(node1: MinimalNodeFixture, node2: MinimalNodeFixture)(implicit system: ActorSystem): ConnectionResult.Connected = { + val sender = TestProbe("sender") + + val connection1 = TestProbe("connection-1")(node1.system) + val transport1 = TestProbe("transport-1")(node1.system) + + val connection2 = TestProbe("connection-2")(node2.system) + val transport2 = TestProbe("transport-2")(node2.system) + + val peerConnection1 = node1.system.actorOf(PeerConnection.props(node1.nodeParams.keyPair, node1.nodeParams.peerConnectionConf, node1.switchboard, node1.router), s"peer-connection-${Random.nextLong()}") + val peerConnection2 = node2.system.actorOf(PeerConnection.props(node2.nodeParams.keyPair, node2.nodeParams.peerConnectionConf, node2.switchboard, node2.router), s"peer-connection-${Random.nextLong()}") + + transport1.setAutoPilot { (_: ActorRef, msg: Any) => + msg match { + case _: TransportHandler.Listener => TestActor.KeepRunning + case _: TransportHandler.ReadAck => TestActor.KeepRunning + case _ => + peerConnection2.tell(msg, transport2.ref) + TestActor.KeepRunning + } + } + + transport2.setAutoPilot { (_: ActorRef, msg: Any) => + msg match { + case _: TransportHandler.Listener => TestActor.KeepRunning + case _: TransportHandler.ReadAck => TestActor.KeepRunning + case _ => + peerConnection1.tell(msg, transport1.ref) + TestActor.KeepRunning + } + } + + val pendingAuth1 = PeerConnection.PendingAuth(connection1.ref, Some(node2.nodeParams.nodeId), IPAddress(InetAddress.getLoopbackAddress, 65432), origin_opt = Some(sender.ref), transport_opt = Some(transport1.ref), isPersistent = false) + peerConnection1 ! pendingAuth1 + + val pendingAuth2 = PeerConnection.PendingAuth(connection2.ref, None, IPAddress(InetAddress.getLoopbackAddress, 65432), origin_opt = None, transport_opt = Some(transport2.ref), isPersistent = false) + peerConnection2 ! pendingAuth2 + + peerConnection1 ! TransportHandler.HandshakeCompleted(node2.nodeParams.nodeId) + peerConnection2 ! TransportHandler.HandshakeCompleted(node1.nodeParams.nodeId) + + sender.expectMsgType[ConnectionResult.Connected] + } + + def openChannel(node1: MinimalNodeFixture, node2: MinimalNodeFixture, funding: Satoshi)(implicit system: ActorSystem): ChannelOpened = { + val sender = TestProbe("sender") + sender.send(node1.switchboard, Peer.OpenChannel(node2.nodeParams.nodeId, funding, 0L msat, None, None, None, None)) + sender.expectMsgType[ChannelOpened] + } + + def fundingTx(node: MinimalNodeFixture, channelId: ByteVector32)(implicit system: ActorSystem): Transaction = { + val fundingTxid = getChannelData(node, channelId).asInstanceOf[PersistentChannelData].commitments.commitInput.outPoint.txid + node.wallet.funded(fundingTxid) + } + + def confirmChannel(node1: MinimalNodeFixture, node2: MinimalNodeFixture, channelId: ByteVector32, blockHeight: BlockHeight, txIndex: Int)(implicit system: ActorSystem): ShortChannelId = { + assert(getChannelState(node1, channelId) === WAIT_FOR_FUNDING_CONFIRMED) + val data1Before = getChannelData(node1, channelId).asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED] + val fundingTx = data1Before.fundingTx.get + + val watch1 = node1.watcher.fishForMessage() { case w: WatchFundingConfirmed if w.txId == fundingTx.txid => true; case _ => false }.asInstanceOf[WatchFundingConfirmed] + val watch2 = node2.watcher.fishForMessage() { case w: WatchFundingConfirmed if w.txId == fundingTx.txid => true; case _ => false }.asInstanceOf[WatchFundingConfirmed] + + watch1.replyTo ! WatchFundingConfirmedTriggered(blockHeight, txIndex, fundingTx) + watch2.replyTo ! WatchFundingConfirmedTriggered(blockHeight, txIndex, fundingTx) + + waitReady(node1, channelId) + waitReady(node2, channelId) + + val data1After = getChannelData(node1, channelId).asInstanceOf[DATA_NORMAL] + val data2After = getChannelData(node2, channelId).asInstanceOf[DATA_NORMAL] + assert(data1After.shortChannelId == data2After.shortChannelId) + assert(!data1After.buried && !data2After.buried) + + data1After.shortChannelId + } + + def confirmChannelDeep(node1: MinimalNodeFixture, node2: MinimalNodeFixture, channelId: ByteVector32, blockHeight: BlockHeight, txIndex: Int)(implicit system: ActorSystem): ShortChannelId = { + assert(getChannelState(node1, channelId) == NORMAL) + val data1Before = getChannelData(node1, channelId).asInstanceOf[DATA_NORMAL] + val fundingTxid = data1Before.commitments.commitInput.outPoint.txid + val fundingTx = node1.wallet.funded(fundingTxid) + + val watch1 = node1.watcher.fishForMessage() { case w: WatchFundingDeeplyBuried if w.txId == fundingTx.txid => true; case _ => false }.asInstanceOf[WatchFundingDeeplyBuried] + val watch2 = node2.watcher.fishForMessage() { case w: WatchFundingDeeplyBuried if w.txId == fundingTx.txid => true; case _ => false }.asInstanceOf[WatchFundingDeeplyBuried] + + watch1.replyTo ! WatchFundingDeeplyBuriedTriggered(blockHeight, txIndex, fundingTx) + watch2.replyTo ! WatchFundingDeeplyBuriedTriggered(blockHeight, txIndex, fundingTx) + + waitReady(node1, channelId) + waitReady(node2, channelId) + + val data1After = getChannelData(node1, channelId).asInstanceOf[DATA_NORMAL] + val data2After = getChannelData(node2, channelId).asInstanceOf[DATA_NORMAL] + assert(data1After.shortChannelId == data2After.shortChannelId) + assert(data1After.buried && data2After.buried) + + data1After.shortChannelId + } + + /** Utility method to make sure that the channel has processed all previous messages */ + def waitReady(node: MinimalNodeFixture, channelId: ByteVector32)(implicit system: ActorSystem): Unit = { + getChannelState(node, channelId) + } + + def getChannelState(node: MinimalNodeFixture, channelId: ByteVector32)(implicit system: ActorSystem): ChannelState = { + val sender = TestProbe("sender") + node.register ! Register.Forward(sender.ref, channelId, CMD_GET_CHANNEL_STATE(sender.ref)) + sender.expectMsgType[RES_GET_CHANNEL_STATE].state + } + + def getChannelData(node: MinimalNodeFixture, channelId: ByteVector32)(implicit system: ActorSystem): ChannelData = { + val sender = TestProbe("sender") + node.register ! Register.Forward(sender.ref, channelId, CMD_GET_CHANNEL_DATA(sender.ref)) + sender.expectMsgType[RES_GET_CHANNEL_DATA[ChannelData]].data + } + + def getRouterData(node: MinimalNodeFixture)(implicit system: ActorSystem): Router.Data = { + val sender = TestProbe("sender") + sender.send(node.router, Router.GetRouterData) + sender.expectMsgType[Router.Data] + } + + private def deterministicShortId(txId: ByteVector32): (BlockHeight, Int) = { + val blockHeight = txId.take(3).toInt(signed = false) + val txIndex = txId.takeRight(2).toInt(signed = false) + (BlockHeight(blockHeight), txIndex) + } + + /** */ + def autoConfirmLocalChannels(fundingTxs: collection.concurrent.Map[ByteVector32, Transaction]): TestActor.AutoPilot = (_, msg) => msg match { + case watch: ZmqWatcher.WatchFundingConfirmed => + val (blockHeight, txIndex) = deterministicShortId(watch.txId) + watch.replyTo ! ZmqWatcher.WatchFundingConfirmedTriggered(blockHeight, txIndex, fundingTxs(watch.txId)) + TestActor.KeepRunning + case watch: ZmqWatcher.WatchFundingDeeplyBuried => + val (blockHeight, txIndex) = deterministicShortId(watch.txId) + watch.replyTo ! ZmqWatcher.WatchFundingDeeplyBuriedTriggered(blockHeight, txIndex, fundingTxs(watch.txId)) + TestActor.KeepRunning + case _ => TestActor.KeepRunning + } + + /** An autopilot method for the watcher, that handles channel validation requests from the router */ + def autoValidatePublicChannels(fundingTxs: Map[ShortChannelId, Transaction]): TestActor.AutoPilot = (_, msg: Any) => msg match { + case vr: ZmqWatcher.ValidateRequest => + val res = Try(fundingTxs(vr.ann.shortChannelId), ZmqWatcher.UtxoStatus.Unspent).toEither + vr.replyTo ! ZmqWatcher.ValidateResult(vr.ann, res) + TestActor.KeepRunning + case _ => TestActor.KeepRunning + } + + def sendPayment(node1: MinimalNodeFixture, node2: MinimalNodeFixture, amount: MilliSatoshi)(implicit system: ActorSystem): PaymentSent = { + val sender = TestProbe("sender") + sender.send(node2.paymentHandler, MultiPartHandler.ReceivePayment(Some(amount), Left("test payment"))) + val invoice = sender.expectMsgType[Bolt11Invoice] + + val routeParams = node1.nodeParams.routerConf.pathFindingExperimentConf.experiments.values.head.getDefaultRouteParams + sender.send(node1.paymentInitiator, PaymentInitiator.SendPaymentToNode(amount, invoice, maxAttempts = 1, routeParams = routeParams, blockUntilComplete = true)) + sender.expectMsgType[PaymentSent] + } + + def prettyPrint(routerData: Router.Data, nodes: MinimalNodeFixture*): Unit = { + val nodeId2Alias = nodes.map(n => n.nodeParams.nodeId -> n.nodeParams.alias).toMap + .withDefault(nodeId => throw new RuntimeException(s"cannot resolve nodeId=$nodeId, make sure you have provided all node fixtures")) + routerData.channels.values.foreach { channel => + val name = Seq(channel.nodeId1, channel.nodeId2).map(nodeId2Alias).sorted.mkString("-") + val u1 = channel.update_1_opt.map(_ => s"${nodeId2Alias(channel.nodeId1)}=yes").getOrElse(s"${nodeId2Alias(channel.nodeId1)}=no") + val u2 = channel.update_2_opt.map(_ => s"${nodeId2Alias(channel.nodeId2)}=yes").getOrElse(s"${nodeId2Alias(channel.nodeId2)}=no") + println(s"$name : $u1 $u2") + } + } + +} \ No newline at end of file diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/ThreeNodesFixture.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/ThreeNodesFixture.scala new file mode 100644 index 0000000000..e367f62455 --- /dev/null +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/ThreeNodesFixture.scala @@ -0,0 +1,31 @@ +package fr.acinq.eclair.integration.basic.fixtures + +import akka.actor.ActorSystem +import akka.testkit.TestKit +import fr.acinq.eclair.NodeParams + + +case class ThreeNodesFixture(system: ActorSystem, + alice: MinimalNodeFixture, + bob: MinimalNodeFixture, + charlie: MinimalNodeFixture) { + implicit val implicitSystem: ActorSystem = system + + def cleanup(): Unit = { + TestKit.shutdownActorSystem(alice.system) + TestKit.shutdownActorSystem(bob.system) + TestKit.shutdownActorSystem(charlie.system) + TestKit.shutdownActorSystem(system) + } +} + +object ThreeNodesFixture { + def apply(aliceParams: NodeParams, bobParams: NodeParams, charlieParams: NodeParams): ThreeNodesFixture = { + ThreeNodesFixture( + system = ActorSystem("system-test"), + alice = MinimalNodeFixture(aliceParams), + bob = MinimalNodeFixture(bobParams), + charlie = MinimalNodeFixture(charlieParams), + ) + } +} \ No newline at end of file diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/TwoNodesFixture.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/TwoNodesFixture.scala new file mode 100644 index 0000000000..4e9bc88287 --- /dev/null +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/TwoNodesFixture.scala @@ -0,0 +1,27 @@ +package fr.acinq.eclair.integration.basic.fixtures + +import akka.actor.ActorSystem +import akka.testkit.TestKit +import fr.acinq.eclair.NodeParams + +case class TwoNodesFixture(system: ActorSystem, + alice: MinimalNodeFixture, + bob: MinimalNodeFixture) { + implicit val implicitSystem: ActorSystem = system + + def cleanup(): Unit = { + TestKit.shutdownActorSystem(alice.system) + TestKit.shutdownActorSystem(bob.system) + TestKit.shutdownActorSystem(system) + } +} + +object TwoNodesFixture { + def apply(aliceParams: NodeParams, bobParams: NodeParams): TwoNodesFixture = { + TwoNodesFixture( + system = ActorSystem("system-test"), + alice = MinimalNodeFixture(aliceParams), + bob = MinimalNodeFixture(bobParams) + ) + } +} diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/testutils/FixtureSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/testutils/FixtureSpec.scala new file mode 100644 index 0000000000..fe140a43c9 --- /dev/null +++ b/eclair-core/src/test/scala/fr/acinq/eclair/testutils/FixtureSpec.scala @@ -0,0 +1,82 @@ +/* + * Copyright 2022 ACINQ SAS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package fr.acinq.eclair.testutils + +import org.scalatest.concurrent.Eventually +import org.scalatest.funsuite.FixtureAnyFunSuite +import org.scalatest.{Assertions, Outcome, TestData} + +/** + * This is an opinionated base class for tests that need a fixture. It is a very thin layer on top of Scalatest, which + * follows the recommended way of using fixtures, and hides boiler plate code. + * + * Usage: + * {{{ + * class MyTestSpec extends FixtureSpec { + * + * type FixtureParam = MyFixtureClass + * + * override def createFixture(testData: TestData): MyFixtureClass = { + * // will be run for each test + * // build the fixture here + * // customize with testData.tags if appropriate + * ... + * } + * + * override def cleanupFixture(fixture: MyFixtureClass): Unit = { + * fixture.cleanup() // it is a good practice to define a cleanup method in your fixture case class + * } + * + * test("my first test") { f => + * import f._ + * // write your test here + * ... + * } + * } + * }}} + * + * Recommendations: + * - on test parallelization: + * - do not use [[org.scalatest.ParallelTestExecution]], parallelize on test suites instead + * - keep the execution time of each suite under one minute + * - on actor testing: + * - use a normal [[akka.actor.ActorSystem]] and real actors, use [[akka.testkit.TestProbe]] to communicate with them + * - do not use [[akka.testkit.TestKit]] class + * - do not use [[akka.testkit.TestActorRef]] + * + * References: + * - https://hseeberger.github.io/2017/09/13/2017-09-13-how-to-use-akka-testkit/ + * - https://markuseliasson.se/article/scalatest-best-practices/ + */ +abstract class FixtureSpec extends FixtureAnyFunSuite + with Assertions + with Eventually { + + def createFixture(testData: TestData): FixtureParam + + def cleanupFixture(fixture: FixtureParam): Unit + + override final def withFixture(test: OneArgTest): Outcome = { + val fixture = createFixture(test) + try { + withFixture(test.toNoArgTest(fixture)) + } finally { + cleanupFixture(fixture) + } + } + +} From 3ef4f447b669d9bdca430374cdabb7008a4ed93e Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 27 May 2022 19:10:36 +0200 Subject: [PATCH 04/15] adapt WaitForOpenChannelStateSpec to new fixture --- .../channel/states/ChannelStateFixture.scala | 127 ++++++++++++++++++ .../a/WaitForOpenChannelStateSpec.scala | 92 ++++++------- 2 files changed, 171 insertions(+), 48 deletions(-) create mode 100644 eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateFixture.scala diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateFixture.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateFixture.scala new file mode 100644 index 0000000000..b623e4a203 --- /dev/null +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateFixture.scala @@ -0,0 +1,127 @@ +package fr.acinq.eclair.channel.states + +import akka.actor.ActorSystem +import akka.actor.typed.scaladsl.adapter.actorRefAdapter +import akka.testkit.{TestFSMRef, TestKit, TestProbe} +import com.softwaremill.quicklens.ModifyPimp +import fr.acinq.bitcoin.scalacompat.SatoshiLong +import fr.acinq.eclair.TestConstants.{Alice, Bob} +import fr.acinq.eclair.blockchain.{DummyOnChainWallet, OnChainWallet} +import fr.acinq.eclair.channel.fsm.Channel +import fr.acinq.eclair.channel.states.ChannelStateTestsHelperMethods.FakeTxPublisherFactory +import fr.acinq.eclair.channel.{ChannelData, ChannelState, ChannelTypes, Helpers, LocalChannelDown, LocalChannelUpdate, LocalParams, SupportedChannelType} +import fr.acinq.eclair.{BlockHeight, FeatureSupport, Features, NodeParams, TestConstants, TestUtils, UInt64} + +case class ChannelStateFixture(system: ActorSystem, + alice: TestFSMRef[ChannelState, ChannelData, Channel], + bob: TestFSMRef[ChannelState, ChannelData, Channel], + aliceOrigin: TestProbe, + alice2bob: TestProbe, + bob2alice: TestProbe, + alice2blockchain: TestProbe, + bob2blockchain: TestProbe, + router: TestProbe, + alice2relayer: TestProbe, + bob2relayer: TestProbe, + channelUpdateListener: TestProbe, + wallet: OnChainWallet, + alicePeer: TestProbe, + bobPeer: TestProbe) { + implicit val implicitSystem: ActorSystem = system + + def currentBlockHeight: BlockHeight = alice.underlyingActor.nodeParams.currentBlockHeight + + def cleanup(): Unit = { + TestKit.shutdownActorSystem(alice.underlyingActor.context.system) + TestKit.shutdownActorSystem(bob.underlyingActor.context.system) + TestKit.shutdownActorSystem(system) + } +} + +object ChannelStateFixture { + + def apply(nodeParamsA: NodeParams = TestConstants.Alice.nodeParams, nodeParamsB: NodeParams = TestConstants.Bob.nodeParams, wallet: OnChainWallet = new DummyOnChainWallet(), tags: Set[String] = Set.empty): ChannelStateFixture = { + implicit val system: ActorSystem = ActorSystem("system") + val aliceOrigin = TestProbe() + val alice2bob = TestProbe() + val bob2alice = TestProbe() + val alicePeer = TestProbe() + val bobPeer = TestProbe() + TestUtils.forwardOutgoingToPipe(alicePeer, alice2bob.ref) + TestUtils.forwardOutgoingToPipe(bobPeer, bob2alice.ref) + val alice2blockchain = TestProbe() + val bob2blockchain = TestProbe() + val alice2relayer = TestProbe() + val bob2relayer = TestProbe() + val channelUpdateListener = TestProbe() + val systemA: ActorSystem = ActorSystem("system-alice") + val systemB: ActorSystem = ActorSystem("system-bob") + systemA.eventStream.subscribe(channelUpdateListener.ref, classOf[LocalChannelUpdate]) + systemA.eventStream.subscribe(channelUpdateListener.ref, classOf[LocalChannelDown]) + systemB.eventStream.subscribe(channelUpdateListener.ref, classOf[LocalChannelUpdate]) + systemB.eventStream.subscribe(channelUpdateListener.ref, classOf[LocalChannelDown]) + val router = TestProbe() + val finalNodeParamsA = nodeParamsA + .modify(_.channelConf.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(5000 sat) + .modify(_.channelConf.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(1000 sat) + .modify(_.channelConf.maxRemoteDustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(10000 sat) + .modify(_.channelConf.maxRemoteDustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(10000 sat) + val finalNodeParamsB = nodeParamsB + .modify(_.channelConf.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(1000 sat) + .modify(_.channelConf.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(5000 sat) + .modify(_.channelConf.maxRemoteDustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(10000 sat) + .modify(_.channelConf.maxRemoteDustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(10000 sat) + val alice: TestFSMRef[ChannelState, ChannelData, Channel] = { + implicit val system: ActorSystem = systemA + TestFSMRef(new Channel(finalNodeParamsA, wallet, finalNodeParamsB.nodeId, alice2blockchain.ref, alice2relayer.ref, FakeTxPublisherFactory(alice2blockchain), origin_opt = Some(aliceOrigin.ref)), alicePeer.ref) + } + val bob: TestFSMRef[ChannelState, ChannelData, Channel] = { + implicit val system: ActorSystem = systemB + TestFSMRef(new Channel(finalNodeParamsB, wallet, finalNodeParamsA.nodeId, bob2blockchain.ref, bob2relayer.ref, FakeTxPublisherFactory(bob2blockchain)), bobPeer.ref) + } + ChannelStateFixture(system, alice, bob, aliceOrigin, alice2bob, bob2alice, alice2blockchain, bob2blockchain, router, alice2relayer, bob2relayer, channelUpdateListener, wallet, alicePeer, bobPeer) + } + + def computeFeatures(setup: ChannelStateFixture, tags: Set[String]): (LocalParams, LocalParams, SupportedChannelType) = { + import setup._ + + val aliceInitFeatures = Alice.nodeParams.features + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.Wumbo))(_.updated(Features.Wumbo, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.StaticRemoteKey))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.AnchorOutputs))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional).updated(Features.AnchorOutputs, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional).updated(Features.AnchorOutputs, FeatureSupport.Optional).updated(Features.AnchorOutputsZeroFeeHtlcTx, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.ShutdownAnySegwit))(_.updated(Features.ShutdownAnySegwit, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.OptionUpfrontShutdownScript))(_.updated(Features.UpfrontShutdownScript, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.ChannelType))(_.updated(Features.ChannelType, FeatureSupport.Optional)) + .initFeatures() + val bobInitFeatures = Bob.nodeParams.features + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.Wumbo))(_.updated(Features.Wumbo, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.StaticRemoteKey))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.AnchorOutputs))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional).updated(Features.AnchorOutputs, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional).updated(Features.AnchorOutputs, FeatureSupport.Optional).updated(Features.AnchorOutputsZeroFeeHtlcTx, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.ShutdownAnySegwit))(_.updated(Features.ShutdownAnySegwit, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.OptionUpfrontShutdownScript))(_.updated(Features.UpfrontShutdownScript, FeatureSupport.Optional)) + .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.ChannelType))(_.updated(Features.ChannelType, FeatureSupport.Optional)) + .initFeatures() + + val channelType = ChannelTypes.defaultFromFeatures(aliceInitFeatures, bobInitFeatures) + + implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global + val aliceParams = Alice.channelParams + .modify(_.initFeatures).setTo(aliceInitFeatures) + .modify(_.walletStaticPaymentBasepoint).setToIf(channelType.paysDirectlyToWallet)(Some(Helpers.getWalletPaymentBasepoint(wallet))) + .modify(_.maxHtlcValueInFlightMsat).setToIf(tags.contains(ChannelStateTestsTags.NoMaxHtlcValueInFlight))(UInt64.MaxValue) + .modify(_.maxHtlcValueInFlightMsat).setToIf(tags.contains(ChannelStateTestsTags.AliceLowMaxHtlcValueInFlight))(UInt64(150000000)) + .modify(_.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(5000 sat) + .modify(_.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(1000 sat) + val bobParams = Bob.channelParams + .modify(_.initFeatures).setTo(bobInitFeatures) + .modify(_.walletStaticPaymentBasepoint).setToIf(channelType.paysDirectlyToWallet)(Some(Helpers.getWalletPaymentBasepoint(wallet))) + .modify(_.maxHtlcValueInFlightMsat).setToIf(tags.contains(ChannelStateTestsTags.NoMaxHtlcValueInFlight))(UInt64.MaxValue) + .modify(_.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(1000 sat) + .modify(_.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(5000 sat) + + (aliceParams, bobParams, channelType) + } + +} diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala index 84ea97e2ce..0ec5b8916d 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala @@ -16,53 +16,50 @@ package fr.acinq.eclair.channel.states.a -import akka.testkit.{TestFSMRef, TestProbe} +import akka.testkit.TestProbe +import com.softwaremill.quicklens.ModifyPimp import fr.acinq.bitcoin.scalacompat.{Block, Btc, ByteVector32, SatoshiLong} import fr.acinq.eclair.TestConstants.{Alice, Bob} import fr.acinq.eclair.blockchain.fee.FeeratePerKw import fr.acinq.eclair.channel._ import fr.acinq.eclair.channel.fsm.Channel -import fr.acinq.eclair.channel.states.{ChannelStateTestsBase, ChannelStateTestsTags} +import fr.acinq.eclair.channel.states.ChannelStateFixture.computeFeatures +import fr.acinq.eclair.channel.states.{ChannelStateFixture, ChannelStateTestsTags} +import fr.acinq.eclair.testutils.FixtureSpec import fr.acinq.eclair.wire.protocol.{AcceptChannel, ChannelTlv, Error, Init, OpenChannel, TlvStream} -import fr.acinq.eclair.{CltvExpiryDelta, MilliSatoshiLong, TestConstants, TestKitBaseClass, ToMilliSatoshiConversion} -import org.scalatest.funsuite.FixtureAnyFunSuiteLike -import org.scalatest.{Outcome, Tag} +import fr.acinq.eclair.{CltvExpiryDelta, MilliSatoshiLong, TestConstants, ToMilliSatoshiConversion} +import org.scalatest.{Tag, TestData} import scodec.bits.ByteVector -import scala.concurrent.duration._ - /** * Created by PM on 05/07/2016. */ -class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with ChannelStateTestsBase { - - case class FixtureParam(alice: TestFSMRef[ChannelState, ChannelData, Channel], bob: TestFSMRef[ChannelState, ChannelData, Channel], alice2bob: TestProbe, bob2alice: TestProbe, bob2blockchain: TestProbe) - - override def withFixture(test: OneArgTest): Outcome = { +class WaitForOpenChannelStateSpec extends FixtureSpec { - import com.softwaremill.quicklens._ + type FixtureParam = ChannelStateFixture + override def createFixture(testData: TestData): ChannelStateFixture = { val bobNodeParams = Bob.nodeParams - .modify(_.channelConf.maxFundingSatoshis).setToIf(test.tags.contains("max-funding-satoshis"))(Btc(1)) + .modify(_.channelConf.maxFundingSatoshis).setToIf(testData.tags.contains("max-funding-satoshis"))(Btc(1)) - val setup = init(nodeParamsB = bobNodeParams) + val fixture = ChannelStateFixture(nodeParamsB = bobNodeParams) - import setup._ + import fixture._ val channelConfig = ChannelConfig.standard - val (aliceParams, bobParams, defaultChannelType) = computeFeatures(setup, test.tags) - val channelType = if (test.tags.contains("standard-channel-type")) ChannelTypes.Standard else defaultChannelType + val (aliceParams, bobParams, defaultChannelType) = computeFeatures(fixture, testData.tags) + val channelType = if (testData.tags.contains("standard-channel-type")) ChannelTypes.Standard else defaultChannelType val commitTxFeerate = if (channelType == ChannelTypes.AnchorOutputs || channelType == ChannelTypes.AnchorOutputsZeroFeeHtlcTx) TestConstants.anchorOutputsFeeratePerKw else TestConstants.feeratePerKw val aliceInit = Init(aliceParams.initFeatures) val bobInit = Init(bobParams.initFeatures) - within(30 seconds) { - alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, commitTxFeerate, TestConstants.feeratePerKw, aliceParams, alice2bob.ref, bobInit, ChannelFlags.Private, channelConfig, channelType) - bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, aliceInit, channelConfig, channelType) - awaitCond(bob.stateName == WAIT_FOR_OPEN_CHANNEL) - withFixture(test.toNoArgTest(FixtureParam(alice, bob, alice2bob, bob2alice, bob2blockchain))) - } + alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, commitTxFeerate, TestConstants.feeratePerKw, aliceParams, alice2bob.ref, bobInit, ChannelFlags.Private, channelConfig, channelType) + bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, aliceInit, channelConfig, channelType) + eventually(bob.stateName == WAIT_FOR_OPEN_CHANNEL) + fixture } + override def cleanupFixture(fixture: ChannelStateFixture): Unit = fixture.cleanup() + test("recv OpenChannel") { f => import f._ val open = alice2bob.expectMsgType[OpenChannel] @@ -71,7 +68,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui // We always send a channel type, even for standard channels. assert(open.channelType_opt === Some(ChannelTypes.Standard)) alice2bob.forward(bob) - awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) + eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.Standard) } @@ -80,7 +77,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val open = alice2bob.expectMsgType[OpenChannel] assert(open.channelType_opt === Some(ChannelTypes.AnchorOutputs)) alice2bob.forward(bob) - awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) + eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.AnchorOutputs) } @@ -89,7 +86,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val open = alice2bob.expectMsgType[OpenChannel] assert(open.channelType_opt === Some(ChannelTypes.AnchorOutputsZeroFeeHtlcTx)) alice2bob.forward(bob) - awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) + eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.AnchorOutputsZeroFeeHtlcTx) } @@ -98,7 +95,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val open = alice2bob.expectMsgType[OpenChannel] assert(open.channelType_opt === Some(ChannelTypes.Standard)) alice2bob.forward(bob) - awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) + eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.Standard) } @@ -110,7 +107,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(chainHash = livenetChainHash) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidChainHash(open.temporaryChannelId, Block.RegtestGenesisBlock.hash, livenetChainHash).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (funding too low, public channel)") { f => @@ -121,7 +118,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(fundingSatoshis = lowFunding, channelFlags = ChannelFlags(announceChannel)) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, lowFunding, Bob.nodeParams.channelConf.minFundingSatoshis(announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (funding too low, private channel)") { f => @@ -132,7 +129,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(fundingSatoshis = lowFunding, channelFlags = ChannelFlags(announceChannel)) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, lowFunding, Bob.nodeParams.channelConf.minFundingSatoshis(announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (funding over channel limit)") { f => @@ -142,7 +139,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(fundingSatoshis = highFundingMsat) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, highFundingMsat, Bob.nodeParams.channelConf.minFundingSatoshis(open.channelFlags.announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (fundingSatoshis > max-funding-satoshis)", Tag(ChannelStateTestsTags.Wumbo)) { f => @@ -161,7 +158,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(maxAcceptedHtlcs = invalidMaxAcceptedHtlcs) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidMaxAcceptedHtlcs(open.temporaryChannelId, invalidMaxAcceptedHtlcs, Channel.MAX_ACCEPTED_HTLCS).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (invalid push_msat)") { f => @@ -171,7 +168,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(pushMsat = invalidPushMsat) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidPushAmount(open.temporaryChannelId, invalidPushMsat, open.fundingSatoshis.toMilliSatoshi).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (to_self_delay too high)") { f => @@ -181,7 +178,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(toSelfDelay = delayTooHigh) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, ToSelfDelayTooHigh(open.temporaryChannelId, delayTooHigh, Alice.nodeParams.channelConf.maxToLocalDelay).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (reserve too high)") { f => @@ -192,7 +189,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(channelReserveSatoshis = reserveTooHigh) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, ChannelReserveTooHigh(open.temporaryChannelId, reserveTooHigh, 0.3, 0.05).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (fee too low, but still valid)") { f => @@ -204,7 +201,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id assert(error === Error(open.temporaryChannelId, "local/remote feerates are too different: remoteFeeratePerKw=253 localFeeratePerKw=10000")) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (fee below absolute valid minimum)") { f => @@ -216,7 +213,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id assert(error === Error(open.temporaryChannelId, "remote fee rate is too small: remoteFeeratePerKw=252")) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (reserve below dust)") { f => @@ -227,7 +224,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id assert(error === Error(open.temporaryChannelId, DustLimitTooLarge(open.temporaryChannelId, open.dustLimitSatoshis, reserveTooSmall).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (dust limit too high)") { f => @@ -237,7 +234,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(dustLimitSatoshis = dustLimitTooHigh) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, DustLimitTooLarge(open.temporaryChannelId, dustLimitTooHigh, Bob.nodeParams.channelConf.maxRemoteDustLimit).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (toLocal + toRemote below reserve)") { f => @@ -249,7 +246,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id assert(error === Error(open.temporaryChannelId, ChannelReserveNotMet(open.temporaryChannelId, pushMsat, (open.channelReserveSatoshis - 1.sat).toMilliSatoshi, open.channelReserveSatoshis).getMessage)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv OpenChannel (wumbo size)", Tag(ChannelStateTestsTags.Wumbo), Tag("max-funding-satoshis")) { f => @@ -258,7 +255,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val highFundingSat = Btc(1).toSatoshi bob ! open.copy(fundingSatoshis = highFundingSat) bob2alice.expectMsgType[AcceptChannel] - awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) + eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) } test("recv OpenChannel (upfront shutdown script)", Tag(ChannelStateTestsTags.OptionUpfrontShutdownScript)) { f => @@ -266,7 +263,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val open = alice2bob.expectMsgType[OpenChannel] assert(open.upfrontShutdownScript_opt.contains(alice.stateData.asInstanceOf[DATA_WAIT_FOR_ACCEPT_CHANNEL].initFunder.localParams.defaultFinalScriptPubKey)) alice2bob.forward(bob, open) - awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) + eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].remoteParams.shutdownScript == open.upfrontShutdownScript_opt) } @@ -275,7 +272,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val open = alice2bob.expectMsgType[OpenChannel] val open1 = open.copy(tlvStream = TlvStream(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.empty))) alice2bob.forward(bob, open1) - awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) + eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].remoteParams.shutdownScript.isEmpty) } @@ -284,13 +281,13 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val open = alice2bob.expectMsgType[OpenChannel] val open1 = open.copy(tlvStream = TlvStream(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.fromValidHex("deadbeef")))) alice2bob.forward(bob, open1) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv Error") { f => import f._ bob ! Error(ByteVector32.Zeroes, "oops") - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } test("recv CMD_CLOSE") { f => @@ -299,7 +296,6 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val c = CMD_CLOSE(sender.ref, None, None) bob ! c sender.expectMsg(RES_SUCCESS(c, ByteVector32.Zeroes)) - awaitCond(bob.stateName == CLOSED) + eventually(bob.stateName == CLOSED) } - } From 2632be328c8d4bd6ffe92b4c5571faf8acfa2cbd Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 27 May 2022 11:15:08 +0200 Subject: [PATCH 05/15] fix race condition in peerconnection --- .../main/scala/fr/acinq/eclair/io/PeerConnection.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala b/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala index e437604647..71e5cad58c 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala @@ -95,6 +95,11 @@ class PeerConnection(keyPair: KeyPair, conf: PeerConnection.Conf, switchboard: A log.warning(s"authentication timed out after ${conf.authTimeout}") d.pendingAuth.origin_opt.foreach(_ ! ConnectionResult.AuthenticationFailed("authentication timed out")) stop(FSM.Normal) + + case Event(remoteInit: protocol.Init, _) => + log.debug("delaying remote init") + context.system.scheduler.scheduleOnce(100 millis, self, remoteInit)(context.dispatcher) + stay() } when(BEFORE_INIT) { @@ -109,6 +114,11 @@ class PeerConnection(keyPair: KeyPair, conf: PeerConnection.Conf, switchboard: A d.transport ! localInit startSingleTimer(INIT_TIMER, InitTimeout, conf.initTimeout) goto(INITIALIZING) using InitializingData(chainHash, d.pendingAuth, d.remoteNodeId, d.transport, peer, localInit, doSync, d.isPersistent) + + case Event(remoteInit: protocol.Init, _) => + log.debug("delaying remote init") + context.system.scheduler.scheduleOnce(100 millis, self, remoteInit)(context.dispatcher) + stay() } when(INITIALIZING) { From 293725d5d77fbb5c101b9a99eba9d58d8227852c Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 27 May 2022 15:10:32 +0200 Subject: [PATCH 06/15] human-readable nodeId for alice/bob --- .../src/test/scala/fr/acinq/eclair/TestConstants.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala b/eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala index 7add1eccac..a9f7854cf1 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala @@ -32,7 +32,7 @@ import fr.acinq.eclair.router.PathFindingExperimentConf import fr.acinq.eclair.router.Router.{MultiPartParams, PathFindingConf, RouterConf, SearchBoundaries} import fr.acinq.eclair.wire.protocol.{Color, EncodingType, NodeAddress, OnionRoutingPacket} import org.scalatest.Tag -import scodec.bits.ByteVector +import scodec.bits.{ByteVector, HexStringSyntax} import java.util.UUID import java.util.concurrent.atomic.AtomicLong @@ -71,7 +71,7 @@ object TestConstants { ) object Alice { - val seed: ByteVector32 = ByteVector32(ByteVector.fill(32)(1)) + val seed: ByteVector32 = ByteVector32(hex"b4acd47335b25ab7b84b8c020997b12018592bb4631b868762154d77fa8b93a3") // 02aaaa... val nodeKeyManager = new LocalNodeKeyManager(seed, Block.RegtestGenesisBlock.hash) val channelKeyManager = new LocalChannelKeyManager(seed, Block.RegtestGenesisBlock.hash) @@ -213,7 +213,7 @@ object TestConstants { } object Bob { - val seed: ByteVector32 = ByteVector32(ByteVector.fill(32)(2)) + val seed: ByteVector32 = ByteVector32(hex"7620226fec887b0b2ebe76492e5a3fd3eb0e47cd3773263f6a81b59a704dc492") // 02bbbb... val nodeKeyManager = new LocalNodeKeyManager(seed, Block.RegtestGenesisBlock.hash) val channelKeyManager = new LocalChannelKeyManager(seed, Block.RegtestGenesisBlock.hash) From f1755708c4d2634c9afa486e7748dff869a56d25 Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 27 May 2022 15:11:53 +0200 Subject: [PATCH 07/15] fix sqlite db roundtrip check --- eclair-core/src/test/scala/fr/acinq/eclair/TestDatabases.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/TestDatabases.scala b/eclair-core/src/test/scala/fr/acinq/eclair/TestDatabases.scala index 7b813fee70..2930d4c07a 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/TestDatabases.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/TestDatabases.scala @@ -60,8 +60,9 @@ object TestDatabases { def freeze1(input: Origin): Origin = input match { case h: Origin.LocalHot => Origin.LocalCold(h.id) + case h: Origin.ChannelRelayedHot => Origin.ChannelRelayedCold(h.originChannelId, h.originHtlcId, h.amountIn, h.amountOut) case h: Origin.TrampolineRelayedHot => Origin.TrampolineRelayedCold(h.htlcs) - case _ => input + case c: Origin.Cold => c } def freeze2(input: Commitments): Commitments = input.copy(originChannels = input.originChannels.view.mapValues(o => freeze1(o)).toMap) From 2e6e566ccc0dbaa49ed9678634b33df0d97f216a Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 27 May 2022 16:54:25 +0200 Subject: [PATCH 08/15] use eclair default params in integration tests --- .../basic/ThreeNodesIntegrationSpec.scala | 30 ++++--------------- .../basic/TwoNodesIntegrationSpec.scala | 12 ++++---- .../basic/fixtures/MinimalNodeFixture.scala | 28 +++++++++++++++-- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala index ddc5dfc10f..68ce34a2c3 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala @@ -1,18 +1,14 @@ package fr.acinq.eclair.integration.basic -import com.softwaremill.quicklens.ModifyPimp -import fr.acinq.bitcoin.scalacompat.{Block, ByteVector32, SatoshiLong} +import fr.acinq.bitcoin.scalacompat.{ByteVector32, SatoshiLong} import fr.acinq.eclair.ShortChannelId.txIndex -import fr.acinq.eclair.crypto.keymanager.{LocalChannelKeyManager, LocalNodeKeyManager} import fr.acinq.eclair.integration.basic.fixtures.ThreeNodesFixture import fr.acinq.eclair.testutils.FixtureSpec -import fr.acinq.eclair.{BlockHeight, MilliSatoshiLong, TestConstants, TestDatabases} +import fr.acinq.eclair.{BlockHeight, MilliSatoshiLong} import org.scalatest.TestData import org.scalatest.concurrent.IntegrationPatience import scodec.bits.HexStringSyntax -import scala.concurrent.duration.DurationInt - /** * This test checks the integration between Channel and Router (events, etc.) @@ -24,24 +20,10 @@ class ThreeNodesIntegrationSpec extends FixtureSpec with IntegrationPatience { import fr.acinq.eclair.integration.basic.fixtures.MinimalNodeFixture._ override def createFixture(testData: TestData): FixtureParam = { - val aliceParams = TestConstants.Alice.nodeParams - .modify(_.channelConf.dustLimit).setTo(1000 sat) - .modify(_.routerConf.routerBroadcastInterval).setTo(1 second) - .modifyAll(_.relayParams.privateChannelFees.feeBase, _.relayParams.publicChannelFees.feeBase).setTo(1_000 msat) - .modifyAll(_.relayParams.privateChannelFees.feeProportionalMillionths, _.relayParams.publicChannelFees.feeProportionalMillionths).setTo(10) - val bobParams = TestConstants.Bob.nodeParams - .modify(_.routerConf.routerBroadcastInterval).setTo(1 second) - .modifyAll(_.relayParams.privateChannelFees.feeBase, _.relayParams.publicChannelFees.feeBase).setTo(1_000 msat) - .modifyAll(_.relayParams.privateChannelFees.feeProportionalMillionths, _.relayParams.publicChannelFees.feeProportionalMillionths).setTo(10) - - val charlieSeed: ByteVector32 = ByteVector32(hex"ebd5a5d3abfb3ef73731eb3418d918f247445183180522674666db98a66411cc") // 02cccc... - val charlieNodeKeyManager = new LocalNodeKeyManager(charlieSeed, Block.RegtestGenesisBlock.hash) - val charlieChannelKeyManager = new LocalChannelKeyManager(charlieSeed, Block.RegtestGenesisBlock.hash) - val charlieParams = TestConstants.Bob.nodeParams - .modify(_.alias).setTo("charlie") - .modify(_.nodeKeyManager).setTo(charlieNodeKeyManager) - .modify(_.db).setTo(TestDatabases.inMemoryDb()) - .modify(_.channelKeyManager).setTo(charlieChannelKeyManager) + // seeds have been chose so that node ids start with 02aaaa for alice, 02bbbb for bob, etc. + val aliceParams = nodeParamsFor("alice", ByteVector32(hex"b4acd47335b25ab7b84b8c020997b12018592bb4631b868762154d77fa8b93a3")) + val bobParams = nodeParamsFor("bob", ByteVector32(hex"7620226fec887b0b2ebe76492e5a3fd3eb0e47cd3773263f6a81b59a704dc492")) + val charlieParams = nodeParamsFor("charlie", ByteVector32(hex"ebd5a5d3abfb3ef73731eb3418d918f247445183180522674666db98a66411cc")) ThreeNodesFixture(aliceParams, bobParams, charlieParams) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala index bd536bfa60..c32504f2bd 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala @@ -1,13 +1,13 @@ package fr.acinq.eclair.integration.basic -import com.softwaremill.quicklens.ModifyPimp -import fr.acinq.bitcoin.scalacompat.SatoshiLong +import fr.acinq.bitcoin.scalacompat.{ByteVector32, SatoshiLong} import fr.acinq.eclair.channel.{DATA_NORMAL, NORMAL} import fr.acinq.eclair.integration.basic.fixtures.TwoNodesFixture import fr.acinq.eclair.testutils.FixtureSpec -import fr.acinq.eclair.{BlockHeight, MilliSatoshiLong, TestConstants} +import fr.acinq.eclair.{BlockHeight, MilliSatoshiLong} import org.scalatest.TestData import org.scalatest.concurrent.IntegrationPatience +import scodec.bits.HexStringSyntax /** @@ -20,9 +20,9 @@ class TwoNodesIntegrationSpec extends FixtureSpec with IntegrationPatience { import fr.acinq.eclair.integration.basic.fixtures.MinimalNodeFixture._ override def createFixture(testData: TestData): FixtureParam = { - val aliceParams = TestConstants.Alice.nodeParams - .modify(_.channelConf.dustLimit).setTo(1000 sat) - val bobParams = TestConstants.Bob.nodeParams + // seeds have been chose so that node ids start with 02aaaa for alice, 02bbbb for bob, etc. + val aliceParams = nodeParamsFor("alice", ByteVector32(hex"b4acd47335b25ab7b84b8c020997b12018592bb4631b868762154d77fa8b93a3")) + val bobParams = nodeParamsFor("bob", ByteVector32(hex"7620226fec887b0b2ebe76492e5a3fd3eb0e47cd3773263f6a81b59a704dc492")) TwoNodesFixture(aliceParams, bobParams) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala index 72166ff5c2..0ecf153997 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala @@ -3,7 +3,9 @@ package fr.acinq.eclair.integration.basic.fixtures import akka.actor.typed.scaladsl.adapter.ClassicActorRefOps import akka.actor.{ActorRef, ActorSystem, Props} import akka.testkit.{TestActor, TestProbe} -import fr.acinq.bitcoin.scalacompat.{ByteVector32, Satoshi, Transaction} +import com.softwaremill.quicklens.ModifyPimp +import com.typesafe.config.ConfigFactory +import fr.acinq.bitcoin.scalacompat.{Block, ByteVector32, Satoshi, Transaction} import fr.acinq.eclair.blockchain.DummyOnChainWallet import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher.{WatchFundingConfirmed, WatchFundingConfirmedTriggered, WatchFundingDeeplyBuried, WatchFundingDeeplyBuriedTriggered} @@ -11,6 +13,7 @@ import fr.acinq.eclair.channel.ChannelOpenResponse.ChannelOpened import fr.acinq.eclair.channel._ import fr.acinq.eclair.channel.fsm.Channel import fr.acinq.eclair.crypto.TransportHandler +import fr.acinq.eclair.crypto.keymanager.{LocalChannelKeyManager, LocalNodeKeyManager} import fr.acinq.eclair.io.PeerConnection.ConnectionResult import fr.acinq.eclair.io.{Peer, PeerConnection, Switchboard} import fr.acinq.eclair.payment.receive.{MultiPartHandler, PaymentHandler} @@ -19,10 +22,13 @@ import fr.acinq.eclair.payment.send.PaymentInitiator import fr.acinq.eclair.payment.{Bolt11Invoice, PaymentSent} import fr.acinq.eclair.router.Router import fr.acinq.eclair.wire.protocol.IPAddress -import fr.acinq.eclair.{BlockHeight, MilliSatoshi, MilliSatoshiLong, NodeParams, ShortChannelId, TestBitcoinCoreClient} +import fr.acinq.eclair.{BlockHeight, MilliSatoshi, MilliSatoshiLong, NodeParams, ShortChannelId, TestBitcoinCoreClient, TestDatabases, TestFeeEstimator} import org.scalatest.Assertions import java.net.InetAddress +import java.util.UUID +import java.util.concurrent.atomic.AtomicLong +import scala.concurrent.duration.DurationInt import scala.util.{Random, Try} @@ -43,6 +49,24 @@ case class MinimalNodeFixture private(nodeParams: NodeParams, wallet: DummyOnChainWallet) object MinimalNodeFixture extends Assertions { + + def nodeParamsFor(alias: String, seed: ByteVector32): NodeParams = { + NodeParams.makeNodeParams( + config = ConfigFactory.load().getConfig("eclair"), + instanceId = UUID.randomUUID(), + nodeKeyManager = new LocalNodeKeyManager(seed, Block.RegtestGenesisBlock.hash), + channelKeyManager = new LocalChannelKeyManager(seed, Block.RegtestGenesisBlock.hash), + torAddress_opt = None, + database = TestDatabases.inMemoryDb(), + blockHeight = new AtomicLong(400_000), + feeEstimator = new TestFeeEstimator + ) + .modify(_.alias).setTo(alias) + .modify(_.chainHash).setTo(Block.RegtestGenesisBlock.hash) + .modify(_.routerConf.routerBroadcastInterval).setTo(1 second) + .modify(_.peerConnectionConf.maxRebroadcastDelay).setTo(1 second) + } + def apply(nodeParams: NodeParams): MinimalNodeFixture = { implicit val system: ActorSystem = ActorSystem(s"system-${nodeParams.alias}") val bitcoinClient = new TestBitcoinCoreClient() From 3d42e3af8ac872413d89aa8d64ddd01a9d16da55 Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 30 May 2022 12:12:38 +0200 Subject: [PATCH 09/15] address review comments --- .../basic/ThreeNodesIntegrationSpec.scala | 22 +++++++++---------- .../basic/fixtures/MinimalNodeFixture.scala | 5 ++--- .../basic/fixtures/ThreeNodesFixture.scala | 8 +++---- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala index 68ce34a2c3..f6c2eedcc4 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/ThreeNodesIntegrationSpec.scala @@ -20,30 +20,30 @@ class ThreeNodesIntegrationSpec extends FixtureSpec with IntegrationPatience { import fr.acinq.eclair.integration.basic.fixtures.MinimalNodeFixture._ override def createFixture(testData: TestData): FixtureParam = { - // seeds have been chose so that node ids start with 02aaaa for alice, 02bbbb for bob, etc. + // seeds have been chosen so that node ids start with 02aaaa for alice, 02bbbb for bob, etc. val aliceParams = nodeParamsFor("alice", ByteVector32(hex"b4acd47335b25ab7b84b8c020997b12018592bb4631b868762154d77fa8b93a3")) val bobParams = nodeParamsFor("bob", ByteVector32(hex"7620226fec887b0b2ebe76492e5a3fd3eb0e47cd3773263f6a81b59a704dc492")) - val charlieParams = nodeParamsFor("charlie", ByteVector32(hex"ebd5a5d3abfb3ef73731eb3418d918f247445183180522674666db98a66411cc")) - ThreeNodesFixture(aliceParams, bobParams, charlieParams) + val carolParams = nodeParamsFor("carol", ByteVector32(hex"ebd5a5d3abfb3ef73731eb3418d918f247445183180522674666db98a66411cc")) + ThreeNodesFixture(aliceParams, bobParams, carolParams) } override def cleanupFixture(fixture: FixtureParam): Unit = { fixture.cleanup() } - test("connect alice->bob and bob->charlie, pay alice->charlie") { f => + test("connect alice->bob and bob->carol, pay alice->carol") { f => import f._ connect(alice, bob) - connect(bob, charlie) + connect(bob, carol) val channelIdAB = openChannel(alice, bob, 100_000 sat).channelId - val channelIdBC = openChannel(bob, charlie, 100_000 sat).channelId + val channelIdBC = openChannel(bob, carol, 100_000 sat).channelId val fundingTxAB = fundingTx(alice, channelIdAB) val fundingTxBC = fundingTx(bob, channelIdBC) val shortIdAB = confirmChannel(alice, bob, channelIdAB, BlockHeight(420_000), 21) - val shortIdBC = confirmChannel(bob, charlie, channelIdBC, BlockHeight(420_001), 22) + val shortIdBC = confirmChannel(bob, carol, channelIdBC, BlockHeight(420_001), 22) val fundingTxs = Map( shortIdAB -> fundingTxAB, @@ -55,17 +55,17 @@ class ThreeNodesIntegrationSpec extends FixtureSpec with IntegrationPatience { bob.watcher.setAutoPilot(autoValidatePublicChannels(fundingTxs)) confirmChannelDeep(alice, bob, channelIdAB, shortIdAB.blockHeight, txIndex(shortIdAB)) - confirmChannelDeep(bob, charlie, channelIdBC, shortIdBC.blockHeight, txIndex(shortIdBC)) + confirmChannelDeep(bob, carol, channelIdBC, shortIdBC.blockHeight, txIndex(shortIdBC)) - // alice now knows about bob-charlie + // alice now knows about bob-carol eventually { val routerData = getRouterData(alice) - //prettyPrint(routerData, alice, bob, charlie) + //prettyPrint(routerData, alice, bob, carol) assert(routerData.channels.size == 2) // 2 channels assert(routerData.channels.values.flatMap(c => c.update_1_opt.toSeq ++ c.update_2_opt.toSeq).size == 3) // only 3 channel_updates because c->b is disabled (all funds on b) } - sendPayment(alice, charlie, 100_000 msat) + sendPayment(alice, carol, 100_000 msat) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala index 0ecf153997..97d4528a3e 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala @@ -60,8 +60,7 @@ object MinimalNodeFixture extends Assertions { database = TestDatabases.inMemoryDb(), blockHeight = new AtomicLong(400_000), feeEstimator = new TestFeeEstimator - ) - .modify(_.alias).setTo(alias) + ).modify(_.alias).setTo(alias) .modify(_.chainHash).setTo(Block.RegtestGenesisBlock.hash) .modify(_.routerConf.routerBroadcastInterval).setTo(1 second) .modify(_.peerConnectionConf.maxRebroadcastDelay).setTo(1 second) @@ -226,7 +225,7 @@ object MinimalNodeFixture extends Assertions { (BlockHeight(blockHeight), txIndex) } - /** */ + /** An autopilot method for the watcher, that handled funding confirmation requests from the channel */ def autoConfirmLocalChannels(fundingTxs: collection.concurrent.Map[ByteVector32, Transaction]): TestActor.AutoPilot = (_, msg) => msg match { case watch: ZmqWatcher.WatchFundingConfirmed => val (blockHeight, txIndex) = deterministicShortId(watch.txId) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/ThreeNodesFixture.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/ThreeNodesFixture.scala index e367f62455..c2062d168f 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/ThreeNodesFixture.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/ThreeNodesFixture.scala @@ -8,24 +8,24 @@ import fr.acinq.eclair.NodeParams case class ThreeNodesFixture(system: ActorSystem, alice: MinimalNodeFixture, bob: MinimalNodeFixture, - charlie: MinimalNodeFixture) { + carol: MinimalNodeFixture) { implicit val implicitSystem: ActorSystem = system def cleanup(): Unit = { TestKit.shutdownActorSystem(alice.system) TestKit.shutdownActorSystem(bob.system) - TestKit.shutdownActorSystem(charlie.system) + TestKit.shutdownActorSystem(carol.system) TestKit.shutdownActorSystem(system) } } object ThreeNodesFixture { - def apply(aliceParams: NodeParams, bobParams: NodeParams, charlieParams: NodeParams): ThreeNodesFixture = { + def apply(aliceParams: NodeParams, bobParams: NodeParams, carolParams: NodeParams): ThreeNodesFixture = { ThreeNodesFixture( system = ActorSystem("system-test"), alice = MinimalNodeFixture(aliceParams), bob = MinimalNodeFixture(bobParams), - charlie = MinimalNodeFixture(charlieParams), + carol = MinimalNodeFixture(carolParams), ) } } \ No newline at end of file From 3376a930fcaeee8453075c76ba2027375acb0aa4 Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 30 May 2022 14:20:24 +0200 Subject: [PATCH 10/15] fixup! fix race condition in peerconnection --- .../fr/acinq/eclair/io/PeerConnection.scala | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala b/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala index 71e5cad58c..ab3f605921 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala @@ -16,7 +16,7 @@ package fr.acinq.eclair.io -import akka.actor.{ActorRef, FSM, OneForOneStrategy, PoisonPill, Props, SupervisorStrategy, Terminated} +import akka.actor.{ActorRef, FSM, OneForOneStrategy, PoisonPill, Props, Stash, SupervisorStrategy, Terminated} import akka.event.Logging.MDC import fr.acinq.bitcoin.scalacompat.ByteVector32 import fr.acinq.bitcoin.scalacompat.Crypto.PublicKey @@ -28,7 +28,7 @@ import fr.acinq.eclair.remote.EclairInternalsSerializer.RemoteTypes import fr.acinq.eclair.router.Router._ import fr.acinq.eclair.wire.protocol import fr.acinq.eclair.wire.protocol._ -import fr.acinq.eclair.{FSMDiagnosticActorLogging, Feature, Features, InitFeature, Logs, TimestampMilli, TimestampSecond} +import fr.acinq.eclair.{FSMDiagnosticActorLogging, Features, InitFeature, Logs, TimestampMilli, TimestampSecond} import scodec.Attempt import scodec.bits.ByteVector @@ -56,7 +56,7 @@ import scala.util.Random * * Created by PM on 11/03/2020. */ -class PeerConnection(keyPair: KeyPair, conf: PeerConnection.Conf, switchboard: ActorRef, router: ActorRef) extends FSMDiagnosticActorLogging[PeerConnection.State, PeerConnection.Data] { +class PeerConnection(keyPair: KeyPair, conf: PeerConnection.Conf, switchboard: ActorRef, router: ActorRef) extends FSMDiagnosticActorLogging[PeerConnection.State, PeerConnection.Data] with Stash { import PeerConnection._ @@ -96,9 +96,9 @@ class PeerConnection(keyPair: KeyPair, conf: PeerConnection.Conf, switchboard: A d.pendingAuth.origin_opt.foreach(_ ! ConnectionResult.AuthenticationFailed("authentication timed out")) stop(FSM.Normal) - case Event(remoteInit: protocol.Init, _) => - log.debug("delaying remote init") - context.system.scheduler.scheduleOnce(100 millis, self, remoteInit)(context.dispatcher) + case Event(_: protocol.Init, _) => + log.debug("stashing remote init") + stash() stay() } @@ -113,11 +113,12 @@ class PeerConnection(keyPair: KeyPair, conf: PeerConnection.Conf, switchboard: A } d.transport ! localInit startSingleTimer(INIT_TIMER, InitTimeout, conf.initTimeout) + unstashAll() // unstash remote init if it already arrived goto(INITIALIZING) using InitializingData(chainHash, d.pendingAuth, d.remoteNodeId, d.transport, peer, localInit, doSync, d.isPersistent) - case Event(remoteInit: protocol.Init, _) => - log.debug("delaying remote init") - context.system.scheduler.scheduleOnce(100 millis, self, remoteInit)(context.dispatcher) + case Event(_: protocol.Init, _) => + log.debug("stashing remote init") + stash() stay() } From fb2e439356a2f0ca11555a497855704ebcbaf9c5 Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 30 May 2022 14:26:40 +0200 Subject: [PATCH 11/15] Revert "adapt WaitForOpenChannelStateSpec to new fixture" This reverts commit 3ef4f447b669d9bdca430374cdabb7008a4ed93e. --- .../channel/states/ChannelStateFixture.scala | 127 ------------------ .../a/WaitForOpenChannelStateSpec.scala | 92 +++++++------ 2 files changed, 48 insertions(+), 171 deletions(-) delete mode 100644 eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateFixture.scala diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateFixture.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateFixture.scala deleted file mode 100644 index b623e4a203..0000000000 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateFixture.scala +++ /dev/null @@ -1,127 +0,0 @@ -package fr.acinq.eclair.channel.states - -import akka.actor.ActorSystem -import akka.actor.typed.scaladsl.adapter.actorRefAdapter -import akka.testkit.{TestFSMRef, TestKit, TestProbe} -import com.softwaremill.quicklens.ModifyPimp -import fr.acinq.bitcoin.scalacompat.SatoshiLong -import fr.acinq.eclair.TestConstants.{Alice, Bob} -import fr.acinq.eclair.blockchain.{DummyOnChainWallet, OnChainWallet} -import fr.acinq.eclair.channel.fsm.Channel -import fr.acinq.eclair.channel.states.ChannelStateTestsHelperMethods.FakeTxPublisherFactory -import fr.acinq.eclair.channel.{ChannelData, ChannelState, ChannelTypes, Helpers, LocalChannelDown, LocalChannelUpdate, LocalParams, SupportedChannelType} -import fr.acinq.eclair.{BlockHeight, FeatureSupport, Features, NodeParams, TestConstants, TestUtils, UInt64} - -case class ChannelStateFixture(system: ActorSystem, - alice: TestFSMRef[ChannelState, ChannelData, Channel], - bob: TestFSMRef[ChannelState, ChannelData, Channel], - aliceOrigin: TestProbe, - alice2bob: TestProbe, - bob2alice: TestProbe, - alice2blockchain: TestProbe, - bob2blockchain: TestProbe, - router: TestProbe, - alice2relayer: TestProbe, - bob2relayer: TestProbe, - channelUpdateListener: TestProbe, - wallet: OnChainWallet, - alicePeer: TestProbe, - bobPeer: TestProbe) { - implicit val implicitSystem: ActorSystem = system - - def currentBlockHeight: BlockHeight = alice.underlyingActor.nodeParams.currentBlockHeight - - def cleanup(): Unit = { - TestKit.shutdownActorSystem(alice.underlyingActor.context.system) - TestKit.shutdownActorSystem(bob.underlyingActor.context.system) - TestKit.shutdownActorSystem(system) - } -} - -object ChannelStateFixture { - - def apply(nodeParamsA: NodeParams = TestConstants.Alice.nodeParams, nodeParamsB: NodeParams = TestConstants.Bob.nodeParams, wallet: OnChainWallet = new DummyOnChainWallet(), tags: Set[String] = Set.empty): ChannelStateFixture = { - implicit val system: ActorSystem = ActorSystem("system") - val aliceOrigin = TestProbe() - val alice2bob = TestProbe() - val bob2alice = TestProbe() - val alicePeer = TestProbe() - val bobPeer = TestProbe() - TestUtils.forwardOutgoingToPipe(alicePeer, alice2bob.ref) - TestUtils.forwardOutgoingToPipe(bobPeer, bob2alice.ref) - val alice2blockchain = TestProbe() - val bob2blockchain = TestProbe() - val alice2relayer = TestProbe() - val bob2relayer = TestProbe() - val channelUpdateListener = TestProbe() - val systemA: ActorSystem = ActorSystem("system-alice") - val systemB: ActorSystem = ActorSystem("system-bob") - systemA.eventStream.subscribe(channelUpdateListener.ref, classOf[LocalChannelUpdate]) - systemA.eventStream.subscribe(channelUpdateListener.ref, classOf[LocalChannelDown]) - systemB.eventStream.subscribe(channelUpdateListener.ref, classOf[LocalChannelUpdate]) - systemB.eventStream.subscribe(channelUpdateListener.ref, classOf[LocalChannelDown]) - val router = TestProbe() - val finalNodeParamsA = nodeParamsA - .modify(_.channelConf.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(5000 sat) - .modify(_.channelConf.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(1000 sat) - .modify(_.channelConf.maxRemoteDustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(10000 sat) - .modify(_.channelConf.maxRemoteDustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(10000 sat) - val finalNodeParamsB = nodeParamsB - .modify(_.channelConf.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(1000 sat) - .modify(_.channelConf.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(5000 sat) - .modify(_.channelConf.maxRemoteDustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(10000 sat) - .modify(_.channelConf.maxRemoteDustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(10000 sat) - val alice: TestFSMRef[ChannelState, ChannelData, Channel] = { - implicit val system: ActorSystem = systemA - TestFSMRef(new Channel(finalNodeParamsA, wallet, finalNodeParamsB.nodeId, alice2blockchain.ref, alice2relayer.ref, FakeTxPublisherFactory(alice2blockchain), origin_opt = Some(aliceOrigin.ref)), alicePeer.ref) - } - val bob: TestFSMRef[ChannelState, ChannelData, Channel] = { - implicit val system: ActorSystem = systemB - TestFSMRef(new Channel(finalNodeParamsB, wallet, finalNodeParamsA.nodeId, bob2blockchain.ref, bob2relayer.ref, FakeTxPublisherFactory(bob2blockchain)), bobPeer.ref) - } - ChannelStateFixture(system, alice, bob, aliceOrigin, alice2bob, bob2alice, alice2blockchain, bob2blockchain, router, alice2relayer, bob2relayer, channelUpdateListener, wallet, alicePeer, bobPeer) - } - - def computeFeatures(setup: ChannelStateFixture, tags: Set[String]): (LocalParams, LocalParams, SupportedChannelType) = { - import setup._ - - val aliceInitFeatures = Alice.nodeParams.features - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.Wumbo))(_.updated(Features.Wumbo, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.StaticRemoteKey))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.AnchorOutputs))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional).updated(Features.AnchorOutputs, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional).updated(Features.AnchorOutputs, FeatureSupport.Optional).updated(Features.AnchorOutputsZeroFeeHtlcTx, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.ShutdownAnySegwit))(_.updated(Features.ShutdownAnySegwit, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.OptionUpfrontShutdownScript))(_.updated(Features.UpfrontShutdownScript, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.ChannelType))(_.updated(Features.ChannelType, FeatureSupport.Optional)) - .initFeatures() - val bobInitFeatures = Bob.nodeParams.features - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.Wumbo))(_.updated(Features.Wumbo, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.StaticRemoteKey))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.AnchorOutputs))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional).updated(Features.AnchorOutputs, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs))(_.updated(Features.StaticRemoteKey, FeatureSupport.Optional).updated(Features.AnchorOutputs, FeatureSupport.Optional).updated(Features.AnchorOutputsZeroFeeHtlcTx, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.ShutdownAnySegwit))(_.updated(Features.ShutdownAnySegwit, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.OptionUpfrontShutdownScript))(_.updated(Features.UpfrontShutdownScript, FeatureSupport.Optional)) - .modify(_.activated).usingIf(tags.contains(ChannelStateTestsTags.ChannelType))(_.updated(Features.ChannelType, FeatureSupport.Optional)) - .initFeatures() - - val channelType = ChannelTypes.defaultFromFeatures(aliceInitFeatures, bobInitFeatures) - - implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global - val aliceParams = Alice.channelParams - .modify(_.initFeatures).setTo(aliceInitFeatures) - .modify(_.walletStaticPaymentBasepoint).setToIf(channelType.paysDirectlyToWallet)(Some(Helpers.getWalletPaymentBasepoint(wallet))) - .modify(_.maxHtlcValueInFlightMsat).setToIf(tags.contains(ChannelStateTestsTags.NoMaxHtlcValueInFlight))(UInt64.MaxValue) - .modify(_.maxHtlcValueInFlightMsat).setToIf(tags.contains(ChannelStateTestsTags.AliceLowMaxHtlcValueInFlight))(UInt64(150000000)) - .modify(_.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(5000 sat) - .modify(_.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(1000 sat) - val bobParams = Bob.channelParams - .modify(_.initFeatures).setTo(bobInitFeatures) - .modify(_.walletStaticPaymentBasepoint).setToIf(channelType.paysDirectlyToWallet)(Some(Helpers.getWalletPaymentBasepoint(wallet))) - .modify(_.maxHtlcValueInFlightMsat).setToIf(tags.contains(ChannelStateTestsTags.NoMaxHtlcValueInFlight))(UInt64.MaxValue) - .modify(_.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob))(1000 sat) - .modify(_.dustLimit).setToIf(tags.contains(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice))(5000 sat) - - (aliceParams, bobParams, channelType) - } - -} diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala index 0ec5b8916d..84ea97e2ce 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala @@ -16,50 +16,53 @@ package fr.acinq.eclair.channel.states.a -import akka.testkit.TestProbe -import com.softwaremill.quicklens.ModifyPimp +import akka.testkit.{TestFSMRef, TestProbe} import fr.acinq.bitcoin.scalacompat.{Block, Btc, ByteVector32, SatoshiLong} import fr.acinq.eclair.TestConstants.{Alice, Bob} import fr.acinq.eclair.blockchain.fee.FeeratePerKw import fr.acinq.eclair.channel._ import fr.acinq.eclair.channel.fsm.Channel -import fr.acinq.eclair.channel.states.ChannelStateFixture.computeFeatures -import fr.acinq.eclair.channel.states.{ChannelStateFixture, ChannelStateTestsTags} -import fr.acinq.eclair.testutils.FixtureSpec +import fr.acinq.eclair.channel.states.{ChannelStateTestsBase, ChannelStateTestsTags} import fr.acinq.eclair.wire.protocol.{AcceptChannel, ChannelTlv, Error, Init, OpenChannel, TlvStream} -import fr.acinq.eclair.{CltvExpiryDelta, MilliSatoshiLong, TestConstants, ToMilliSatoshiConversion} -import org.scalatest.{Tag, TestData} +import fr.acinq.eclair.{CltvExpiryDelta, MilliSatoshiLong, TestConstants, TestKitBaseClass, ToMilliSatoshiConversion} +import org.scalatest.funsuite.FixtureAnyFunSuiteLike +import org.scalatest.{Outcome, Tag} import scodec.bits.ByteVector +import scala.concurrent.duration._ + /** * Created by PM on 05/07/2016. */ -class WaitForOpenChannelStateSpec extends FixtureSpec { +class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with ChannelStateTestsBase { + + case class FixtureParam(alice: TestFSMRef[ChannelState, ChannelData, Channel], bob: TestFSMRef[ChannelState, ChannelData, Channel], alice2bob: TestProbe, bob2alice: TestProbe, bob2blockchain: TestProbe) + + override def withFixture(test: OneArgTest): Outcome = { - type FixtureParam = ChannelStateFixture + import com.softwaremill.quicklens._ - override def createFixture(testData: TestData): ChannelStateFixture = { val bobNodeParams = Bob.nodeParams - .modify(_.channelConf.maxFundingSatoshis).setToIf(testData.tags.contains("max-funding-satoshis"))(Btc(1)) + .modify(_.channelConf.maxFundingSatoshis).setToIf(test.tags.contains("max-funding-satoshis"))(Btc(1)) - val fixture = ChannelStateFixture(nodeParamsB = bobNodeParams) + val setup = init(nodeParamsB = bobNodeParams) - import fixture._ + import setup._ val channelConfig = ChannelConfig.standard - val (aliceParams, bobParams, defaultChannelType) = computeFeatures(fixture, testData.tags) - val channelType = if (testData.tags.contains("standard-channel-type")) ChannelTypes.Standard else defaultChannelType + val (aliceParams, bobParams, defaultChannelType) = computeFeatures(setup, test.tags) + val channelType = if (test.tags.contains("standard-channel-type")) ChannelTypes.Standard else defaultChannelType val commitTxFeerate = if (channelType == ChannelTypes.AnchorOutputs || channelType == ChannelTypes.AnchorOutputsZeroFeeHtlcTx) TestConstants.anchorOutputsFeeratePerKw else TestConstants.feeratePerKw val aliceInit = Init(aliceParams.initFeatures) val bobInit = Init(bobParams.initFeatures) - alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, commitTxFeerate, TestConstants.feeratePerKw, aliceParams, alice2bob.ref, bobInit, ChannelFlags.Private, channelConfig, channelType) - bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, aliceInit, channelConfig, channelType) - eventually(bob.stateName == WAIT_FOR_OPEN_CHANNEL) - fixture + within(30 seconds) { + alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, commitTxFeerate, TestConstants.feeratePerKw, aliceParams, alice2bob.ref, bobInit, ChannelFlags.Private, channelConfig, channelType) + bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, aliceInit, channelConfig, channelType) + awaitCond(bob.stateName == WAIT_FOR_OPEN_CHANNEL) + withFixture(test.toNoArgTest(FixtureParam(alice, bob, alice2bob, bob2alice, bob2blockchain))) + } } - override def cleanupFixture(fixture: ChannelStateFixture): Unit = fixture.cleanup() - test("recv OpenChannel") { f => import f._ val open = alice2bob.expectMsgType[OpenChannel] @@ -68,7 +71,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { // We always send a channel type, even for standard channels. assert(open.channelType_opt === Some(ChannelTypes.Standard)) alice2bob.forward(bob) - eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) + awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.Standard) } @@ -77,7 +80,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val open = alice2bob.expectMsgType[OpenChannel] assert(open.channelType_opt === Some(ChannelTypes.AnchorOutputs)) alice2bob.forward(bob) - eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) + awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.AnchorOutputs) } @@ -86,7 +89,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val open = alice2bob.expectMsgType[OpenChannel] assert(open.channelType_opt === Some(ChannelTypes.AnchorOutputsZeroFeeHtlcTx)) alice2bob.forward(bob) - eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) + awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.AnchorOutputsZeroFeeHtlcTx) } @@ -95,7 +98,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val open = alice2bob.expectMsgType[OpenChannel] assert(open.channelType_opt === Some(ChannelTypes.Standard)) alice2bob.forward(bob) - eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) + awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.Standard) } @@ -107,7 +110,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { bob ! open.copy(chainHash = livenetChainHash) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidChainHash(open.temporaryChannelId, Block.RegtestGenesisBlock.hash, livenetChainHash).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (funding too low, public channel)") { f => @@ -118,7 +121,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { bob ! open.copy(fundingSatoshis = lowFunding, channelFlags = ChannelFlags(announceChannel)) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, lowFunding, Bob.nodeParams.channelConf.minFundingSatoshis(announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (funding too low, private channel)") { f => @@ -129,7 +132,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { bob ! open.copy(fundingSatoshis = lowFunding, channelFlags = ChannelFlags(announceChannel)) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, lowFunding, Bob.nodeParams.channelConf.minFundingSatoshis(announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (funding over channel limit)") { f => @@ -139,7 +142,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { bob ! open.copy(fundingSatoshis = highFundingMsat) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, highFundingMsat, Bob.nodeParams.channelConf.minFundingSatoshis(open.channelFlags.announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (fundingSatoshis > max-funding-satoshis)", Tag(ChannelStateTestsTags.Wumbo)) { f => @@ -158,7 +161,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { bob ! open.copy(maxAcceptedHtlcs = invalidMaxAcceptedHtlcs) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidMaxAcceptedHtlcs(open.temporaryChannelId, invalidMaxAcceptedHtlcs, Channel.MAX_ACCEPTED_HTLCS).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (invalid push_msat)") { f => @@ -168,7 +171,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { bob ! open.copy(pushMsat = invalidPushMsat) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, InvalidPushAmount(open.temporaryChannelId, invalidPushMsat, open.fundingSatoshis.toMilliSatoshi).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (to_self_delay too high)") { f => @@ -178,7 +181,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { bob ! open.copy(toSelfDelay = delayTooHigh) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, ToSelfDelayTooHigh(open.temporaryChannelId, delayTooHigh, Alice.nodeParams.channelConf.maxToLocalDelay).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (reserve too high)") { f => @@ -189,7 +192,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { bob ! open.copy(channelReserveSatoshis = reserveTooHigh) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, ChannelReserveTooHigh(open.temporaryChannelId, reserveTooHigh, 0.3, 0.05).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (fee too low, but still valid)") { f => @@ -201,7 +204,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id assert(error === Error(open.temporaryChannelId, "local/remote feerates are too different: remoteFeeratePerKw=253 localFeeratePerKw=10000")) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (fee below absolute valid minimum)") { f => @@ -213,7 +216,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id assert(error === Error(open.temporaryChannelId, "remote fee rate is too small: remoteFeeratePerKw=252")) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (reserve below dust)") { f => @@ -224,7 +227,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id assert(error === Error(open.temporaryChannelId, DustLimitTooLarge(open.temporaryChannelId, open.dustLimitSatoshis, reserveTooSmall).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (dust limit too high)") { f => @@ -234,7 +237,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { bob ! open.copy(dustLimitSatoshis = dustLimitTooHigh) val error = bob2alice.expectMsgType[Error] assert(error === Error(open.temporaryChannelId, DustLimitTooLarge(open.temporaryChannelId, dustLimitTooHigh, Bob.nodeParams.channelConf.maxRemoteDustLimit).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (toLocal + toRemote below reserve)") { f => @@ -246,7 +249,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id assert(error === Error(open.temporaryChannelId, ChannelReserveNotMet(open.temporaryChannelId, pushMsat, (open.channelReserveSatoshis - 1.sat).toMilliSatoshi, open.channelReserveSatoshis).getMessage)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv OpenChannel (wumbo size)", Tag(ChannelStateTestsTags.Wumbo), Tag("max-funding-satoshis")) { f => @@ -255,7 +258,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val highFundingSat = Btc(1).toSatoshi bob ! open.copy(fundingSatoshis = highFundingSat) bob2alice.expectMsgType[AcceptChannel] - eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) + awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) } test("recv OpenChannel (upfront shutdown script)", Tag(ChannelStateTestsTags.OptionUpfrontShutdownScript)) { f => @@ -263,7 +266,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val open = alice2bob.expectMsgType[OpenChannel] assert(open.upfrontShutdownScript_opt.contains(alice.stateData.asInstanceOf[DATA_WAIT_FOR_ACCEPT_CHANNEL].initFunder.localParams.defaultFinalScriptPubKey)) alice2bob.forward(bob, open) - eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) + awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].remoteParams.shutdownScript == open.upfrontShutdownScript_opt) } @@ -272,7 +275,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val open = alice2bob.expectMsgType[OpenChannel] val open1 = open.copy(tlvStream = TlvStream(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.empty))) alice2bob.forward(bob, open1) - eventually(bob.stateName == WAIT_FOR_FUNDING_CREATED) + awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].remoteParams.shutdownScript.isEmpty) } @@ -281,13 +284,13 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val open = alice2bob.expectMsgType[OpenChannel] val open1 = open.copy(tlvStream = TlvStream(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.fromValidHex("deadbeef")))) alice2bob.forward(bob, open1) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv Error") { f => import f._ bob ! Error(ByteVector32.Zeroes, "oops") - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } test("recv CMD_CLOSE") { f => @@ -296,6 +299,7 @@ class WaitForOpenChannelStateSpec extends FixtureSpec { val c = CMD_CLOSE(sender.ref, None, None) bob ! c sender.expectMsg(RES_SUCCESS(c, ByteVector32.Zeroes)) - eventually(bob.stateName == CLOSED) + awaitCond(bob.stateName == CLOSED) } + } From ffeb8e511fd0da9f1cc066d00e92569d0aef82db Mon Sep 17 00:00:00 2001 From: pm47 Date: Mon, 30 May 2022 14:28:39 +0200 Subject: [PATCH 12/15] fixup! address review comments --- .../eclair/integration/basic/TwoNodesIntegrationSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala index c32504f2bd..cbeb0e4fa6 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/TwoNodesIntegrationSpec.scala @@ -20,7 +20,7 @@ class TwoNodesIntegrationSpec extends FixtureSpec with IntegrationPatience { import fr.acinq.eclair.integration.basic.fixtures.MinimalNodeFixture._ override def createFixture(testData: TestData): FixtureParam = { - // seeds have been chose so that node ids start with 02aaaa for alice, 02bbbb for bob, etc. + // seeds have been chosen so that node ids start with 02aaaa for alice, 02bbbb for bob, etc. val aliceParams = nodeParamsFor("alice", ByteVector32(hex"b4acd47335b25ab7b84b8c020997b12018592bb4631b868762154d77fa8b93a3")) val bobParams = nodeParamsFor("bob", ByteVector32(hex"7620226fec887b0b2ebe76492e5a3fd3eb0e47cd3773263f6a81b59a704dc492")) TwoNodesFixture(aliceParams, bobParams) From 202521b0101f68120e599e5b5f2107c10ff13be5 Mon Sep 17 00:00:00 2001 From: pm47 Date: Wed, 1 Jun 2022 16:41:00 +0200 Subject: [PATCH 13/15] remove ChannelStateTestsHelperMethods dependencies The circular dependency to TestKitBaseClass/TestKitBase was really weird, we had: - NormalStateSpec -> TestKitBaseClass -> ChannelStateTestsBase - ChannelStateTestsBase -> ChannelStateTestsHelperMethods - ChannelStateTestsHelperMethods -> TestKitBase --- .../ChannelStateTestsHelperMethods.scala | 55 +++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala index d011406706..defbe4c0ef 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala @@ -18,7 +18,7 @@ package fr.acinq.eclair.channel.states import akka.actor.typed.scaladsl.adapter.actorRefAdapter import akka.actor.{ActorContext, ActorRef, ActorSystem} -import akka.testkit.{TestFSMRef, TestKit, TestKitBase, TestProbe} +import akka.testkit.{TestFSMRef, TestKit, TestProbe} import com.softwaremill.quicklens.ModifyPimp import fr.acinq.bitcoin.ScriptFlags import fr.acinq.bitcoin.scalacompat.Crypto.PublicKey @@ -39,7 +39,8 @@ import fr.acinq.eclair.router.Router.ChannelHop import fr.acinq.eclair.transactions.Transactions import fr.acinq.eclair.transactions.Transactions._ import fr.acinq.eclair.wire.protocol._ -import org.scalatest.FixtureTestSuite +import org.scalatest.{Assertions, FixtureTestSuite} +import org.scalatest.concurrent.Eventually import java.util.UUID import scala.concurrent.duration._ @@ -47,7 +48,7 @@ import scala.concurrent.duration._ /** * Created by PM on 23/08/2016. */ -trait ChannelStateTestsBase extends ChannelStateTestsHelperMethods with FixtureTestSuite { +trait ChannelStateTestsBase extends ChannelStateTestsHelperMethods { implicit class ChannelWithTestFeeConf(a: TestFSMRef[ChannelState, ChannelData, Channel]) { // @formatter:off @@ -87,7 +88,7 @@ object ChannelStateTestsTags { val ChannelType = "option_channel_type" } -trait ChannelStateTestsHelperMethods extends TestKitBase { +trait ChannelStateTestsHelperMethods extends Assertions with Eventually { case class SetupFixture(alice: TestFSMRef[ChannelState, ChannelData, Channel], bob: TestFSMRef[ChannelState, ChannelData, Channel], @@ -106,6 +107,7 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { def currentBlockHeight: BlockHeight = alice.underlyingActor.nodeParams.currentBlockHeight } + implicit val system: ActorSystem val systemA: ActorSystem = ActorSystem("system-alice") val systemB: ActorSystem = ActorSystem("system-bob") @@ -227,7 +229,8 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { assert(bob2blockchain.expectMsgType[TxPublisher.SetChannelId].channelId != ByteVector32.Zeroes) bob2blockchain.expectMsgType[WatchFundingSpent] bob2blockchain.expectMsgType[WatchFundingConfirmed] - awaitCond(alice.stateName == WAIT_FOR_FUNDING_CONFIRMED) + + eventually(assert(alice.stateName == WAIT_FOR_FUNDING_CONFIRMED)) val fundingTx = alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].fundingTx.get alice ! WatchFundingConfirmedTriggered(BlockHeight(400000), 42, fundingTx) bob ! WatchFundingConfirmedTriggered(BlockHeight(400000), 42, fundingTx) @@ -239,8 +242,8 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { bob2alice.forward(alice) alice2blockchain.expectMsgType[WatchFundingDeeplyBuried] bob2blockchain.expectMsgType[WatchFundingDeeplyBuried] - awaitCond(alice.stateName == NORMAL) - awaitCond(bob.stateName == NORMAL) + eventually(assert(alice.stateName == NORMAL)) + eventually(assert(bob.stateName == NORMAL)) assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.availableBalanceForSend == (pushMsat - aliceParams.requestedChannelReserve_opt.getOrElse(0 sat)).max(0 msat)) // x2 because alice and bob share the same relayer channelUpdateListener.expectMsgType[LocalChannelUpdate] @@ -288,7 +291,7 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { s ! cmdAdd val htlc = s2r.expectMsgType[UpdateAddHtlc] s2r.forward(r) - awaitCond(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteChanges.proposed.contains(htlc)) + eventually(assert(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteChanges.proposed.contains(htlc))) htlc } @@ -296,14 +299,14 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { s ! CMD_FULFILL_HTLC(id, preimage) val fulfill = s2r.expectMsgType[UpdateFulfillHtlc] s2r.forward(r) - awaitCond(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteChanges.proposed.contains(fulfill)) + eventually(assert(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteChanges.proposed.contains(fulfill))) } def failHtlc(id: Long, s: TestFSMRef[ChannelState, ChannelData, Channel], r: TestFSMRef[ChannelState, ChannelData, Channel], s2r: TestProbe, r2s: TestProbe): Unit = { s ! CMD_FAIL_HTLC(id, Right(TemporaryNodeFailure)) val fail = s2r.expectMsgType[UpdateFailHtlc] s2r.forward(r) - awaitCond(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteChanges.proposed.contains(fail)) + eventually(assert(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteChanges.proposed.contains(fail))) } def crossSign(s: TestFSMRef[ChannelState, ChannelData, Channel], r: TestFSMRef[ChannelState, ChannelData, Channel], s2r: TestProbe, r2s: TestProbe): Unit = { @@ -326,15 +329,19 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { s2r.forward(r) r2s.expectMsgType[RevokeAndAck] r2s.forward(s) - awaitCond(s.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.index == sCommitIndex + 1) - awaitCond(s.stateData.asInstanceOf[PersistentChannelData].commitments.remoteCommit.index == sCommitIndex + 2) - awaitCond(r.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.index == rCommitIndex + 2) - awaitCond(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteCommit.index == rCommitIndex + 1) + eventually { + assert(s.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.index == sCommitIndex + 1) + assert(s.stateData.asInstanceOf[PersistentChannelData].commitments.remoteCommit.index == sCommitIndex + 2) + assert(r.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.index == rCommitIndex + 2) + assert(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteCommit.index == rCommitIndex + 1) + } } else { - awaitCond(s.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.index == sCommitIndex + 1) - awaitCond(s.stateData.asInstanceOf[PersistentChannelData].commitments.remoteCommit.index == sCommitIndex + 1) - awaitCond(r.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.index == rCommitIndex + 1) - awaitCond(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteCommit.index == rCommitIndex + 1) + eventually { + assert(s.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.index == sCommitIndex + 1) + assert(s.stateData.asInstanceOf[PersistentChannelData].commitments.remoteCommit.index == sCommitIndex + 1) + assert(r.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.index == rCommitIndex + 1) + assert(r.stateData.asInstanceOf[PersistentChannelData].commitments.remoteCommit.index == rCommitIndex + 1) + } } } @@ -350,7 +357,7 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { r2s.forward(s) s2r.expectMsgType[RevokeAndAck] s2r.forward(r) - awaitCond(s.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.spec.commitTxFeerate == feerate) + eventually(assert(s.stateData.asInstanceOf[PersistentChannelData].commitments.localCommit.spec.commitTxFeerate == feerate)) } def mutualClose(s: TestFSMRef[ChannelState, ChannelData, Channel], r: TestFSMRef[ChannelState, ChannelData, Channel], s2r: TestProbe, r2s: TestProbe, s2blockchain: TestProbe, r2blockchain: TestProbe): Unit = { @@ -373,8 +380,10 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { s2blockchain.expectMsgType[WatchTxConfirmed] r2blockchain.expectMsgType[TxPublisher.PublishTx] r2blockchain.expectMsgType[WatchTxConfirmed] - awaitCond(s.stateName == CLOSING) - awaitCond(r.stateName == CLOSING) + eventually { + assert(s.stateName == CLOSING) + assert(r.stateName == CLOSING) + } // both nodes are now in CLOSING state with a mutual close tx pending for confirmation } @@ -387,7 +396,7 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { val commitTx = localCommit.commitTxAndRemoteSig.commitTx.tx s ! Error(ByteVector32.Zeroes, "oops") - awaitCond(s.stateName == CLOSING) + eventually(assert(s.stateName == CLOSING)) val closingState = s.stateData.asInstanceOf[DATA_CLOSING] assert(closingState.localCommitPublished.isDefined) val localCommitPublished = closingState.localCommitPublished.get @@ -432,7 +441,7 @@ trait ChannelStateTestsHelperMethods extends TestKitBase { def remoteClose(rCommitTx: Transaction, s: TestFSMRef[ChannelState, ChannelData, Channel], s2blockchain: TestProbe): RemoteCommitPublished = { // we make s believe r unilaterally closed the channel s ! WatchFundingSpentTriggered(rCommitTx) - awaitCond(s.stateName == CLOSING) + eventually(assert(s.stateName == CLOSING)) val closingData = s.stateData.asInstanceOf[DATA_CLOSING] val remoteCommitPublished_opt = closingData.remoteCommitPublished.orElse(closingData.nextRemoteCommitPublished).orElse(closingData.futureRemoteCommitPublished) assert(remoteCommitPublished_opt.isDefined) From 2da5a97cd205e592ea02dfed5d92240a4f26b6dc Mon Sep 17 00:00:00 2001 From: pm47 Date: Wed, 1 Jun 2022 17:25:05 +0200 Subject: [PATCH 14/15] merge ChannelStateTestsBase and ChannelStateTestsHelperMethods --- .../eclair/channel/ChannelDataSpec.scala | 4 +-- .../eclair/channel/ChannelFeaturesSpec.scala | 4 +-- .../fr/acinq/eclair/channel/FuzzySpec.scala | 2 +- .../fr/acinq/eclair/channel/HelpersSpec.scala | 4 +-- .../fr/acinq/eclair/channel/RestoreSpec.scala | 2 +- .../publish/ReplaceableTxPublisherSpec.scala | 4 +-- .../ChannelStateTestsHelperMethods.scala | 29 +++++++------------ .../interop/rustytests/RustyTestsSpec.scala | 2 +- .../payment/PostRestartHtlcCleanerSpec.scala | 4 +-- 9 files changed, 24 insertions(+), 31 deletions(-) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelDataSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelDataSpec.scala index 1b24852f85..bbed15743f 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelDataSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelDataSpec.scala @@ -21,14 +21,14 @@ import fr.acinq.bitcoin.scalacompat.{ByteVector32, OutPoint, SatoshiLong, Transa import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher.WatchFundingSpentTriggered import fr.acinq.eclair.channel.Helpers.Closing import fr.acinq.eclair.channel.fsm.Channel -import fr.acinq.eclair.channel.states.ChannelStateTestsHelperMethods +import fr.acinq.eclair.channel.states.ChannelStateTestsBase import fr.acinq.eclair.transactions.Transactions._ import fr.acinq.eclair.wire.protocol.{CommitSig, RevokeAndAck, UnknownNextPeer, UpdateAddHtlc} import fr.acinq.eclair.{MilliSatoshiLong, NodeParams, TestKitBaseClass} import org.scalatest.funsuite.AnyFunSuiteLike import scodec.bits.ByteVector -class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStateTestsHelperMethods { +class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStateTestsBase { implicit val log: akka.event.LoggingAdapter = akka.event.NoLogging diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelFeaturesSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelFeaturesSpec.scala index 0981d3bac5..80e05bf045 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelFeaturesSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelFeaturesSpec.scala @@ -18,12 +18,12 @@ package fr.acinq.eclair.channel import fr.acinq.eclair.FeatureSupport._ import fr.acinq.eclair.Features._ -import fr.acinq.eclair.channel.states.ChannelStateTestsHelperMethods +import fr.acinq.eclair.channel.states.ChannelStateTestsBase import fr.acinq.eclair.transactions.Transactions import fr.acinq.eclair.{Features, InitFeature, NodeFeature, TestKitBaseClass} import org.scalatest.funsuite.AnyFunSuiteLike -class ChannelFeaturesSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStateTestsHelperMethods { +class ChannelFeaturesSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStateTestsBase { test("channel features determines commitment format") { val standardChannel = ChannelFeatures() diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/FuzzySpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/FuzzySpec.scala index e4cefd5cd9..987b686a7c 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/FuzzySpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/FuzzySpec.scala @@ -28,7 +28,7 @@ import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher._ import fr.acinq.eclair.channel.fsm.Channel import fr.acinq.eclair.channel.publish.TxPublisher import fr.acinq.eclair.channel.states.ChannelStateTestsBase -import fr.acinq.eclair.channel.states.ChannelStateTestsHelperMethods.FakeTxPublisherFactory +import fr.acinq.eclair.channel.states.ChannelStateTestsBase.FakeTxPublisherFactory import fr.acinq.eclair.payment.OutgoingPaymentPacket.Upstream import fr.acinq.eclair.payment._ import fr.acinq.eclair.payment.receive.MultiPartHandler.ReceivePayment diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/HelpersSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/HelpersSpec.scala index 38b1fb6fe6..717444b105 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/HelpersSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/HelpersSpec.scala @@ -24,7 +24,7 @@ import fr.acinq.eclair.TestUtils.NoLoggingDiagnostics import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher.WatchFundingSpentTriggered import fr.acinq.eclair.channel.Helpers.Closing import fr.acinq.eclair.channel.fsm.Channel -import fr.acinq.eclair.channel.states.{ChannelStateTestsHelperMethods, ChannelStateTestsTags} +import fr.acinq.eclair.channel.states.{ChannelStateTestsBase, ChannelStateTestsTags} import fr.acinq.eclair.transactions.Transactions._ import fr.acinq.eclair.wire.protocol.UpdateAddHtlc import fr.acinq.eclair.{BlockHeight, MilliSatoshiLong, TestKitBaseClass, TimestampSecond, TimestampSecondLong} @@ -35,7 +35,7 @@ import scodec.bits.HexStringSyntax import java.util.UUID import scala.concurrent.duration._ -class HelpersSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStateTestsHelperMethods { +class HelpersSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStateTestsBase { implicit val log: akka.event.LoggingAdapter = akka.event.NoLogging diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/RestoreSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/RestoreSpec.scala index 08cc58de8f..beedd584f0 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/RestoreSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/RestoreSpec.scala @@ -13,7 +13,7 @@ import fr.acinq.eclair.TestConstants.{Alice, Bob} import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher.WatchFundingSpentTriggered import fr.acinq.eclair.channel.fsm.Channel import fr.acinq.eclair.channel.states.ChannelStateTestsBase -import fr.acinq.eclair.channel.states.ChannelStateTestsHelperMethods.FakeTxPublisherFactory +import fr.acinq.eclair.channel.states.ChannelStateTestsBase.FakeTxPublisherFactory import fr.acinq.eclair.crypto.Generators import fr.acinq.eclair.crypto.keymanager.ChannelKeyManager import fr.acinq.eclair.router.Announcements diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisherSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisherSpec.scala index 42f45797e6..9444f32da7 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisherSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisherSpec.scala @@ -34,7 +34,7 @@ import fr.acinq.eclair.channel.fsm.Channel import fr.acinq.eclair.channel.publish.ReplaceableTxPublisher.{Publish, Stop, UpdateConfirmationTarget} import fr.acinq.eclair.channel.publish.TxPublisher.TxRejectedReason._ import fr.acinq.eclair.channel.publish.TxPublisher._ -import fr.acinq.eclair.channel.states.{ChannelStateTestsHelperMethods, ChannelStateTestsTags} +import fr.acinq.eclair.channel.states.{ChannelStateTestsBase, ChannelStateTestsTags} import fr.acinq.eclair.transactions.Transactions import fr.acinq.eclair.transactions.Transactions._ import fr.acinq.eclair.{BlockHeight, MilliSatoshiLong, NodeParams, NotificationsLogger, TestConstants, TestFeeEstimator, TestKitBaseClass, randomBytes32, randomKey} @@ -46,7 +46,7 @@ import java.util.concurrent.atomic.AtomicLong import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration.DurationInt -class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike with BitcoindService with ChannelStateTestsHelperMethods with BeforeAndAfterAll { +class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike with BitcoindService with ChannelStateTestsBase with BeforeAndAfterAll { override def beforeAll(): Unit = { startBitcoind() diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala index defbe4c0ef..a5461c8fcc 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala @@ -32,33 +32,19 @@ import fr.acinq.eclair.channel._ import fr.acinq.eclair.channel.fsm.Channel import fr.acinq.eclair.channel.publish.TxPublisher import fr.acinq.eclair.channel.publish.TxPublisher.PublishReplaceableTx -import fr.acinq.eclair.channel.states.ChannelStateTestsHelperMethods.FakeTxPublisherFactory +import fr.acinq.eclair.channel.states.ChannelStateTestsBase.FakeTxPublisherFactory import fr.acinq.eclair.payment.OutgoingPaymentPacket import fr.acinq.eclair.payment.OutgoingPaymentPacket.Upstream import fr.acinq.eclair.router.Router.ChannelHop import fr.acinq.eclair.transactions.Transactions import fr.acinq.eclair.transactions.Transactions._ import fr.acinq.eclair.wire.protocol._ -import org.scalatest.{Assertions, FixtureTestSuite} +import org.scalatest.Assertions import org.scalatest.concurrent.Eventually import java.util.UUID import scala.concurrent.duration._ -/** - * Created by PM on 23/08/2016. - */ -trait ChannelStateTestsBase extends ChannelStateTestsHelperMethods { - - implicit class ChannelWithTestFeeConf(a: TestFSMRef[ChannelState, ChannelData, Channel]) { - // @formatter:off - def feeEstimator: TestFeeEstimator = a.underlyingActor.nodeParams.onChainFeeConf.feeEstimator.asInstanceOf[TestFeeEstimator] - def feeTargets: FeeTargets = a.underlyingActor.nodeParams.onChainFeeConf.feeTargets - // @formatter:on - } - -} - object ChannelStateTestsTags { /** If set, channels will use option_support_large_channel. */ val Wumbo = "wumbo" @@ -88,7 +74,7 @@ object ChannelStateTestsTags { val ChannelType = "option_channel_type" } -trait ChannelStateTestsHelperMethods extends Assertions with Eventually { +trait ChannelStateTestsBase extends Assertions with Eventually { case class SetupFixture(alice: TestFSMRef[ChannelState, ChannelData, Channel], bob: TestFSMRef[ChannelState, ChannelData, Channel], @@ -107,6 +93,13 @@ trait ChannelStateTestsHelperMethods extends Assertions with Eventually { def currentBlockHeight: BlockHeight = alice.underlyingActor.nodeParams.currentBlockHeight } + implicit class ChannelWithTestFeeConf(a: TestFSMRef[ChannelState, ChannelData, Channel]) { + // @formatter:off + def feeEstimator: TestFeeEstimator = a.underlyingActor.nodeParams.onChainFeeConf.feeEstimator.asInstanceOf[TestFeeEstimator] + def feeTargets: FeeTargets = a.underlyingActor.nodeParams.onChainFeeConf.feeTargets + // @formatter:on + } + implicit val system: ActorSystem val systemA: ActorSystem = ActorSystem("system-alice") val systemB: ActorSystem = ActorSystem("system-bob") @@ -486,7 +479,7 @@ trait ChannelStateTestsHelperMethods extends Assertions with Eventually { } -object ChannelStateTestsHelperMethods { +object ChannelStateTestsBase { case class FakeTxPublisherFactory(txPublisher: TestProbe) extends Channel.TxPublisherFactory { override def spawnTxPublisher(context: ActorContext, remoteNodeId: PublicKey): akka.actor.typed.ActorRef[TxPublisher.Command] = txPublisher.ref diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/interop/rustytests/RustyTestsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/interop/rustytests/RustyTestsSpec.scala index 9e36e63243..2563eaf43e 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/interop/rustytests/RustyTestsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/interop/rustytests/RustyTestsSpec.scala @@ -27,7 +27,7 @@ import fr.acinq.eclair.blockchain.fee.{FeeratePerKw, FeeratesPerKw} import fr.acinq.eclair.channel._ import fr.acinq.eclair.channel.fsm.Channel import fr.acinq.eclair.channel.publish.TxPublisher -import fr.acinq.eclair.channel.states.ChannelStateTestsHelperMethods.FakeTxPublisherFactory +import fr.acinq.eclair.channel.states.ChannelStateTestsBase.FakeTxPublisherFactory import fr.acinq.eclair.payment.receive.{ForwardHandler, PaymentHandler} import fr.acinq.eclair.wire.protocol.Init import fr.acinq.eclair.{BlockHeight, MilliSatoshiLong, TestFeeEstimator, TestKitBaseClass, TestUtils} diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PostRestartHtlcCleanerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PostRestartHtlcCleanerSpec.scala index 611eadc840..f53be5caa5 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PostRestartHtlcCleanerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PostRestartHtlcCleanerSpec.scala @@ -25,7 +25,7 @@ import fr.acinq.bitcoin.scalacompat.{Block, ByteVector32, Crypto, OutPoint, Sato import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher.WatchTxConfirmedTriggered import fr.acinq.eclair.channel.Helpers.Closing import fr.acinq.eclair.channel._ -import fr.acinq.eclair.channel.states.ChannelStateTestsHelperMethods +import fr.acinq.eclair.channel.states.ChannelStateTestsBase import fr.acinq.eclair.db.{OutgoingPayment, OutgoingPaymentStatus, PaymentType} import fr.acinq.eclair.payment.OutgoingPaymentPacket.{Upstream, buildCommand} import fr.acinq.eclair.payment.PaymentPacketSpec._ @@ -50,7 +50,7 @@ import scala.util.Success * Created by t-bast on 21/11/2019. */ -class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with ParallelTestExecution with ChannelStateTestsHelperMethods { +class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with ParallelTestExecution with ChannelStateTestsBase { import PostRestartHtlcCleanerSpec._ From 8833eaeb332dd20ec906ee18faacb608cfc8e6b7 Mon Sep 17 00:00:00 2001 From: pm47 Date: Wed, 1 Jun 2022 16:58:30 +0200 Subject: [PATCH 15/15] replace all === by == Triple equals allows customizing the equality method, but we never use that. Detailed errors (which is what we were looking for) are provided by mixing in scalatest's `Assertions` and using the regular `assert(x==y)` syntax. The `Assertions` trait is already mixed in by default in all scalatest suites. --- .../fr/acinq/eclair/CltvExpirySpec.scala | 22 +- .../fr/acinq/eclair/EclairImplSpec.scala | 128 ++--- .../scala/fr/acinq/eclair/FeaturesSpec.scala | 36 +- .../fr/acinq/eclair/MilliSatoshiSpec.scala | 44 +- .../scala/fr/acinq/eclair/PackageSpec.scala | 2 +- .../scala/fr/acinq/eclair/StartupSpec.scala | 16 +- .../scala/fr/acinq/eclair/UInt64Spec.scala | 24 +- .../eclair/balance/CheckBalanceSpec.scala | 22 +- .../bitcoind/BitcoinCoreClientSpec.scala | 70 +-- .../blockchain/bitcoind/ZmqWatcherSpec.scala | 38 +- .../fee/BitcoinCoreFeeProviderSpec.scala | 2 +- .../fee/FallbackFeeProviderSpec.scala | 22 +- .../blockchain/fee/FeeEstimatorSpec.scala | 42 +- .../blockchain/fee/FeeProviderSpec.scala | 28 +- .../watchdogs/BlockchainWatchdogSpec.scala | 28 +- .../watchdogs/ExplorerApiSpec.scala | 4 +- .../eclair/channel/ChannelDataSpec.scala | 60 +-- .../eclair/channel/ChannelFeaturesSpec.scala | 30 +- .../eclair/channel/CommitmentsSpec.scala | 2 +- .../eclair/channel/DustExposureSpec.scala | 38 +- .../fr/acinq/eclair/channel/HelpersSpec.scala | 24 +- .../acinq/eclair/channel/RegisterSpec.scala | 2 +- .../fr/acinq/eclair/channel/RestoreSpec.scala | 8 +- .../publish/FinalTxPublisherSpec.scala | 8 +- .../publish/MempoolTxMonitorSpec.scala | 6 +- .../publish/ReplaceableTxFunderSpec.scala | 46 +- .../publish/ReplaceableTxPublisherSpec.scala | 192 ++++---- .../channel/publish/TxPublisherSpec.scala | 38 +- .../publish/TxTimeLocksMonitorSpec.scala | 8 +- .../ChannelStateTestsHelperMethods.scala | 12 +- .../a/WaitForAcceptChannelStateSpec.scala | 48 +- .../a/WaitForOpenChannelStateSpec.scala | 46 +- .../b/WaitForFundingCreatedStateSpec.scala | 4 +- .../b/WaitForFundingSignedStateSpec.scala | 6 +- .../c/WaitForFundingConfirmedStateSpec.scala | 22 +- .../c/WaitForFundingLockedStateSpec.scala | 20 +- .../channel/states/e/NormalStateSpec.scala | 446 +++++++++--------- .../channel/states/e/OfflineStateSpec.scala | 38 +- .../channel/states/f/ShutdownStateSpec.scala | 120 ++--- .../states/g/NegotiatingStateSpec.scala | 134 +++--- .../channel/states/h/ClosingStateSpec.scala | 374 +++++++-------- .../eclair/crypto/ChaCha20Poly1305Spec.scala | 4 +- .../fr/acinq/eclair/crypto/RandomSpec.scala | 2 +- .../fr/acinq/eclair/crypto/ShaChainSpec.scala | 2 +- .../fr/acinq/eclair/crypto/SphinxSpec.scala | 130 ++--- .../eclair/crypto/TransportHandlerSpec.scala | 12 +- .../keymanager/LocalNodeKeyManagerSpec.scala | 2 +- .../fr/acinq/eclair/db/AuditDbSpec.scala | 40 +- .../fr/acinq/eclair/db/ChannelsDbSpec.scala | 32 +- .../acinq/eclair/db/DualDatabasesSpec.scala | 4 +- .../fr/acinq/eclair/db/NetworkDbSpec.scala | 36 +- .../fr/acinq/eclair/db/PaymentsDbSpec.scala | 92 ++-- .../fr/acinq/eclair/db/PeersDbSpec.scala | 32 +- .../eclair/db/PendingCommandsDbSpec.scala | 14 +- .../fr/acinq/eclair/db/PgUtilsSpec.scala | 8 +- .../eclair/db/SqliteFeeratesDbSpec.scala | 4 +- .../fr/acinq/eclair/db/SqliteUtilsSpec.scala | 16 +- .../integration/ChannelIntegrationSpec.scala | 38 +- .../integration/MessageIntegrationSpec.scala | 14 +- .../integration/PaymentIntegrationSpec.scala | 134 +++--- .../integration/StartupIntegrationSpec.scala | 6 +- .../basic/fixtures/MinimalNodeFixture.scala | 2 +- .../interop/rustytests/RustyTestsSpec.scala | 20 +- .../fr/acinq/eclair/io/MessageRelaySpec.scala | 22 +- .../fr/acinq/eclair/io/NodeURISpec.scala | 2 +- .../acinq/eclair/io/PeerConnectionSpec.scala | 20 +- .../scala/fr/acinq/eclair/io/PeerSpec.scala | 66 +-- .../eclair/io/ReconnectionTaskSpec.scala | 26 +- .../fr/acinq/eclair/io/SwitchboardSpec.scala | 20 +- .../eclair/message/OnionMessagesSpec.scala | 8 +- .../fr/acinq/eclair/message/PostmanSpec.scala | 16 +- .../eclair/payment/Bolt11InvoiceSpec.scala | 212 ++++----- .../eclair/payment/Bolt12InvoiceSpec.scala | 58 +-- .../eclair/payment/MultiPartHandlerSpec.scala | 92 ++-- .../payment/MultiPartPaymentFSMSpec.scala | 44 +- .../MultiPartPaymentLifecycleSpec.scala | 140 +++--- .../eclair/payment/PaymentInitiatorSpec.scala | 106 ++--- .../eclair/payment/PaymentLifecycleSpec.scala | 100 ++-- .../eclair/payment/PaymentPacketSpec.scala | 218 ++++----- .../payment/PostRestartHtlcCleanerSpec.scala | 66 +-- .../payment/receive/InvoicePurgerSpec.scala | 14 +- .../payment/relay/ChannelRelayerSpec.scala | 42 +- .../payment/relay/NodeRelayerSpec.scala | 160 +++---- .../eclair/payment/relay/RelayerSpec.scala | 28 +- .../eclair/router/AnnouncementsSpec.scala | 14 +- .../acinq/eclair/router/BaseRouterSpec.scala | 28 +- .../router/ChannelRangeQueriesSpec.scala | 24 +- .../router/ChannelRouterIntegrationSpec.scala | 4 +- .../fr/acinq/eclair/router/GraphSpec.scala | 72 +-- .../eclair/router/RouteCalculationSpec.scala | 256 +++++----- .../fr/acinq/eclair/router/RouterSpec.scala | 106 ++--- .../acinq/eclair/router/RoutingSyncSpec.scala | 62 +-- .../eclair/tor/TorProtocolHandlerSpec.scala | 16 +- .../transactions/CommitmentSpecSpec.scala | 22 +- .../eclair/transactions/TestVectorsSpec.scala | 6 +- .../transactions/TransactionsSpec.scala | 152 +++--- .../wire/internal/CommandCodecsSpec.scala | 8 +- .../internal/channel/ChannelCodecsSpec.scala | 46 +- .../channel/version0/ChannelCodecs0Spec.scala | 22 +- .../channel/version1/ChannelCodecs1Spec.scala | 48 +- .../channel/version2/ChannelCodecs2Spec.scala | 20 +- .../channel/version3/ChannelCodecs3Spec.scala | 76 +-- .../wire/protocol/CommonCodecsSpec.scala | 68 +-- .../protocol/ExtendedQueriesCodecsSpec.scala | 24 +- .../protocol/FailureMessageCodecsSpec.scala | 20 +- .../protocol/LightningMessageCodecsSpec.scala | 64 +-- .../protocol/MessageOnionCodecsSpec.scala | 28 +- .../eclair/wire/protocol/OffersSpec.scala | 50 +- .../wire/protocol/PaymentOnionSpec.scala | 88 ++-- .../wire/protocol/RouteBlindingSpec.scala | 6 +- .../eclair/wire/protocol/TlvCodecsSpec.scala | 56 +-- .../acinq/eclair/router/FrontRouterSpec.scala | 4 +- .../fr/acinq/eclair/api/ApiServiceSpec.scala | 26 +- 113 files changed, 2890 insertions(+), 2890 deletions(-) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/CltvExpirySpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/CltvExpirySpec.scala index e77446a728..b319a494d2 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/CltvExpirySpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/CltvExpirySpec.scala @@ -27,15 +27,15 @@ class CltvExpirySpec extends AnyFunSuite with ParallelTestExecution { test("cltv expiry delta") { val d = CltvExpiryDelta(561) - assert(d.toInt === 561) + assert(d.toInt == 561) // add - assert(d + 5 === CltvExpiryDelta(566)) - assert(d + CltvExpiryDelta(5) === CltvExpiryDelta(566)) + assert(d + 5 == CltvExpiryDelta(566)) + assert(d + CltvExpiryDelta(5) == CltvExpiryDelta(566)) // subtract - assert(d - CltvExpiryDelta(5) === CltvExpiryDelta(556)) - assert(d - CltvExpiryDelta(562) === CltvExpiryDelta(-1)) + assert(d - CltvExpiryDelta(5) == CltvExpiryDelta(556)) + assert(d - CltvExpiryDelta(562) == CltvExpiryDelta(-1)) // compare assert(d <= CltvExpiryDelta(561)) @@ -44,18 +44,18 @@ class CltvExpirySpec extends AnyFunSuite with ParallelTestExecution { assert(d > CltvExpiryDelta(560)) // convert to cltv expiry - assert(d.toCltvExpiry(currentBlockHeight = BlockHeight(1105)) === CltvExpiry(1666)) - assert(d.toCltvExpiry(currentBlockHeight = BlockHeight(1106)) === CltvExpiry(1667)) + assert(d.toCltvExpiry(currentBlockHeight = BlockHeight(1105)) == CltvExpiry(1666)) + assert(d.toCltvExpiry(currentBlockHeight = BlockHeight(1106)) == CltvExpiry(1667)) } test("cltv expiry") { val e = CltvExpiry(1105) - assert(e.toLong === 1105) + assert(e.toLong == 1105) // add - assert(e + CltvExpiryDelta(561) === CltvExpiry(1666)) - assert(e - CltvExpiryDelta(561) === CltvExpiry(544)) - assert(e - CltvExpiry(561) === CltvExpiryDelta(544)) + assert(e + CltvExpiryDelta(561) == CltvExpiry(1666)) + assert(e - CltvExpiryDelta(561) == CltvExpiry(544)) + assert(e - CltvExpiry(561) == CltvExpiryDelta(544)) // compare assert(e <= CltvExpiry(1105)) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/EclairImplSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/EclairImplSpec.scala index f0af4df86f..9154eb3154 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/EclairImplSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/EclairImplSpec.scala @@ -97,13 +97,13 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I // standard conversion eclair.open(nodeId, fundingAmount = 10000000L sat, pushAmount_opt = None, channelType_opt = None, fundingFeeratePerByte_opt = Some(FeeratePerByte(5 sat)), announceChannel_opt = None, openTimeout_opt = None) val open = switchboard.expectMsgType[OpenChannel] - assert(open.fundingTxFeeratePerKw_opt === Some(FeeratePerKw(1250 sat))) + assert(open.fundingTxFeeratePerKw_opt == Some(FeeratePerKw(1250 sat))) // check that minimum fee rate of 253 sat/bw is used eclair.open(nodeId, fundingAmount = 10000000L sat, pushAmount_opt = None, channelType_opt = Some(ChannelTypes.StaticRemoteKey), fundingFeeratePerByte_opt = Some(FeeratePerByte(1 sat)), announceChannel_opt = None, openTimeout_opt = None) val open1 = switchboard.expectMsgType[OpenChannel] - assert(open1.fundingTxFeeratePerKw_opt === Some(FeeratePerKw.MinimumFeeratePerKw)) - assert(open1.channelType_opt === Some(ChannelTypes.StaticRemoteKey)) + assert(open1.fundingTxFeeratePerKw_opt == Some(FeeratePerKw.MinimumFeeratePerKw)) + assert(open1.channelType_opt == Some(ChannelTypes.StaticRemoteKey)) } test("call send with passing correct arguments") { f => @@ -114,12 +114,12 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I val invoice0 = Bolt11Invoice(Block.RegtestGenesisBlock.hash, Some(123 msat), ByteVector32.Zeroes, nodePrivKey, Left("description"), CltvExpiryDelta(18)) eclair.send(None, 123 msat, invoice0) val send = paymentInitiator.expectMsgType[SendPaymentToNode] - assert(send.externalId === None) - assert(send.recipientNodeId === nodePrivKey.publicKey) - assert(send.recipientAmount === 123.msat) - assert(send.paymentHash === ByteVector32.Zeroes) - assert(send.invoice === invoice0) - assert(send.assistedRoutes === Seq.empty) + assert(send.externalId == None) + assert(send.recipientNodeId == nodePrivKey.publicKey) + assert(send.recipientAmount == 123.msat) + assert(send.paymentHash == ByteVector32.Zeroes) + assert(send.invoice == invoice0) + assert(send.assistedRoutes == Seq.empty) // with assisted routes val externalId1 = "030bb6a5e0c6b203c7e2180fb78c7ba4bdce46126761d8201b91ddac089cdecc87" @@ -127,33 +127,33 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I val invoice1 = Bolt11Invoice(Block.RegtestGenesisBlock.hash, Some(123 msat), ByteVector32.Zeroes, nodePrivKey, Left("description"), CltvExpiryDelta(18), None, None, hints) eclair.send(Some(externalId1), 123 msat, invoice1) val send1 = paymentInitiator.expectMsgType[SendPaymentToNode] - assert(send1.externalId === Some(externalId1)) - assert(send1.recipientNodeId === nodePrivKey.publicKey) - assert(send1.recipientAmount === 123.msat) - assert(send1.paymentHash === ByteVector32.Zeroes) - assert(send1.invoice === invoice1) - assert(send1.assistedRoutes === hints) + assert(send1.externalId == Some(externalId1)) + assert(send1.recipientNodeId == nodePrivKey.publicKey) + assert(send1.recipientAmount == 123.msat) + assert(send1.paymentHash == ByteVector32.Zeroes) + assert(send1.invoice == invoice1) + assert(send1.assistedRoutes == hints) // with finalCltvExpiry val externalId2 = "487da196-a4dc-4b1e-92b4-3e5e905e9f3f" val invoice2 = Bolt11Invoice("lntb", Some(123 msat), TimestampSecond.now(), nodePrivKey.publicKey, List(Bolt11Invoice.MinFinalCltvExpiry(96), Bolt11Invoice.PaymentHash(ByteVector32.Zeroes), Bolt11Invoice.Description("description")), ByteVector.empty) eclair.send(Some(externalId2), 123 msat, invoice2) val send2 = paymentInitiator.expectMsgType[SendPaymentToNode] - assert(send2.externalId === Some(externalId2)) - assert(send2.recipientNodeId === nodePrivKey.publicKey) - assert(send2.recipientAmount === 123.msat) - assert(send2.paymentHash === ByteVector32.Zeroes) - assert(send2.invoice === invoice2) + assert(send2.externalId == Some(externalId2)) + assert(send2.recipientNodeId == nodePrivKey.publicKey) + assert(send2.recipientAmount == 123.msat) + assert(send2.paymentHash == ByteVector32.Zeroes) + assert(send2.invoice == invoice2) // with custom route fees parameters eclair.send(None, 123 msat, invoice0, maxFeeFlat_opt = Some(123 sat), maxFeePct_opt = Some(4.20)) val send3 = paymentInitiator.expectMsgType[SendPaymentToNode] - assert(send3.externalId === None) - assert(send3.recipientNodeId === nodePrivKey.publicKey) - assert(send3.recipientAmount === 123.msat) - assert(send3.paymentHash === ByteVector32.Zeroes) - assert(send3.routeParams.boundaries.maxFeeFlat === 123000.msat) // conversion sat -> msat - assert(send3.routeParams.boundaries.maxFeeProportional === 0.042) + assert(send3.externalId == None) + assert(send3.recipientNodeId == nodePrivKey.publicKey) + assert(send3.recipientAmount == 123.msat) + assert(send3.paymentHash == ByteVector32.Zeroes) + assert(send3.routeParams.boundaries.maxFeeFlat == 123000.msat) // conversion sat -> msat + assert(send3.routeParams.boundaries.maxFeeProportional == 0.042) val invalidExternalId = "Robert'); DROP TABLE received_payments; DROP TABLE sent_payments; DROP TABLE payments;" assertThrows[IllegalArgumentException](Await.result(eclair.send(Some(invalidExternalId), 123 msat, invoice0), 50 millis)) @@ -179,13 +179,13 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I eclair.nodes().pipeTo(sender.ref) router.expectMsg(Router.GetNodes) router.reply(allNodes) - assert(sender.expectMsgType[Iterable[NodeAnnouncement]].toSet === allNodes.toSet) + assert(sender.expectMsgType[Iterable[NodeAnnouncement]].toSet == allNodes.toSet) } { eclair.nodes(Some(Set(remoteNodeAnn1.nodeId, remoteNodeAnn2.nodeId))).pipeTo(sender.ref) router.expectMsg(Router.GetNodes) router.reply(allNodes) - assert(sender.expectMsgType[Iterable[NodeAnnouncement]].toSet === Set(remoteNodeAnn1, remoteNodeAnn2)) + assert(sender.expectMsgType[Iterable[NodeAnnouncement]].toSet == Set(remoteNodeAnn1, remoteNodeAnn2)) } { eclair.nodes(Some(Set(randomKey().publicKey))).pipeTo(sender.ref) @@ -230,7 +230,7 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I eclair.allUpdates(Some(b)).pipeTo(sender.ref) // ask updates filtered by 'b' router.expectMsg(Router.GetChannelsMap) router.reply(channels) - assert(sender.expectMsgType[Iterable[ChannelUpdate]].map(_.shortChannelId).toSet === Set(ShortChannelId(2))) + assert(sender.expectMsgType[Iterable[ChannelUpdate]].map(_.shortChannelId).toSet == Set(ShortChannelId(2))) } test("close and forceclose should work both with channelId and shortChannelId") { f => @@ -279,9 +279,9 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I eclair.receive(Left("some desc"), Some(123 msat), Some(456), Some(fallBackAddressRaw), None) val receive = paymentHandler.expectMsgType[ReceivePayment] - assert(receive.amount_opt === Some(123 msat)) - assert(receive.expirySeconds_opt === Some(456)) - assert(receive.fallbackAddress_opt === Some(fallBackAddressRaw)) + assert(receive.amount_opt == Some(123 msat)) + assert(receive.expirySeconds_opt == Some(456)) + assert(receive.fallbackAddress_opt == Some(fallBackAddressRaw)) // try with wrong address format assertThrows[IllegalArgumentException](eclair.receive(Left("some desc"), Some(123 msat), Some(456), Some("wassa wassa"), None)) @@ -295,7 +295,7 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I val paymentPreimage = randomBytes32() eclair.receive(Left("some desc"), None, None, None, Some(paymentPreimage)).pipeTo(sender.ref) - assert(sender.expectMsgType[Invoice].paymentHash === Crypto.sha256(paymentPreimage)) + assert(sender.expectMsgType[Invoice].paymentHash == Crypto.sha256(paymentPreimage)) } test("sendtoroute should pass the parameters correctly") { f => @@ -319,10 +319,10 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I eclair.sendWithPreimage(None, nodeId, 12345 msat) val send = paymentInitiator.expectMsgType[SendSpontaneousPayment] - assert(send.externalId === None) - assert(send.recipientNodeId === nodeId) - assert(send.recipientAmount === 12345.msat) - assert(send.paymentHash === Crypto.sha256(send.paymentPreimage)) + assert(send.externalId == None) + assert(send.recipientNodeId == nodeId) + assert(send.recipientAmount == 12345.msat) + assert(send.paymentHash == Crypto.sha256(send.paymentPreimage)) assert(send.userCustomTlvs.isEmpty) } @@ -336,11 +336,11 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I eclair.sendWithPreimage(None, nodeId, 12345 msat, paymentPreimage = expectedPaymentPreimage) val send = paymentInitiator.expectMsgType[SendSpontaneousPayment] - assert(send.externalId === None) - assert(send.recipientNodeId === nodeId) - assert(send.recipientAmount === 12345.msat) - assert(send.paymentPreimage === expectedPaymentPreimage) - assert(send.paymentHash === expectedPaymentHash) + assert(send.externalId == None) + assert(send.recipientNodeId == nodeId) + assert(send.recipientAmount == 12345.msat) + assert(send.paymentPreimage == expectedPaymentPreimage) + assert(send.paymentHash == expectedPaymentHash) assert(send.userCustomTlvs.isEmpty) } @@ -353,17 +353,17 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I val bytesMsg = ByteVector.fromValidBase64(base64Msg) val signedMessage = eclair.signMessage(bytesMsg) - assert(signedMessage.nodeId === kit.nodeParams.nodeId) - assert(signedMessage.message === base64Msg) + assert(signedMessage.nodeId == kit.nodeParams.nodeId) + assert(signedMessage.message == base64Msg) val verifiedMessage = eclair.verifyMessage(bytesMsg, signedMessage.signature) assert(verifiedMessage.valid) - assert(verifiedMessage.publicKey === kit.nodeParams.nodeId) + assert(verifiedMessage.publicKey == kit.nodeParams.nodeId) val prefix = ByteVector("Lightning Signed Message:".getBytes) val dhash256 = Crypto.hash256(prefix ++ bytesMsg) val expectedDigest = ByteVector32(hex"cbedbc1542fb139e2e10954f1ff9f82e8a1031cc63260636bbc45a90114552ea") - assert(dhash256 === expectedDigest) + assert(dhash256 == expectedDigest) assert(Crypto.verifySignature(dhash256, ByteVector64(signedMessage.signature.tail), kit.nodeParams.nodeId)) } @@ -376,8 +376,8 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I val bytesMsg = ByteVector.fromValidBase64(base64Msg) val signedMessage = eclair.signMessage(bytesMsg) - assert(signedMessage.nodeId === kit.nodeParams.nodeId) - assert(signedMessage.message === base64Msg) + assert(signedMessage.nodeId == kit.nodeParams.nodeId) + assert(signedMessage.message == base64Msg) val wrongMsg = ByteVector.fromValidBase64(base64Msg.tail) val verifiedMessage = eclair.verifyMessage(wrongMsg, signedMessage.signature) @@ -404,8 +404,8 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I val bytesMsg = ByteVector.fromValidBase64(base64Msg) val signedMessage = eclair.signMessage(bytesMsg) - assert(signedMessage.nodeId === kit.nodeParams.nodeId) - assert(signedMessage.message === base64Msg) + assert(signedMessage.nodeId == kit.nodeParams.nodeId) + assert(signedMessage.message == base64Msg) val invalidSignature = (if (signedMessage.signature.head.toInt == 31) 32 else 31).toByte +: signedMessage.signature.tail val verifiedMessage = eclair.verifyMessage(bytesMsg, invalidSignature) @@ -437,7 +437,7 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I register.reply(RES_GET_CHANNEL_INFO(map(c3.channelId), c3.channelId, NORMAL, ChannelCodecsSpec.normal)) register.expectNoMessage() - assert(sender.expectMsgType[Iterable[RES_GET_CHANNEL_INFO]].toSet === Set( + assert(sender.expectMsgType[Iterable[RES_GET_CHANNEL_INFO]].toSet == Set( RES_GET_CHANNEL_INFO(a, a1, NORMAL, ChannelCodecsSpec.normal), RES_GET_CHANNEL_INFO(b, b1, NORMAL, ChannelCodecsSpec.normal), )) @@ -466,7 +466,7 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I register.reply(RES_GET_CHANNEL_INFO(channels2Nodes(c2.channelId), c2.channelId, NORMAL, ChannelCodecsSpec.normal)) register.expectNoMessage() - assert(sender.expectMsgType[Iterable[RES_GET_CHANNEL_INFO]].toSet === Set( + assert(sender.expectMsgType[Iterable[RES_GET_CHANNEL_INFO]].toSet == Set( RES_GET_CHANNEL_INFO(a, a1, NORMAL, ChannelCodecsSpec.normal), RES_GET_CHANNEL_INFO(a, a2, NORMAL, ChannelCodecsSpec.normal), )) @@ -519,11 +519,11 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I paymentInitiator.expectMsg(GetPayment(Right(spontaneousPayment.paymentHash))) paymentInitiator.reply(PaymentIsPending(pendingPaymentId, spontaneousPayment.paymentHash, PendingSpontaneousPayment(ActorRef.noSender, spontaneousPayment))) val pendingPayment2 = sender.expectMsgType[Seq[OutgoingPayment]] - assert(pendingPayment2.length === 1) - assert(pendingPayment2.head.id === pendingPayment2.head.parentId) - assert(pendingPayment2.head.id === pendingPaymentId) - assert(pendingPayment2.head.paymentHash === spontaneousPayment.paymentHash) - assert(pendingPayment2.head.status === OutgoingPaymentStatus.Pending) + assert(pendingPayment2.length == 1) + assert(pendingPayment2.head.id == pendingPayment2.head.parentId) + assert(pendingPayment2.head.id == pendingPaymentId) + assert(pendingPayment2.head.paymentHash == spontaneousPayment.paymentHash) + assert(pendingPayment2.head.status == OutgoingPaymentStatus.Pending) // A third payment is fully settled in the DB and not being retried. val failedAt = TimestampMilli.now() @@ -540,11 +540,11 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I paymentInitiator.expectMsg(GetPayment(Left(failedPayment.parentId))) paymentInitiator.reply(PaymentIsPending(failedPayment.parentId, spontaneousPayment.paymentHash, PendingSpontaneousPayment(ActorRef.noSender, spontaneousPayment))) val pendingPayment3 = sender.expectMsgType[Seq[OutgoingPayment]] - assert(pendingPayment3.length === 2) - assert(pendingPayment3.head.id === failedPayment.parentId) - assert(pendingPayment3.head.paymentHash === failedPayment.paymentHash) - assert(pendingPayment3.head.status === OutgoingPaymentStatus.Pending) - assert(pendingPayment3.last === failedPayment) + assert(pendingPayment3.length == 2) + assert(pendingPayment3.head.id == failedPayment.parentId) + assert(pendingPayment3.head.paymentHash == failedPayment.paymentHash) + assert(pendingPayment3.head.status == OutgoingPaymentStatus.Pending) + assert(pendingPayment3.last == failedPayment) } test("close channels") { f => @@ -563,7 +563,7 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I register.reply(RES_SUCCESS(c2.message, c2.channelId)) register.expectNoMessage() - assert(sender.expectMsgType[Map[ChannelIdentifier, Either[Throwable, CommandResponse[CMD_CLOSE]]]] === Map( + assert(sender.expectMsgType[Map[ChannelIdentifier, Either[Throwable, CommandResponse[CMD_CLOSE]]]] == Map( Left(a) -> Right(RES_SUCCESS(CMD_CLOSE(ActorRef.noSender, None, None), a)), Left(b) -> Right(RES_SUCCESS(CMD_CLOSE(ActorRef.noSender, None, None), b)) )) @@ -600,7 +600,7 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I register.reply(Register.ForwardFailure(u3)) register.expectNoMessage() - assert(sender.expectMsgType[Map[ChannelIdentifier, Either[Throwable, CommandResponse[CMD_UPDATE_RELAY_FEE]]]] === Map( + assert(sender.expectMsgType[Map[ChannelIdentifier, Either[Throwable, CommandResponse[CMD_UPDATE_RELAY_FEE]]]] == Map( Left(a1) -> Right(RES_SUCCESS(CMD_UPDATE_RELAY_FEE(ActorRef.noSender, 999 msat, 1234, None), a1)), Left(a2) -> Right(RES_FAILURE(CMD_UPDATE_RELAY_FEE(ActorRef.noSender, 999 msat, 1234, None), CommandUnavailableInThisState(a2, "CMD_UPDATE_RELAY_FEE", channel.CLOSING))), Left(b1) -> Left(ChannelNotFound(Left(b1))) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/FeaturesSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/FeaturesSpec.scala index 65c83af986..9efbe13c76 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/FeaturesSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/FeaturesSpec.scala @@ -114,8 +114,8 @@ class FeaturesSpec extends AnyFunSuite { for ((testCase, valid) <- testCases) { if (valid) { - assert(validateFeatureGraph(Features(testCase)) === None) - assert(validateFeatureGraph(Features(testCase.bytes)) === None) + assert(validateFeatureGraph(Features(testCase)) == None) + assert(validateFeatureGraph(Features(testCase.bytes)) == None) } else { assert(validateFeatureGraph(Features(testCase)).nonEmpty) assert(validateFeatureGraph(Features(testCase.bytes)).nonEmpty) @@ -220,9 +220,9 @@ class FeaturesSpec extends AnyFunSuite { ) for (testCase <- testCases) { - assert(areCompatible(testCase.ours, testCase.theirs) === testCase.compatible, testCase) - assert(testCase.ours.areSupported(testCase.theirs) === testCase.oursSupportTheirs, testCase) - assert(testCase.theirs.areSupported(testCase.ours) === testCase.theirsSupportOurs, testCase) + assert(areCompatible(testCase.ours, testCase.theirs) == testCase.compatible, testCase) + assert(testCase.ours.areSupported(testCase.theirs) == testCase.oursSupportTheirs, testCase) + assert(testCase.theirs.areSupported(testCase.ours) == testCase.theirsSupportOurs, testCase) } } @@ -231,15 +231,15 @@ class FeaturesSpec extends AnyFunSuite { Map(DataLossProtect -> Optional, InitialRoutingSync -> Optional, VariableLengthOnion -> Mandatory, PaymentMetadata -> Optional), Set(UnknownFeature(753), UnknownFeature(852), UnknownFeature(65303)) ) - assert(features.initFeatures() === Features( + assert(features.initFeatures() == Features( Map(DataLossProtect -> Optional, InitialRoutingSync -> Optional, VariableLengthOnion -> Mandatory), Set(UnknownFeature(753), UnknownFeature(852), UnknownFeature(65303)) )) - assert(features.nodeAnnouncementFeatures() === Features( + assert(features.nodeAnnouncementFeatures() == Features( Map(DataLossProtect -> Optional, VariableLengthOnion -> Mandatory), Set(UnknownFeature(753), UnknownFeature(852), UnknownFeature(65303)) )) - assert(features.invoiceFeatures() === Features( + assert(features.invoiceFeatures() == Features( Map(VariableLengthOnion -> Mandatory, PaymentMetadata -> Optional), Set(UnknownFeature(753), UnknownFeature(852), UnknownFeature(65303)) )) @@ -255,11 +255,11 @@ class FeaturesSpec extends AnyFunSuite { ) for ((bin, features) <- testCases) { - assert(features.toByteVector === bin) - assert(Features(bin) === features) + assert(features.toByteVector == bin) + assert(Features(bin) == features) val notMinimallyEncoded = Features(hex"00" ++ bin) - assert(notMinimallyEncoded === features) - assert(notMinimallyEncoded.toByteVector === bin) // features are minimally-encoded when converting to bytes + assert(notMinimallyEncoded == features) + assert(notMinimallyEncoded.toByteVector == bin) // features are minimally-encoded when converting to bytes } } @@ -277,9 +277,9 @@ class FeaturesSpec extends AnyFunSuite { """) val features = fromConfiguration(conf) - assert(features.toByteVector === hex"028a8a") - assert(Features(hex"028a8a") === features) - assert(validateFeatureGraph(features) === None) + assert(features.toByteVector == hex"028a8a") + assert(Features(hex"028a8a") == features) + assert(validateFeatureGraph(features) == None) assert(features.hasFeature(DataLossProtect, Some(Optional))) assert(features.hasFeature(InitialRoutingSync, Some(Optional))) assert(features.hasFeature(ChannelRangeQueries, Some(Optional))) @@ -300,9 +300,9 @@ class FeaturesSpec extends AnyFunSuite { """) val features = fromConfiguration(conf) - assert(features.toByteVector === hex"068a") - assert(Features(hex"068a") === features) - assert(validateFeatureGraph(features) === None) + assert(features.toByteVector == hex"068a") + assert(Features(hex"068a") == features) + assert(validateFeatureGraph(features) == None) assert(features.hasFeature(DataLossProtect, Some(Optional))) assert(features.hasFeature(InitialRoutingSync, Some(Optional))) assert(!features.hasFeature(InitialRoutingSync, Some(Mandatory))) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/MilliSatoshiSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/MilliSatoshiSpec.scala index 09c7f76e1c..6b2133becc 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/MilliSatoshiSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/MilliSatoshiSpec.scala @@ -27,26 +27,26 @@ class MilliSatoshiSpec extends AnyFunSuite { test("millisatoshi numeric operations") { // add - assert(MilliSatoshi(561) + 0.msat === MilliSatoshi(561)) - assert(MilliSatoshi(561) + 0.sat === MilliSatoshi(561)) - assert(MilliSatoshi(561) + 1105.msat === MilliSatoshi(1666)) - assert(MilliSatoshi(2000) + 3.sat === MilliSatoshi(5000)) + assert(MilliSatoshi(561) + 0.msat == MilliSatoshi(561)) + assert(MilliSatoshi(561) + 0.sat == MilliSatoshi(561)) + assert(MilliSatoshi(561) + 1105.msat == MilliSatoshi(1666)) + assert(MilliSatoshi(2000) + 3.sat == MilliSatoshi(5000)) // subtract - assert(MilliSatoshi(561) - 0.msat === MilliSatoshi(561)) - assert(MilliSatoshi(1105) - 561.msat === MilliSatoshi(544)) - assert(561.msat - 1105.msat === -MilliSatoshi(544)) - assert(MilliSatoshi(561) - 1105.msat === -MilliSatoshi(544)) - assert(MilliSatoshi(1105) - 1.sat === MilliSatoshi(105)) + assert(MilliSatoshi(561) - 0.msat == MilliSatoshi(561)) + assert(MilliSatoshi(1105) - 561.msat == MilliSatoshi(544)) + assert(561.msat - 1105.msat == -MilliSatoshi(544)) + assert(MilliSatoshi(561) - 1105.msat == -MilliSatoshi(544)) + assert(MilliSatoshi(1105) - 1.sat == MilliSatoshi(105)) // multiply - assert(MilliSatoshi(561) * 1 === 561.msat) - assert(MilliSatoshi(561) * 2 === 1122.msat) - assert(MilliSatoshi(561) * 2.5 === 1402.msat) + assert(MilliSatoshi(561) * 1 == 561.msat) + assert(MilliSatoshi(561) * 2 == 1122.msat) + assert(MilliSatoshi(561) * 2.5 == 1402.msat) // divide - assert(MilliSatoshi(561) / 1 === MilliSatoshi(561)) - assert(MilliSatoshi(561) / 2 === MilliSatoshi(280)) + assert(MilliSatoshi(561) / 1 == MilliSatoshi(561)) + assert(MilliSatoshi(561) / 2 == MilliSatoshi(280)) // compare assert(MilliSatoshi(561) <= MilliSatoshi(561)) @@ -63,16 +63,16 @@ class MilliSatoshiSpec extends AnyFunSuite { assert(MilliSatoshi(2000) > Satoshi(1)) // maxOf - assert((561 msat).max(1105 msat) === MilliSatoshi(1105)) - assert((1105 msat).max(1 sat) === MilliSatoshi(1105)) - assert((1105 msat).max(2 sat) === MilliSatoshi(2000)) - assert((1 sat).max(2 sat) === Satoshi(2)) + assert((561 msat).max(1105 msat) == MilliSatoshi(1105)) + assert((1105 msat).max(1 sat) == MilliSatoshi(1105)) + assert((1105 msat).max(2 sat) == MilliSatoshi(2000)) + assert((1 sat).max(2 sat) == Satoshi(2)) // minOf - assert((561 msat).min(1105 msat) === MilliSatoshi(561)) - assert((1105 msat).min(1 sat) === MilliSatoshi(1000)) - assert((1105 msat).min(2 sat) === MilliSatoshi(1105)) - assert((1 sat).min(2 sat) === Satoshi(1)) + assert((561 msat).min(1105 msat) == MilliSatoshi(561)) + assert((1105 msat).min(1 sat) == MilliSatoshi(1000)) + assert((1105 msat).min(2 sat) == MilliSatoshi(1105)) + assert((1 sat).min(2 sat) == Satoshi(1)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/PackageSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/PackageSpec.scala index ef19218dbb..9427149101 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/PackageSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/PackageSpec.scala @@ -41,7 +41,7 @@ class PackageSpec extends AnyFunSuite { (hex"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00F0", 0x0F00, hex"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0FF0") :: Nil) .map(x => (ByteVector32(x._1), x._2, ByteVector32(x._3))) - data.foreach(x => assert(toLongId(ByteVector32(x._1), x._2) === x._3)) + data.foreach(x => assert(toLongId(ByteVector32(x._1), x._2) == x._3)) } test("decode base58 addresses") { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/StartupSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/StartupSpec.scala index fb7a86121f..e4efaa0cec 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/StartupSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/StartupSpec.scala @@ -54,14 +54,14 @@ class StartupSpec extends AnyFunSuite { val threeBytesUTFChar = '\u20AC' // € val baseUkraineAlias = "BitcoinLightningNodeUkraine" - assert(baseUkraineAlias.length === 27) - assert(baseUkraineAlias.getBytes.length === 27) + assert(baseUkraineAlias.length == 27) + assert(baseUkraineAlias.getBytes.length == 27) // we add 2 UTF-8 chars, each is 3-bytes long -> total new length 33 bytes! val goUkraineGo = s"${threeBytesUTFChar}BitcoinLightningNodeUkraine$threeBytesUTFChar" - assert(goUkraineGo.length === 29) - assert(goUkraineGo.getBytes.length === 33) // too long for the alias, should be truncated + assert(goUkraineGo.length == 29) + assert(goUkraineGo.getBytes.length == 33) // too long for the alias, should be truncated val illegalAliasConf = ConfigFactory.parseString(s"node-alias = $goUkraineGo") val conf = illegalAliasConf.withFallback(defaultConf) @@ -182,7 +182,7 @@ class StartupSpec extends AnyFunSuite { val nodeParams = makeNodeParamsWithDefaults(perNodeConf.withFallback(defaultConf)) val perNodeFeatures = nodeParams.initFeaturesFor(PublicKey(ByteVector.fromValidHex("031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f"))) - assert(perNodeFeatures === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory, BasicMultiPartPayment -> Mandatory, ChannelType -> Optional)) + assert(perNodeFeatures == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory, BasicMultiPartPayment -> Mandatory, ChannelType -> Optional)) } test("reject non-init features in node override") { @@ -247,9 +247,9 @@ class StartupSpec extends AnyFunSuite { ) val nodeParams = makeNodeParamsWithDefaults(perNodeConf.withFallback(defaultConf)) - assert(nodeParams.onChainFeeConf.feerateToleranceFor(PublicKey(hex"031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f")) === FeerateTolerance(0.1, 15.0, FeeratePerKw(FeeratePerByte(15 sat)), DustTolerance(25_000 sat, closeOnUpdateFeeOverflow = true))) - assert(nodeParams.onChainFeeConf.feerateToleranceFor(PublicKey(hex"03462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b")) === FeerateTolerance(0.75, 5.0, FeeratePerKw(FeeratePerByte(5 sat)), DustTolerance(40_000 sat, closeOnUpdateFeeOverflow = false))) - assert(nodeParams.onChainFeeConf.feerateToleranceFor(PublicKey(hex"0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f7")) === FeerateTolerance(0.5, 10.0, FeeratePerKw(FeeratePerByte(10 sat)), DustTolerance(50_000 sat, closeOnUpdateFeeOverflow = false))) + assert(nodeParams.onChainFeeConf.feerateToleranceFor(PublicKey(hex"031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f")) == FeerateTolerance(0.1, 15.0, FeeratePerKw(FeeratePerByte(15 sat)), DustTolerance(25_000 sat, closeOnUpdateFeeOverflow = true))) + assert(nodeParams.onChainFeeConf.feerateToleranceFor(PublicKey(hex"03462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b")) == FeerateTolerance(0.75, 5.0, FeeratePerKw(FeeratePerByte(5 sat)), DustTolerance(40_000 sat, closeOnUpdateFeeOverflow = false))) + assert(nodeParams.onChainFeeConf.feerateToleranceFor(PublicKey(hex"0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f7")) == FeerateTolerance(0.5, 10.0, FeeratePerKw(FeeratePerByte(10 sat)), DustTolerance(50_000 sat, closeOnUpdateFeeOverflow = false))) } test("NodeParams should fail if htlc-minimum-msat is set to 0") { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/UInt64Spec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/UInt64Spec.scala index 54535ed515..d07caab268 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/UInt64Spec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/UInt64Spec.scala @@ -47,21 +47,21 @@ class UInt64Spec extends AnyFunSuite { assert(l1.toString == "9223372036854775808") assert(l1.toBigInt == BigInt("9223372036854775808")) - assert(a.toByteVector === hex"ffffffffffffffff") - assert(a.toString === "18446744073709551615") // 2^64 - 1 - assert(a.toBigInt === BigInt("18446744073709551615")) + assert(a.toByteVector == hex"ffffffffffffffff") + assert(a.toString == "18446744073709551615") // 2^64 - 1 + assert(a.toBigInt == BigInt("18446744073709551615")) - assert(b.toByteVector === hex"fffffffffffffffe") - assert(b.toString === "18446744073709551614") - assert(b.toBigInt === BigInt("18446744073709551614")) + assert(b.toByteVector == hex"fffffffffffffffe") + assert(b.toString == "18446744073709551614") + assert(b.toBigInt == BigInt("18446744073709551614")) - assert(c.toByteVector === hex"00000000000002a") - assert(c.toString === "42") - assert(c.toBigInt === BigInt("42")) + assert(c.toByteVector == hex"00000000000002a") + assert(c.toString == "42") + assert(c.toBigInt == BigInt("42")) - assert(z.toByteVector === hex"000000000000000") - assert(z.toString === "0") - assert(z.toBigInt === BigInt("0")) + assert(z.toByteVector == hex"000000000000000") + assert(z.toString == "0") + assert(z.toBigInt == BigInt("0")) assert(UInt64(hex"ff").toByteVector == hex"0000000000000ff") assert(UInt64(hex"800").toByteVector == hex"000000000000800") diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/balance/CheckBalanceSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/balance/CheckBalanceSpec.scala index a7c8305da9..a16d0e9e38 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/balance/CheckBalanceSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/balance/CheckBalanceSpec.scala @@ -47,7 +47,7 @@ class CheckBalanceSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with addHtlc(10_000_000 msat, alice, bob, alice2bob, bob2alice) crossSign(alice, bob, alice2bob, bob2alice) - assert(CheckBalance.computeOffChainBalance(Seq(alice.stateData.asInstanceOf[DATA_NORMAL]), knownPreimages = Set.empty).normal === + assert(CheckBalance.computeOffChainBalance(Seq(alice.stateData.asInstanceOf[DATA_NORMAL]), knownPreimages = Set.empty).normal == MainAndHtlcBalance( toLocal = (TestConstants.fundingSatoshis - TestConstants.pushMsat - 30_000_000.msat).truncateToSatoshi, htlcs = 30_000.sat @@ -64,7 +64,7 @@ class CheckBalanceSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob ! CMD_SIGN() bob2alice.expectMsgType[CommitSig] - assert(CheckBalance.computeOffChainBalance(Seq(bob.stateData.asInstanceOf[DATA_NORMAL]), knownPreimages = Set.empty).normal === + assert(CheckBalance.computeOffChainBalance(Seq(bob.stateData.asInstanceOf[DATA_NORMAL]), knownPreimages = Set.empty).normal == MainAndHtlcBalance( toLocal = TestConstants.pushMsat.truncateToSatoshi, htlcs = htlc.amountMsat.truncateToSatoshi @@ -97,7 +97,7 @@ class CheckBalanceSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val commitments = alice.stateData.asInstanceOf[DATA_CLOSING].commitments val remoteCommitPublished = alice.stateData.asInstanceOf[DATA_CLOSING].remoteCommitPublished.get val knownPreimages = Set((commitments.channelId, htlcb1.id)) - assert(CheckBalance.computeRemoteCloseBalance(commitments, CurrentRemoteClose(commitments.remoteCommit, remoteCommitPublished), knownPreimages) === + assert(CheckBalance.computeRemoteCloseBalance(commitments, CurrentRemoteClose(commitments.remoteCommit, remoteCommitPublished), knownPreimages) == PossiblyPublishedMainAndHtlcBalance( toLocal = Map(remoteCommitPublished.claimMainOutputTx.get.tx.txid -> remoteCommitPublished.claimMainOutputTx.get.tx.txOut.head.amount), htlcs = claimHtlcTxs.map(claimTx => claimTx.txid -> claimTx.txOut.head.amount.toBtc).toMap, @@ -105,7 +105,7 @@ class CheckBalanceSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with )) // assuming alice gets the preimage for the 2nd htlc val knownPreimages1 = Set((commitments.channelId, htlcb1.id), (commitments.channelId, htlcb2.id)) - assert(CheckBalance.computeRemoteCloseBalance(commitments, CurrentRemoteClose(commitments.remoteCommit, remoteCommitPublished), knownPreimages1) === + assert(CheckBalance.computeRemoteCloseBalance(commitments, CurrentRemoteClose(commitments.remoteCommit, remoteCommitPublished), knownPreimages1) == PossiblyPublishedMainAndHtlcBalance( toLocal = Map(remoteCommitPublished.claimMainOutputTx.get.tx.txid -> remoteCommitPublished.claimMainOutputTx.get.tx.txOut.head.amount), htlcs = claimHtlcTxs.map(claimTx => claimTx.txid -> claimTx.txOut.head.amount.toBtc).toMap, @@ -146,7 +146,7 @@ class CheckBalanceSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val remoteCommitPublished = alice.stateData.asInstanceOf[DATA_CLOSING].nextRemoteCommitPublished.get val knownPreimages = Set((commitments.channelId, htlcb1.id)) val Left(waitingForRevocation) = commitments.remoteNextCommitInfo - assert(CheckBalance.computeRemoteCloseBalance(commitments, CurrentRemoteClose(waitingForRevocation.nextRemoteCommit, remoteCommitPublished), knownPreimages) === + assert(CheckBalance.computeRemoteCloseBalance(commitments, CurrentRemoteClose(waitingForRevocation.nextRemoteCommit, remoteCommitPublished), knownPreimages) == PossiblyPublishedMainAndHtlcBalance( toLocal = Map(remoteCommitPublished.claimMainOutputTx.get.tx.txid -> remoteCommitPublished.claimMainOutputTx.get.tx.txOut.head.amount), htlcs = claimHtlcTxs.map(claimTx => claimTx.txid -> claimTx.txOut.head.amount.toBtc).toMap, @@ -154,7 +154,7 @@ class CheckBalanceSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with )) // assuming alice gets the preimage for the 2nd htlc val knownPreimages1 = Set((commitments.channelId, htlcb1.id), (commitments.channelId, htlcb2.id)) - assert(CheckBalance.computeRemoteCloseBalance(commitments, CurrentRemoteClose(waitingForRevocation.nextRemoteCommit, remoteCommitPublished), knownPreimages1) === + assert(CheckBalance.computeRemoteCloseBalance(commitments, CurrentRemoteClose(waitingForRevocation.nextRemoteCommit, remoteCommitPublished), knownPreimages1) == PossiblyPublishedMainAndHtlcBalance( toLocal = Map(remoteCommitPublished.claimMainOutputTx.get.tx.txid -> remoteCommitPublished.claimMainOutputTx.get.tx.txOut.head.amount), htlcs = claimHtlcTxs.map(claimTx => claimTx.txid -> claimTx.txOut.head.amount.toBtc).toMap, @@ -179,14 +179,14 @@ class CheckBalanceSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // alice publishes her commit tx val aliceCommitTx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! Error(ByteVector32.Zeroes, "oops") - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) assert(aliceCommitTx.txOut.size == 6) // two main outputs and 4 pending htlcs awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.isDefined) val commitments = alice.stateData.asInstanceOf[DATA_CLOSING].commitments val localCommitPublished = alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get val knownPreimages = Set((commitments.channelId, htlcb1.id)) - assert(CheckBalance.computeLocalCloseBalance(commitments, LocalClose(commitments.localCommit, localCommitPublished), knownPreimages) === + assert(CheckBalance.computeLocalCloseBalance(commitments, LocalClose(commitments.localCommit, localCommitPublished), knownPreimages) == PossiblyPublishedMainAndHtlcBalance( toLocal = Map(localCommitPublished.claimMainDelayedOutputTx.get.tx.txid -> localCommitPublished.claimMainDelayedOutputTx.get.tx.txOut.head.amount), htlcs = Map.empty, @@ -207,15 +207,15 @@ class CheckBalanceSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // 3rd-stage txs are published when htlc txs confirm val claimHtlcDelayedTxs = Seq(htlcTx1, htlcTx2, htlcTx3).map { htlcTimeoutTx => alice ! WatchOutputSpentTriggered(htlcTimeoutTx) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === htlcTimeoutTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == htlcTimeoutTx.txid) alice ! WatchTxConfirmedTriggered(BlockHeight(2701), 3, htlcTimeoutTx) val claimHtlcDelayedTx = alice2blockchain.expectMsgType[PublishFinalTx].tx - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimHtlcDelayedTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimHtlcDelayedTx.txid) claimHtlcDelayedTx } awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.claimHtlcDelayedTxs.length == 3) - assert(CheckBalance.computeLocalCloseBalance(commitments, LocalClose(commitments.localCommit, alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get), knownPreimages) === + assert(CheckBalance.computeLocalCloseBalance(commitments, LocalClose(commitments.localCommit, alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get), knownPreimages) == PossiblyPublishedMainAndHtlcBalance( toLocal = Map(localCommitPublished.claimMainDelayedOutputTx.get.tx.txid -> localCommitPublished.claimMainDelayedOutputTx.get.tx.txOut.head.amount), htlcs = claimHtlcDelayedTxs.map(claimTx => claimTx.txid -> claimTx.txOut.head.amount.toBtc).toMap, diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/BitcoinCoreClientSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/BitcoinCoreClientSpec.scala index fa53885f6e..c37464d932 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/BitcoinCoreClientSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/BitcoinCoreClientSpec.scala @@ -85,12 +85,12 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A assert(fundTxResponse.amountIn > 0.sat) assert(fundTxResponse.fee > 0.sat) fundTxResponse.tx.txIn.foreach(txIn => assert(txIn.signatureScript.isEmpty && txIn.witness.isNull)) - fundTxResponse.tx.txIn.foreach(txIn => assert(txIn.sequence === bitcoin.TxIn.SEQUENCE_FINAL - 2)) + fundTxResponse.tx.txIn.foreach(txIn => assert(txIn.sequence == bitcoin.TxIn.SEQUENCE_FINAL - 2)) bitcoinClient.signTransaction(fundTxResponse.tx, Nil).pipeTo(sender.ref) val signTxResponse = sender.expectMsgType[SignTransactionResponse] assert(signTxResponse.complete) - assert(signTxResponse.tx.txOut.size === 2) + assert(signTxResponse.tx.txOut.size == 2) bitcoinClient.publishTransaction(signTxResponse.tx).pipeTo(sender.ref) sender.expectMsg(signTxResponse.tx.txid) @@ -123,11 +123,11 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A val txManyOutputs = Transaction(2, Nil, TxOut(410000 sat, Script.pay2wpkh(randomKey().publicKey)) :: TxOut(230000 sat, Script.pay2wpkh(randomKey().publicKey)) :: Nil, 0) bitcoinClient.fundTransaction(txManyOutputs, FundTransactionOptions(TestConstants.feeratePerKw, replaceable = false, changePosition = Some(1))).pipeTo(sender.ref) val fundTxResponse = sender.expectMsgType[FundTransactionResponse] - assert(fundTxResponse.tx.txOut.size === 3) - assert(fundTxResponse.changePosition === Some(1)) + assert(fundTxResponse.tx.txOut.size == 3) + assert(fundTxResponse.changePosition == Some(1)) assert(!Set(230000 sat, 410000 sat).contains(fundTxResponse.tx.txOut(1).amount)) - assert(Set(230000 sat, 410000 sat) === Set(fundTxResponse.tx.txOut.head.amount, fundTxResponse.tx.txOut.last.amount)) - fundTxResponse.tx.txIn.foreach(txIn => assert(txIn.sequence === bitcoin.TxIn.SEQUENCE_FINAL - 1)) + assert(Set(230000 sat, 410000 sat) == Set(fundTxResponse.tx.txOut.head.amount, fundTxResponse.tx.txOut.last.amount)) + fundTxResponse.tx.txIn.foreach(txIn => assert(txIn.sequence == bitcoin.TxIn.SEQUENCE_FINAL - 1)) } } @@ -149,11 +149,11 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A val sender = TestProbe() val bitcoinClient = new BitcoinCoreClient(rpcClient) bitcoinClient.onChainBalance().pipeTo(sender.ref) - assert(sender.expectMsgType[OnChainBalance] === OnChainBalance(Satoshi(satoshi), Satoshi(satoshi))) + assert(sender.expectMsgType[OnChainBalance] == OnChainBalance(Satoshi(satoshi), Satoshi(satoshi))) bitcoinClient.fundTransaction(txIn, FundTransactionOptions(FeeratePerKw(250 sat))).pipeTo(sender.ref) val fundTxResponse = sender.expectMsgType[FundTransactionResponse] - assert(fundTxResponse.fee === Satoshi(satoshi)) + assert(fundTxResponse.fee == Satoshi(satoshi)) } } @@ -182,7 +182,7 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A sender.expectMsgType[MakeFundingTxResponse].fundingTx } - assert(getLocks(sender).size === 4) + assert(getLocks(sender).size == 4) bitcoinClient.commit(fundingTxs(0)).pipeTo(sender.ref) assert(sender.expectMsgType[Boolean]) @@ -294,9 +294,9 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A // tx2 replaced tx1 in the mempool bitcoinClient.getMempool().pipeTo(sender.ref) val mempoolTxs = sender.expectMsgType[Seq[Transaction]] - assert(mempoolTxs.length === 1) - assert(mempoolTxs.head.txid === tx2.txid) - assert(tx2.txIn.map(_.outPoint).intersect(tx1.txIn.map(_.outPoint)).length === 1) + assert(mempoolTxs.length == 1) + assert(mempoolTxs.head.txid == tx2.txid) + assert(tx2.txIn.map(_.outPoint).intersect(tx1.txIn.map(_.outPoint)).length == 1) } test("unlock transaction inputs if publishing fails") { @@ -540,7 +540,7 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A bitcoinClient.onChainBalance().pipeTo(sender.ref) val initialBalance = sender.expectMsgType[OnChainBalance] - assert(initialBalance.unconfirmed === 0.sat) + assert(initialBalance.unconfirmed == 0.sat) assert(initialBalance.confirmed > 50.btc.toSatoshi) val address = "n2YKngjUp139nkjKvZGnfLRN6HzzYxJsje" @@ -550,10 +550,10 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A bitcoinClient.listTransactions(25, 0).pipeTo(sender.ref) val Some(tx1) = sender.expectMsgType[List[WalletTx]].collectFirst { case tx if tx.txid == txid => tx } - assert(tx1.address === address) - assert(tx1.amount === -amount) + assert(tx1.address == address) + assert(tx1.amount == -amount) assert(tx1.fees < 0.sat) - assert(tx1.confirmations === 0) + assert(tx1.confirmations == 0) bitcoinClient.onChainBalance().pipeTo(sender.ref) // NB: we use + because these amounts are already negative @@ -562,10 +562,10 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A generateBlocks(1) bitcoinClient.listTransactions(25, 0).pipeTo(sender.ref) val Some(tx2) = sender.expectMsgType[List[WalletTx]].collectFirst { case tx if tx.txid == txid => tx } - assert(tx2.address === address) - assert(tx2.amount === -amount) + assert(tx2.address == address) + assert(tx2.amount == -amount) assert(tx2.fees < 0.sat) - assert(tx2.confirmations === 1) + assert(tx2.confirmations == 1) } test("get mempool transaction") { @@ -591,26 +591,26 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A bitcoinClient.getMempoolTx(tx1.txid).pipeTo(sender.ref) val mempoolTx1 = sender.expectMsgType[MempoolTx] - assert(mempoolTx1.ancestorCount === 0) - assert(mempoolTx1.descendantCount === 2) - assert(mempoolTx1.fees === mempoolTx1.ancestorFees) - assert(mempoolTx1.descendantFees === mempoolTx1.fees + 12500.sat) + assert(mempoolTx1.ancestorCount == 0) + assert(mempoolTx1.descendantCount == 2) + assert(mempoolTx1.fees == mempoolTx1.ancestorFees) + assert(mempoolTx1.descendantFees == mempoolTx1.fees + 12500.sat) bitcoinClient.getMempoolTx(tx2.txid).pipeTo(sender.ref) val mempoolTx2 = sender.expectMsgType[MempoolTx] - assert(mempoolTx2.ancestorCount === 1) - assert(mempoolTx2.descendantCount === 1) - assert(mempoolTx2.fees === 5000.sat) - assert(mempoolTx2.descendantFees === 12500.sat) - assert(mempoolTx2.ancestorFees === mempoolTx1.fees + 5000.sat) + assert(mempoolTx2.ancestorCount == 1) + assert(mempoolTx2.descendantCount == 1) + assert(mempoolTx2.fees == 5000.sat) + assert(mempoolTx2.descendantFees == 12500.sat) + assert(mempoolTx2.ancestorFees == mempoolTx1.fees + 5000.sat) bitcoinClient.getMempoolTx(tx3.txid).pipeTo(sender.ref) val mempoolTx3 = sender.expectMsgType[MempoolTx] - assert(mempoolTx3.ancestorCount === 2) - assert(mempoolTx3.descendantCount === 0) - assert(mempoolTx3.fees === 7500.sat) - assert(mempoolTx3.descendantFees === mempoolTx3.fees) - assert(mempoolTx3.ancestorFees === mempoolTx1.fees + 12500.sat) + assert(mempoolTx3.ancestorCount == 2) + assert(mempoolTx3.descendantCount == 0) + assert(mempoolTx3.fees == 7500.sat) + assert(mempoolTx3.descendantFees == mempoolTx3.fees) + assert(mempoolTx3.ancestorFees == mempoolTx1.fees + 12500.sat) } test("abandon transaction") { @@ -781,7 +781,7 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A generateBlocks(1) bitcoinClient.getBlockHeight().pipeTo(sender.ref) val blockHeight1 = sender.expectMsgType[BlockHeight] - assert(blockHeight1 === blockHeight + 1) + assert(blockHeight1 == blockHeight + 1) bitcoinClient.getTxConfirmations(tx1.txid).pipeTo(sender.ref) sender.expectMsg(Some(1)) bitcoinClient.isTransactionOutputSpendable(tx1.txid, 0, includeMempool = false).pipeTo(sender.ref) @@ -803,7 +803,7 @@ class BitcoinCoreClientSpec extends TestKitBaseClass with BitcoindService with A bitcoinClient.getReceivePubkey(receiveAddress = Some(address)).pipeTo(sender.ref) val receiveKey = sender.expectMsgType[PublicKey] - assert(addressToPublicKeyScript(address, Block.RegtestGenesisBlock.hash) === Script.pay2wpkh(receiveKey)) + assert(addressToPublicKeyScript(address, Block.RegtestGenesisBlock.hash) == Script.pay2wpkh(receiveKey)) } } \ No newline at end of file diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/ZmqWatcherSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/ZmqWatcherSpec.scala index ff42206b52..b521692e20 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/ZmqWatcherSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/ZmqWatcherSpec.scala @@ -95,7 +95,7 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind restartBitcoind(probe) generateBlocks(1) val block2 = listener.expectMsgType[CurrentBlockHeight] - assert(block2.blockHeight === block1.blockHeight + 1) + assert(block2.blockHeight == block1.blockHeight + 1) listener.expectNoMessage(100 millis) }) } @@ -141,17 +141,17 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind // When the watcher starts, it broadcasts the current height. val block1 = listener.expectMsgType[CurrentBlockHeight] - assert(blockHeight.get() === block1.blockHeight.toLong) + assert(blockHeight.get() == block1.blockHeight.toLong) listener.expectNoMessage(100 millis) generateBlocks(1) - assert(listener.expectMsgType[CurrentBlockHeight].blockHeight === block1.blockHeight + 1) - assert(blockHeight.get() === block1.blockHeight.toLong + 1) + assert(listener.expectMsgType[CurrentBlockHeight].blockHeight == block1.blockHeight + 1) + assert(blockHeight.get() == block1.blockHeight.toLong + 1) listener.expectNoMessage(100 millis) generateBlocks(5) - assert(listener.expectMsgType[CurrentBlockHeight].blockHeight === block1.blockHeight + 6) - assert(blockHeight.get() === block1.blockHeight.toLong + 6) + assert(listener.expectMsgType[CurrentBlockHeight].blockHeight == block1.blockHeight + 6) + assert(blockHeight.get() == block1.blockHeight.toLong + 6) listener.expectNoMessage(100 millis) }) } @@ -170,17 +170,17 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind listener.expectNoMessage(1 second) watcher ! ListWatches(listener.ref) - assert(listener.expectMsgType[Set[Watch[_]]].size === 2) + assert(listener.expectMsgType[Set[Watch[_]]].size == 2) generateBlocks(1) - assert(listener.expectMsgType[WatchFundingConfirmedTriggered].tx.txid === tx.txid) + assert(listener.expectMsgType[WatchFundingConfirmedTriggered].tx.txid == tx.txid) listener.expectNoMessage(1 second) watcher ! ListWatches(listener.ref) - assert(listener.expectMsgType[Set[Watch[_]]].size === 1) + assert(listener.expectMsgType[Set[Watch[_]]].size == 1) generateBlocks(3) - assert(listener.expectMsgType[WatchFundingDeeplyBuriedTriggered].tx.txid === tx.txid) + assert(listener.expectMsgType[WatchFundingDeeplyBuriedTriggered].tx.txid == tx.txid) listener.expectNoMessage(1 second) watcher ! ListWatches(listener.ref) @@ -188,11 +188,11 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind // If we try to watch a transaction that has already been confirmed, we should immediately receive a WatchEventConfirmed. watcher ! WatchFundingConfirmed(listener.ref, tx.txid, 1) - assert(listener.expectMsgType[WatchFundingConfirmedTriggered].tx.txid === tx.txid) + assert(listener.expectMsgType[WatchFundingConfirmedTriggered].tx.txid == tx.txid) watcher ! WatchFundingConfirmed(listener.ref, tx.txid, 2) - assert(listener.expectMsgType[WatchFundingConfirmedTriggered].tx.txid === tx.txid) + assert(listener.expectMsgType[WatchFundingConfirmedTriggered].tx.txid == tx.txid) watcher ! WatchFundingDeeplyBuried(listener.ref, tx.txid, 4) - assert(listener.expectMsgType[WatchFundingDeeplyBuriedTriggered].tx.txid === tx.txid) + assert(listener.expectMsgType[WatchFundingDeeplyBuriedTriggered].tx.txid == tx.txid) listener.expectNoMessage(1 second) watcher ! ListWatches(listener.ref) @@ -215,7 +215,7 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind listener.expectNoMessage(1 second) watcher ! ListWatches(listener.ref) - assert(listener.expectMsgType[Set[Watch[_]]].size === 2) + assert(listener.expectMsgType[Set[Watch[_]]].size == 2) bitcoinClient.publishTransaction(tx1).pipeTo(probe.ref) probe.expectMsg(tx1.txid) @@ -234,7 +234,7 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind watcher ! ListWatches(listener.ref) val watches1 = listener.expectMsgType[Set[Watch[_]]] - assert(watches1.size === 1) + assert(watches1.size == 1) assert(watches1.forall(_.isInstanceOf[WatchFundingSpent])) // Let's submit tx2, and set a watch after it has been confirmed this time. @@ -248,7 +248,7 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind watcher ! ListWatches(listener.ref) val watches2 = listener.expectMsgType[Set[Watch[_]]] - assert(watches2.size === 1) + assert(watches2.size == 1) assert(watches2.forall(_.isInstanceOf[WatchFundingSpent])) watcher ! StopWatching(listener.ref) @@ -302,7 +302,7 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind generateBlocks(1) probe.expectMsg(WatchFundingSpentTriggered(tx2)) // tx2 is confirmed which triggers WatchEventSpent again generateBlocks(1) - assert(probe.expectMsgType[WatchFundingConfirmedTriggered].tx === tx1) // tx1 now has 3 confirmations + assert(probe.expectMsgType[WatchFundingConfirmedTriggered].tx == tx1) // tx1 now has 3 confirmations }) } @@ -350,7 +350,7 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind watcher ! WatchOutputSpent(actor1.ref, txid, 1, Set.empty) watcher ! ListWatches(actor1.ref) val watches1 = actor1.expectMsgType[Set[Watch[_]]] - assert(watches1.size === 6) + assert(watches1.size == 6) watcher ! WatchFundingConfirmed(actor2.ref, txid, 2) watcher ! WatchFundingDeeplyBuried(actor2.ref, txid, 3) @@ -359,7 +359,7 @@ class ZmqWatcherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoind watcher ! WatchOutputSpent(actor2.ref, txid, 1, Set.empty) watcher ! ListWatches(actor2.ref) val watches2 = actor2.expectMsgType[Set[Watch[_]]] - assert(watches2.size === 11) + assert(watches2.size == 11) assert(watches1.forall(w => watches2.contains(w))) watcher ! StopWatching(actor2.ref) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/BitcoinCoreFeeProviderSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/BitcoinCoreFeeProviderSpec.scala index 732f7abe76..090519e9b4 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/BitcoinCoreFeeProviderSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/BitcoinCoreFeeProviderSpec.scala @@ -117,7 +117,7 @@ class BitcoinCoreFeeProviderSpec extends TestKitBaseClass with BitcoindService w regtestProvider.mempoolMinFee().pipeTo(sender.ref) val mempoolMinFee = sender.expectMsgType[FeeratePerKB] // The regtest provider doesn't have any transaction in its mempool, so it defaults to the min_relay_fee. - assert(mempoolMinFee.feerate.toLong === FeeratePerKw.MinimumRelayFeeRate) + assert(mempoolMinFee.feerate.toLong == FeeratePerKw.MinimumRelayFeeRate) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FallbackFeeProviderSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FallbackFeeProviderSpec.scala index 4969ddcb19..0112b2ecf9 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FallbackFeeProviderSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FallbackFeeProviderSpec.scala @@ -55,19 +55,19 @@ class FallbackFeeProviderSpec extends AnyFunSuite { val fallbackFeeProvider = new FallbackFeeProvider(provider0 :: provider1 :: provider3 :: provider5 :: provider7 :: Nil, FeeratePerByte(1 sat)) - assert(await(fallbackFeeProvider.getFeerates) === provider1.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider1.feeratesPerKB) - assert(await(fallbackFeeProvider.getFeerates) === provider3.feeratesPerKB) - assert(await(fallbackFeeProvider.getFeerates) === provider3.feeratesPerKB) - assert(await(fallbackFeeProvider.getFeerates) === provider3.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider3.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider3.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider3.feeratesPerKB) - assert(await(fallbackFeeProvider.getFeerates) === provider5.feeratesPerKB) - assert(await(fallbackFeeProvider.getFeerates) === provider5.feeratesPerKB) - assert(await(fallbackFeeProvider.getFeerates) === provider5.feeratesPerKB) - assert(await(fallbackFeeProvider.getFeerates) === provider5.feeratesPerKB) - assert(await(fallbackFeeProvider.getFeerates) === provider5.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider5.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider5.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider5.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider5.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider5.feeratesPerKB) - assert(await(fallbackFeeProvider.getFeerates) === provider7.feeratesPerKB) + assert(await(fallbackFeeProvider.getFeerates) == provider7.feeratesPerKB) } test("ensure minimum feerate") { @@ -75,7 +75,7 @@ class FallbackFeeProviderSpec extends AnyFunSuite { val minFeeratePerByte = FeeratePerByte(2 sat) val minFeeratePerKB = FeeratePerKB(minFeeratePerByte) val fallbackFeeProvider = new FallbackFeeProvider(constantFeeProvider :: Nil, minFeeratePerByte) - assert(await(fallbackFeeProvider.getFeerates) === FeeratesPerKB(FeeratePerKB(64000 sat), FeeratePerKB(32000 sat), FeeratePerKB(16000 sat), FeeratePerKB(8000 sat), FeeratePerKB(4000 sat), minFeeratePerKB, minFeeratePerKB, minFeeratePerKB, minFeeratePerKB)) + assert(await(fallbackFeeProvider.getFeerates) == FeeratesPerKB(FeeratePerKB(64000 sat), FeeratePerKB(32000 sat), FeeratePerKB(16000 sat), FeeratePerKB(8000 sat), FeeratePerKB(4000 sat), minFeeratePerKB, minFeeratePerKB, minFeeratePerKB, minFeeratePerKB)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FeeEstimatorSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FeeEstimatorSpec.scala index 9ab3f7380a..3e0567eb4a 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FeeEstimatorSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FeeEstimatorSpec.scala @@ -41,10 +41,10 @@ class FeeEstimatorSpec extends AnyFunSuite { val feeConf = OnChainFeeConf(FeeTargets(1, 2, 6, 1, 1, 1), feeEstimator, closeOnOfflineMismatch = true, updateFeeMinDiffRatio = 0.1, defaultFeerateTolerance, Map.empty) feeEstimator.setFeerate(FeeratesPerKw.single(FeeratePerKw(10000 sat)).copy(blocks_2 = FeeratePerKw(5000 sat))) - assert(feeConf.getCommitmentFeerate(randomKey().publicKey, channelType, 100000 sat, None) === FeeratePerKw(5000 sat)) + assert(feeConf.getCommitmentFeerate(randomKey().publicKey, channelType, 100000 sat, None) == FeeratePerKw(5000 sat)) val currentFeerates = CurrentFeerates(FeeratesPerKw.single(FeeratePerKw(10000 sat)).copy(blocks_2 = FeeratePerKw(4000 sat))) - assert(feeConf.getCommitmentFeerate(randomKey().publicKey, channelType, 100000 sat, Some(currentFeerates)) === FeeratePerKw(4000 sat)) + assert(feeConf.getCommitmentFeerate(randomKey().publicKey, channelType, 100000 sat, Some(currentFeerates)) == FeeratePerKw(4000 sat)) } test("get commitment feerate (anchor outputs)") { @@ -56,35 +56,35 @@ class FeeEstimatorSpec extends AnyFunSuite { val feeConf = OnChainFeeConf(FeeTargets(1, 2, 6, 1, 1, 1), feeEstimator, closeOnOfflineMismatch = true, updateFeeMinDiffRatio = 0.1, defaultFeerateTolerance, Map(overrideNodeId -> defaultFeerateTolerance.copy(anchorOutputMaxCommitFeerate = overrideMaxCommitFeerate))) feeEstimator.setFeerate(FeeratesPerKw.single(FeeratePerKw(10000 sat)).copy(blocks_2 = defaultMaxCommitFeerate / 2, mempoolMinFee = FeeratePerKw(250 sat))) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) === defaultMaxCommitFeerate / 2) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) === defaultMaxCommitFeerate / 2) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) == defaultMaxCommitFeerate / 2) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) == defaultMaxCommitFeerate / 2) feeEstimator.setFeerate(FeeratesPerKw.single(FeeratePerKw(10000 sat)).copy(blocks_2 = defaultMaxCommitFeerate * 2, mempoolMinFee = FeeratePerKw(250 sat))) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) === defaultMaxCommitFeerate) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) === defaultMaxCommitFeerate) - assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) === overrideMaxCommitFeerate) - assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) === overrideMaxCommitFeerate) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) == defaultMaxCommitFeerate) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) == defaultMaxCommitFeerate) + assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) == overrideMaxCommitFeerate) + assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) == overrideMaxCommitFeerate) val currentFeerates1 = CurrentFeerates(FeeratesPerKw.single(FeeratePerKw(10000 sat)).copy(blocks_2 = defaultMaxCommitFeerate / 2, mempoolMinFee = FeeratePerKw(250 sat))) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, Some(currentFeerates1)) === defaultMaxCommitFeerate / 2) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, Some(currentFeerates1)) === defaultMaxCommitFeerate / 2) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, Some(currentFeerates1)) == defaultMaxCommitFeerate / 2) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, Some(currentFeerates1)) == defaultMaxCommitFeerate / 2) val currentFeerates2 = CurrentFeerates(FeeratesPerKw.single(FeeratePerKw(10000 sat)).copy(blocks_2 = defaultMaxCommitFeerate * 1.5, mempoolMinFee = FeeratePerKw(250 sat))) feeEstimator.setFeerate(FeeratesPerKw.single(FeeratePerKw(10000 sat)).copy(blocks_2 = defaultMaxCommitFeerate / 2, mempoolMinFee = FeeratePerKw(250 sat))) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, Some(currentFeerates2)) === defaultMaxCommitFeerate) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, Some(currentFeerates2)) === defaultMaxCommitFeerate) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, Some(currentFeerates2)) == defaultMaxCommitFeerate) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, Some(currentFeerates2)) == defaultMaxCommitFeerate) val highFeerates = CurrentFeerates(FeeratesPerKw.single(FeeratePerKw(25000 sat)).copy(mempoolMinFee = FeeratePerKw(10000 sat))) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, Some(highFeerates)) === FeeratePerKw(10000 sat) * 1.25) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, Some(highFeerates)) === FeeratePerKw(10000 sat) * 1.25) - assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputs, 100000 sat, Some(highFeerates)) === FeeratePerKw(10000 sat) * 1.25) - assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, Some(highFeerates)) === FeeratePerKw(10000 sat) * 1.25) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, Some(highFeerates)) == FeeratePerKw(10000 sat) * 1.25) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, Some(highFeerates)) == FeeratePerKw(10000 sat) * 1.25) + assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputs, 100000 sat, Some(highFeerates)) == FeeratePerKw(10000 sat) * 1.25) + assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, Some(highFeerates)) == FeeratePerKw(10000 sat) * 1.25) feeEstimator.setFeerate(FeeratesPerKw.single(FeeratePerKw(25000 sat)).copy(mempoolMinFee = FeeratePerKw(10000 sat))) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) === FeeratePerKw(10000 sat) * 1.25) - assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) === FeeratePerKw(10000 sat) * 1.25) - assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) === FeeratePerKw(10000 sat) * 1.25) - assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) === FeeratePerKw(10000 sat) * 1.25) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) == FeeratePerKw(10000 sat) * 1.25) + assert(feeConf.getCommitmentFeerate(defaultNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) == FeeratePerKw(10000 sat) * 1.25) + assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputs, 100000 sat, None) == FeeratePerKw(10000 sat) * 1.25) + assert(feeConf.getCommitmentFeerate(overrideNodeId, ChannelTypes.AnchorOutputsZeroFeeHtlcTx, 100000 sat, None) == FeeratePerKw(10000 sat) * 1.25) } test("fee difference too high") { @@ -102,7 +102,7 @@ class FeeEstimatorSpec extends AnyFunSuite { (FeeratePerKw(250 sat), FeeratePerKw(1500 sat), true), ) testCases.foreach { case (networkFeerate, proposedFeerate, expected) => - assert(tolerance.isFeeDiffTooHigh(channelType, networkFeerate, proposedFeerate) === expected) + assert(tolerance.isFeeDiffTooHigh(channelType, networkFeerate, proposedFeerate) == expected) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FeeProviderSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FeeProviderSpec.scala index efeda2cee2..73c4d4548f 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FeeProviderSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/fee/FeeProviderSpec.scala @@ -23,17 +23,17 @@ import org.scalatest.funsuite.AnyFunSuite class FeeProviderSpec extends AnyFunSuite { test("convert fee rates") { - assert(FeeratePerByte(FeeratePerKw(2000 sat)) === FeeratePerByte(8 sat)) - assert(FeeratePerKB(FeeratePerByte(10 sat)) === FeeratePerKB(10000 sat)) - assert(FeeratePerKB(FeeratePerKw(25 sat)) === FeeratePerKB(100 sat)) - assert(FeeratePerKw(FeeratePerKB(10000 sat)) === FeeratePerKw(2500 sat)) - assert(FeeratePerKw(FeeratePerByte(10 sat)) === FeeratePerKw(2500 sat)) + assert(FeeratePerByte(FeeratePerKw(2000 sat)) == FeeratePerByte(8 sat)) + assert(FeeratePerKB(FeeratePerByte(10 sat)) == FeeratePerKB(10000 sat)) + assert(FeeratePerKB(FeeratePerKw(25 sat)) == FeeratePerKB(100 sat)) + assert(FeeratePerKw(FeeratePerKB(10000 sat)) == FeeratePerKw(2500 sat)) + assert(FeeratePerKw(FeeratePerByte(10 sat)) == FeeratePerKw(2500 sat)) } test("enforce a minimum feerate-per-kw") { - assert(FeeratePerKw(FeeratePerKB(1000 sat)) === MinimumFeeratePerKw) - assert(FeeratePerKw(FeeratePerKB(500 sat)) === MinimumFeeratePerKw) - assert(FeeratePerKw(FeeratePerByte(1 sat)) === MinimumFeeratePerKw) + assert(FeeratePerKw(FeeratePerKB(1000 sat)) == MinimumFeeratePerKw) + assert(FeeratePerKw(FeeratePerKB(500 sat)) == MinimumFeeratePerKw) + assert(FeeratePerKw(FeeratePerByte(1 sat)) == MinimumFeeratePerKw) } test("compare feerates") { @@ -48,12 +48,12 @@ class FeeProviderSpec extends AnyFunSuite { } test("numeric operations") { - assert(FeeratePerKw(100 sat) * 0.4 === FeeratePerKw(40 sat)) - assert(FeeratePerKw(501 sat) * 0.5 === FeeratePerKw(250 sat)) - assert(FeeratePerKw(5 sat) * 5 === FeeratePerKw(25 sat)) - assert(FeeratePerKw(100 sat) / 10 === FeeratePerKw(10 sat)) - assert(FeeratePerKw(101 sat) / 10 === FeeratePerKw(10 sat)) - assert(FeeratePerKw(100 sat) + FeeratePerKw(50 sat) === FeeratePerKw(150 sat)) + assert(FeeratePerKw(100 sat) * 0.4 == FeeratePerKw(40 sat)) + assert(FeeratePerKw(501 sat) * 0.5 == FeeratePerKw(250 sat)) + assert(FeeratePerKw(5 sat) * 5 == FeeratePerKw(25 sat)) + assert(FeeratePerKw(100 sat) / 10 == FeeratePerKw(10 sat)) + assert(FeeratePerKw(101 sat) / 10 == FeeratePerKw(10 sat)) + assert(FeeratePerKw(100 sat) + FeeratePerKw(50 sat) == FeeratePerKw(150 sat)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainWatchdogSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainWatchdogSpec.scala index 24b73080d3..819579ce96 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainWatchdogSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainWatchdogSpec.scala @@ -53,8 +53,8 @@ class BlockchainWatchdogSpec extends ScalaTestWithActorTestKit(ConfigFactory.loa // eventListener.expectMessageType[DangerousBlocksSkew] ) eventListener.expectNoMessage(100 millis) - // assert(events.map(_.recentHeaders.source).toSet === Set("bitcoinheaders.net", "blockcypher.com", "blockstream.info", "mempool.space")) - assert(events.map(_.recentHeaders.source).toSet === Set("bitcoinheaders.net", "blockstream.info", "mempool.space")) + // assert(events.map(_.recentHeaders.source).toSet == Set("bitcoinheaders.net", "blockcypher.com", "blockstream.info", "mempool.space")) + assert(events.map(_.recentHeaders.source).toSet == Set("bitcoinheaders.net", "blockstream.info", "mempool.space")) testKit.stop(watchdog) } @@ -70,8 +70,8 @@ class BlockchainWatchdogSpec extends ScalaTestWithActorTestKit(ConfigFactory.loa // eventListener.expectMessageType[DangerousBlocksSkew] ) eventListener.expectNoMessage(100 millis) - // assert(events.map(_.recentHeaders.source).toSet === Set("blockcypher.com", "blockstream.info", "mempool.space")) - assert(events.map(_.recentHeaders.source).toSet === Set("blockstream.info", "mempool.space")) + // assert(events.map(_.recentHeaders.source).toSet == Set("blockcypher.com", "blockstream.info", "mempool.space")) + assert(events.map(_.recentHeaders.source).toSet == Set("blockstream.info", "mempool.space")) testKit.stop(watchdog) } @@ -82,21 +82,21 @@ class BlockchainWatchdogSpec extends ScalaTestWithActorTestKit(ConfigFactory.loa val watchdog = testKit.spawn(BlockchainWatchdog(nodeParamsTestnet, 1 second, blockTimeout)) watchdog ! WrappedCurrentBlockHeight(BlockHeight(500000)) - assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight === BlockHeight(500000)) - assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight === BlockHeight(500000)) - // assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight === BlockHeight(500000)) + assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight == BlockHeight(500000)) + assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight == BlockHeight(500000)) + // assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight == BlockHeight(500000)) eventListener.expectNoMessage(100 millis) // If we don't receive blocks, we check blockchain sources. - assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight === BlockHeight(500000)) - assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight === BlockHeight(500000)) - // assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight === BlockHeight(500000)) + assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight == BlockHeight(500000)) + assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight == BlockHeight(500000)) + // assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight == BlockHeight(500000)) eventListener.expectNoMessage(100 millis) // And we keep checking blockchain sources until we receive a block. - assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight === BlockHeight(500000)) - assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight === BlockHeight(500000)) - // assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight === BlockHeight(500000)) + assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight == BlockHeight(500000)) + assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight == BlockHeight(500000)) + // assert(eventListener.expectMessageType[DangerousBlocksSkew].recentHeaders.currentBlockHeight == BlockHeight(500000)) eventListener.expectNoMessage(100 millis) } @@ -123,7 +123,7 @@ class BlockchainWatchdogSpec extends ScalaTestWithActorTestKit(ConfigFactory.loa // eventListener.expectMessageType[DangerousBlocksSkew] ) eventListener.expectNoMessage(100 millis) - assert(events.map(_.recentHeaders.source).toSet === Set("blockstream.info", "mempool.space")) + assert(events.map(_.recentHeaders.source).toSet == Set("blockstream.info", "mempool.space")) testKit.stop(watchdog) } else { cancel("Tor daemon is not up and running") diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/ExplorerApiSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/ExplorerApiSpec.scala index 8c1328bcb3..846292dc1b 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/ExplorerApiSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/ExplorerApiSpec.scala @@ -36,10 +36,10 @@ class ExplorerApiSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl val sender = testKit.createTestProbe[LatestHeaders]() api ! CheckLatestHeaders(sender.ref) val latestHeaders = sender.expectMessageType[LatestHeaders] - assert(latestHeaders.currentBlockHeight === BlockHeight(630450)) + assert(latestHeaders.currentBlockHeight == BlockHeight(630450)) assert(latestHeaders.blockHeaders.nonEmpty) assert(latestHeaders.blockHeaders.forall(_.blockHeight > BlockHeight(630450))) - assert(latestHeaders.source === explorer.name) + assert(latestHeaders.source == explorer.name) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelDataSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelDataSpec.scala index bbed15743f..e86490470a 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelDataSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelDataSpec.scala @@ -82,15 +82,15 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel val aliceClosing = alice.stateData.asInstanceOf[DATA_CLOSING] assert(aliceClosing.localCommitPublished.nonEmpty) val lcp = aliceClosing.localCommitPublished.get - assert(lcp.commitTx.txOut.length === 6) + assert(lcp.commitTx.txOut.length == 6) assert(lcp.claimMainDelayedOutputTx.nonEmpty) - assert(lcp.htlcTxs.size === 4) // we have one entry for each non-dust htlc + assert(lcp.htlcTxs.size == 4) // we have one entry for each non-dust htlc val htlcTimeoutTxs = getHtlcTimeoutTxs(lcp) - assert(htlcTimeoutTxs.length === 2) + assert(htlcTimeoutTxs.length == 2) val htlcSuccessTxs = getHtlcSuccessTxs(lcp) - assert(htlcSuccessTxs.length === 1) // we only have the preimage for 1 of the 2 non-dust htlcs + assert(htlcSuccessTxs.length == 1) // we only have the preimage for 1 of the 2 non-dust htlcs val remainingHtlcOutpoint = lcp.htlcTxs.collect { case (outpoint, None) => outpoint }.head - assert(lcp.claimHtlcDelayedTxs.length === 0) // we will publish 3rd-stage txs once htlc txs confirm + assert(lcp.claimHtlcDelayedTxs.length == 0) // we will publish 3rd-stage txs once htlc txs confirm assert(!lcp.isConfirmed) assert(!lcp.isDone) @@ -122,7 +122,7 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel Closing.updateLocalCommitPublished(current1, tx) } assert(!lcp3.isDone) - assert(lcp3.claimHtlcDelayedTxs.length === 3) + assert(lcp3.claimHtlcDelayedTxs.length == 3) val lcp4 = lcp3.claimHtlcDelayedTxs.map(_.tx).foldLeft(lcp3) { case (current, tx) => Closing.updateLocalCommitPublished(current, tx) @@ -145,7 +145,7 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel Closing.updateLocalCommitPublished(current1, tx) } assert(!lcp3.isDone) - assert(lcp3.claimHtlcDelayedTxs.length === 3) + assert(lcp3.claimHtlcDelayedTxs.length == 3) val lcp4 = lcp3.claimHtlcDelayedTxs.map(_.tx).foldLeft(lcp3) { case (current, tx) => Closing.updateLocalCommitPublished(current, tx) @@ -157,11 +157,11 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel val aliceClosing1 = alice.stateData.asInstanceOf[DATA_CLOSING] val lcp5 = aliceClosing1.localCommitPublished.get.copy(irrevocablySpent = lcp4.irrevocablySpent, claimHtlcDelayedTxs = lcp4.claimHtlcDelayedTxs) assert(lcp5.htlcTxs(remainingHtlcOutpoint) !== None) - assert(lcp5.claimHtlcDelayedTxs.length === 3) + assert(lcp5.claimHtlcDelayedTxs.length == 3) val newHtlcSuccessTx = lcp5.htlcTxs(remainingHtlcOutpoint).get.tx val (lcp6, Some(newClaimHtlcDelayedTx)) = Closing.LocalClose.claimHtlcDelayedOutput(lcp5, nodeParams.channelKeyManager, aliceClosing.commitments, newHtlcSuccessTx, nodeParams.onChainFeeConf.feeEstimator, nodeParams.onChainFeeConf.feeTargets) - assert(lcp6.claimHtlcDelayedTxs.length === 4) + assert(lcp6.claimHtlcDelayedTxs.length == 4) val lcp7 = Closing.updateLocalCommitPublished(lcp6, newHtlcSuccessTx) assert(!lcp7.isDone) @@ -180,16 +180,16 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel val (current1, _) = Closing.LocalClose.claimHtlcDelayedOutput(current, nodeParams.channelKeyManager, aliceClosing.commitments, tx, nodeParams.onChainFeeConf.feeEstimator, nodeParams.onChainFeeConf.feeTargets) Closing.updateLocalCommitPublished(current1, tx) } - assert(lcp3.claimHtlcDelayedTxs.length === 1) + assert(lcp3.claimHtlcDelayedTxs.length == 1) assert(!lcp3.isDone) val lcp4 = Closing.updateLocalCommitPublished(lcp3, lcp3.claimHtlcDelayedTxs.head.tx) assert(!lcp4.isDone) val remainingHtlcTimeoutTxs = htlcTimeoutTxs.filter(_.input.outPoint != remoteHtlcSuccess.input.outPoint) - assert(remainingHtlcTimeoutTxs.length === 1) + assert(remainingHtlcTimeoutTxs.length == 1) val (lcp5, Some(remainingClaimHtlcTx)) = Closing.LocalClose.claimHtlcDelayedOutput(lcp4, nodeParams.channelKeyManager, aliceClosing.commitments, remainingHtlcTimeoutTxs.head.tx, nodeParams.onChainFeeConf.feeEstimator, nodeParams.onChainFeeConf.feeTargets) - assert(lcp5.claimHtlcDelayedTxs.length === 2) + assert(lcp5.claimHtlcDelayedTxs.length == 2) val lcp6 = (remainingHtlcTimeoutTxs.map(_.tx) ++ Seq(remainingClaimHtlcTx.tx)).foldLeft(lcp5) { case (current, tx) => Closing.updateLocalCommitPublished(current, tx) @@ -211,7 +211,7 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel Closing.updateLocalCommitPublished(current1, tx) } assert(!lcp3.isDone) - assert(lcp3.claimHtlcDelayedTxs.length === 2) + assert(lcp3.claimHtlcDelayedTxs.length == 2) val lcp4 = lcp3.claimHtlcDelayedTxs.map(_.tx).foldLeft(lcp3) { case (current, tx) => Closing.updateLocalCommitPublished(current, tx) @@ -219,7 +219,7 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel assert(!lcp4.isDone) val remoteHtlcTimeoutTxs = getClaimHtlcTimeoutTxs(rcp).map(_.tx) - assert(remoteHtlcTimeoutTxs.length === 2) + assert(remoteHtlcTimeoutTxs.length == 2) val lcp5 = Closing.updateLocalCommitPublished(lcp4, remoteHtlcTimeoutTxs.head) assert(!lcp5.isDone) @@ -238,7 +238,7 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel } assert(!lcp3.isDone) - assert(lcp3.claimHtlcDelayedTxs.length === 3) + assert(lcp3.claimHtlcDelayedTxs.length == 3) val lcp4 = lcp3.claimHtlcDelayedTxs.map(_.tx).foldLeft(lcp3) { case (current, tx) => Closing.updateLocalCommitPublished(current, tx) @@ -246,14 +246,14 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel assert(!lcp4.isDone) // at this point the pending incoming htlc is waiting for a preimage - assert(lcp4.htlcTxs(remainingHtlcOutpoint) === None) + assert(lcp4.htlcTxs(remainingHtlcOutpoint) == None) alice ! CMD_FAIL_HTLC(1, Right(UnknownNextPeer), replyTo_opt = Some(probe.ref)) probe.expectMsgType[CommandSuccess[CMD_FAIL_HTLC]] val aliceClosing1 = alice.stateData.asInstanceOf[DATA_CLOSING] val lcp5 = aliceClosing1.localCommitPublished.get.copy(irrevocablySpent = lcp4.irrevocablySpent, claimHtlcDelayedTxs = lcp4.claimHtlcDelayedTxs) assert(!lcp5.htlcTxs.contains(remainingHtlcOutpoint)) - assert(lcp5.claimHtlcDelayedTxs.length === 3) + assert(lcp5.claimHtlcDelayedTxs.length == 3) assert(lcp5.isDone) } @@ -267,13 +267,13 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel val bobClosing = bob.stateData.asInstanceOf[DATA_CLOSING] assert(bobClosing.remoteCommitPublished.nonEmpty) val rcp = bobClosing.remoteCommitPublished.get - assert(rcp.commitTx.txOut.length === 6) + assert(rcp.commitTx.txOut.length == 6) assert(rcp.claimMainOutputTx.nonEmpty) - assert(rcp.claimHtlcTxs.size === 4) // we have one entry for each non-dust htlc + assert(rcp.claimHtlcTxs.size == 4) // we have one entry for each non-dust htlc val claimHtlcTimeoutTxs = getClaimHtlcTimeoutTxs(rcp) - assert(claimHtlcTimeoutTxs.length === 2) + assert(claimHtlcTimeoutTxs.length == 2) val claimHtlcSuccessTxs = getClaimHtlcSuccessTxs(rcp) - assert(claimHtlcSuccessTxs.length === 1) // we only have the preimage for 1 of the 2 non-dust htlcs + assert(claimHtlcSuccessTxs.length == 1) // we only have the preimage for 1 of the 2 non-dust htlcs val remainingHtlcOutpoint = rcp.claimHtlcTxs.collect { case (outpoint, None) => outpoint }.head assert(!rcp.isConfirmed) assert(!rcp.isDone) @@ -342,7 +342,7 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel assert(!rcp3.isDone) val remainingClaimHtlcTimeoutTx = claimHtlcTimeoutTxs.filter(_.input.outPoint != remoteHtlcSuccess.input.outPoint) - assert(remainingClaimHtlcTimeoutTx.length === 1) + assert(remainingClaimHtlcTimeoutTx.length == 1) val rcp4 = Closing.updateRemoteCommitPublished(rcp3, remainingClaimHtlcTimeoutTx.head.tx) assert(!rcp4.isDone) @@ -383,7 +383,7 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel val bobClosing1 = bob.stateData.asInstanceOf[DATA_CLOSING] val rcp4 = bobClosing1.remoteCommitPublished.get.copy(irrevocablySpent = rcp3.irrevocablySpent) assert(!rcp4.claimHtlcTxs.contains(remainingHtlcOutpoint)) - assert(rcp4.claimHtlcTxs.size === 3) + assert(rcp4.claimHtlcTxs.size == 3) assert(getClaimHtlcSuccessTxs(rcp4).size == 1) assert(getClaimHtlcTimeoutTxs(rcp4).size == 2) @@ -431,13 +431,13 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel val bobClosing = bob.stateData.asInstanceOf[DATA_CLOSING] assert(bobClosing.nextRemoteCommitPublished.nonEmpty) val rcp = bobClosing.nextRemoteCommitPublished.get - assert(rcp.commitTx.txOut.length === 6) + assert(rcp.commitTx.txOut.length == 6) assert(rcp.claimMainOutputTx.nonEmpty) - assert(rcp.claimHtlcTxs.size === 4) // we have one entry for each non-dust htlc + assert(rcp.claimHtlcTxs.size == 4) // we have one entry for each non-dust htlc val claimHtlcTimeoutTxs = getClaimHtlcTimeoutTxs(rcp) - assert(claimHtlcTimeoutTxs.length === 2) + assert(claimHtlcTimeoutTxs.length == 2) val claimHtlcSuccessTxs = getClaimHtlcSuccessTxs(rcp) - assert(claimHtlcSuccessTxs.length === 1) // we only have the preimage for 1 of the 2 non-dust htlcs + assert(claimHtlcSuccessTxs.length == 1) // we only have the preimage for 1 of the 2 non-dust htlcs val remainingHtlcOutpoint = rcp.claimHtlcTxs.collect { case (outpoint, None) => outpoint }.head assert(!rcp.isConfirmed) assert(!rcp.isDone) @@ -504,7 +504,7 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel assert(!rcp3.isDone) val remainingClaimHtlcTimeoutTx = claimHtlcTimeoutTxs.filter(_.input.outPoint != remoteHtlcSuccess.input.outPoint) - assert(remainingClaimHtlcTimeoutTx.length === 1) + assert(remainingClaimHtlcTimeoutTx.length == 1) val rcp4 = Closing.updateRemoteCommitPublished(rcp3, remainingClaimHtlcTimeoutTx.head.tx) assert(!rcp4.isDone) @@ -552,11 +552,11 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel alice ! WatchFundingSpentTriggered(revokedCommitTx) awaitCond(alice.stateName == CLOSING) val aliceClosing = alice.stateData.asInstanceOf[DATA_CLOSING] - assert(aliceClosing.revokedCommitPublished.length === 1) + assert(aliceClosing.revokedCommitPublished.length == 1) val rvk = aliceClosing.revokedCommitPublished.head assert(rvk.claimMainOutputTx.nonEmpty) assert(rvk.mainPenaltyTx.nonEmpty) - assert(rvk.htlcPenaltyTxs.length === 4) + assert(rvk.htlcPenaltyTxs.length == 4) assert(rvk.claimHtlcDelayedPenaltyTxs.isEmpty) assert(!rvk.isDone) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelFeaturesSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelFeaturesSpec.scala index 80e05bf045..8a8eb9d1f1 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelFeaturesSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/ChannelFeaturesSpec.scala @@ -33,24 +33,24 @@ class ChannelFeaturesSpec extends TestKitBaseClass with AnyFunSuiteLike with Cha assert(!standardChannel.hasFeature(Features.StaticRemoteKey)) assert(!standardChannel.hasFeature(Features.AnchorOutputs)) - assert(standardChannel.commitmentFormat === Transactions.DefaultCommitmentFormat) + assert(standardChannel.commitmentFormat == Transactions.DefaultCommitmentFormat) assert(!standardChannel.paysDirectlyToWallet) assert(staticRemoteKeyChannel.hasFeature(Features.StaticRemoteKey)) assert(!staticRemoteKeyChannel.hasFeature(Features.AnchorOutputs)) - assert(staticRemoteKeyChannel.commitmentFormat === Transactions.DefaultCommitmentFormat) + assert(staticRemoteKeyChannel.commitmentFormat == Transactions.DefaultCommitmentFormat) assert(staticRemoteKeyChannel.paysDirectlyToWallet) assert(anchorOutputsChannel.hasFeature(Features.StaticRemoteKey)) assert(anchorOutputsChannel.hasFeature(Features.AnchorOutputs)) assert(!anchorOutputsChannel.hasFeature(Features.AnchorOutputsZeroFeeHtlcTx)) - assert(anchorOutputsChannel.commitmentFormat === Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) + assert(anchorOutputsChannel.commitmentFormat == Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) assert(!anchorOutputsChannel.paysDirectlyToWallet) assert(anchorOutputsZeroFeeHtlcsChannel.hasFeature(Features.StaticRemoteKey)) assert(anchorOutputsZeroFeeHtlcsChannel.hasFeature(Features.AnchorOutputsZeroFeeHtlcTx)) assert(!anchorOutputsZeroFeeHtlcsChannel.hasFeature(Features.AnchorOutputs)) - assert(anchorOutputsZeroFeeHtlcsChannel.commitmentFormat === Transactions.ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) + assert(anchorOutputsZeroFeeHtlcsChannel.commitmentFormat == Transactions.ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) assert(!anchorOutputsZeroFeeHtlcsChannel.paysDirectlyToWallet) } @@ -75,7 +75,7 @@ class ChannelFeaturesSpec extends TestKitBaseClass with AnyFunSuiteLike with Cha ) for (testCase <- testCases) { - assert(ChannelTypes.defaultFromFeatures(testCase.localFeatures, testCase.remoteFeatures) === testCase.expectedChannelType) + assert(ChannelTypes.defaultFromFeatures(testCase.localFeatures, testCase.remoteFeatures) == testCase.expectedChannelType) } } @@ -89,7 +89,7 @@ class ChannelFeaturesSpec extends TestKitBaseClass with AnyFunSuiteLike with Cha TestCase(Features(StaticRemoteKey -> Mandatory, AnchorOutputsZeroFeeHtlcTx -> Mandatory), ChannelTypes.AnchorOutputsZeroFeeHtlcTx), ) for (testCase <- validChannelTypes) { - assert(ChannelTypes.fromFeatures(testCase.features) === testCase.expectedChannelType) + assert(ChannelTypes.fromFeatures(testCase.features) == testCase.expectedChannelType) } val invalidChannelTypes: Seq[Features[InitFeature]] = Seq( @@ -107,20 +107,20 @@ class ChannelFeaturesSpec extends TestKitBaseClass with AnyFunSuiteLike with Cha Features(StaticRemoteKey -> Mandatory, AnchorOutputs -> Mandatory, Wumbo -> Optional), ) for (features <- invalidChannelTypes) { - assert(ChannelTypes.fromFeatures(features) === ChannelTypes.UnsupportedChannelType(features)) + assert(ChannelTypes.fromFeatures(features) == ChannelTypes.UnsupportedChannelType(features)) } } test("enrich channel type with other permanent channel features") { assert(ChannelFeatures(ChannelTypes.Standard, Features[InitFeature](Wumbo -> Optional), Features.empty[InitFeature]).features.isEmpty) - assert(ChannelFeatures(ChannelTypes.Standard, Features[InitFeature](Wumbo -> Optional), Features[InitFeature](Wumbo -> Optional)).features === Set(Wumbo)) - assert(ChannelFeatures(ChannelTypes.Standard, Features[InitFeature](Wumbo -> Mandatory), Features[InitFeature](Wumbo -> Optional)).features === Set(Wumbo)) - assert(ChannelFeatures(ChannelTypes.StaticRemoteKey, Features[InitFeature](Wumbo -> Optional), Features.empty[InitFeature]).features === Set(StaticRemoteKey)) - assert(ChannelFeatures(ChannelTypes.StaticRemoteKey, Features[InitFeature](Wumbo -> Optional), Features[InitFeature](Wumbo -> Optional)).features === Set(StaticRemoteKey, Wumbo)) - assert(ChannelFeatures(ChannelTypes.AnchorOutputs, Features.empty[InitFeature], Features[InitFeature](Wumbo -> Optional)).features === Set(StaticRemoteKey, AnchorOutputs)) - assert(ChannelFeatures(ChannelTypes.AnchorOutputs, Features[InitFeature](Wumbo -> Optional), Features[InitFeature](Wumbo -> Mandatory)).features === Set(StaticRemoteKey, AnchorOutputs, Wumbo)) - assert(ChannelFeatures(ChannelTypes.AnchorOutputsZeroFeeHtlcTx, Features.empty[InitFeature], Features[InitFeature](Wumbo -> Optional)).features === Set(StaticRemoteKey, AnchorOutputsZeroFeeHtlcTx)) - assert(ChannelFeatures(ChannelTypes.AnchorOutputsZeroFeeHtlcTx, Features[InitFeature](Wumbo -> Optional), Features[InitFeature](Wumbo -> Mandatory)).features === Set(StaticRemoteKey, AnchorOutputsZeroFeeHtlcTx, Wumbo)) + assert(ChannelFeatures(ChannelTypes.Standard, Features[InitFeature](Wumbo -> Optional), Features[InitFeature](Wumbo -> Optional)).features == Set(Wumbo)) + assert(ChannelFeatures(ChannelTypes.Standard, Features[InitFeature](Wumbo -> Mandatory), Features[InitFeature](Wumbo -> Optional)).features == Set(Wumbo)) + assert(ChannelFeatures(ChannelTypes.StaticRemoteKey, Features[InitFeature](Wumbo -> Optional), Features.empty[InitFeature]).features == Set(StaticRemoteKey)) + assert(ChannelFeatures(ChannelTypes.StaticRemoteKey, Features[InitFeature](Wumbo -> Optional), Features[InitFeature](Wumbo -> Optional)).features == Set(StaticRemoteKey, Wumbo)) + assert(ChannelFeatures(ChannelTypes.AnchorOutputs, Features.empty[InitFeature], Features[InitFeature](Wumbo -> Optional)).features == Set(StaticRemoteKey, AnchorOutputs)) + assert(ChannelFeatures(ChannelTypes.AnchorOutputs, Features[InitFeature](Wumbo -> Optional), Features[InitFeature](Wumbo -> Mandatory)).features == Set(StaticRemoteKey, AnchorOutputs, Wumbo)) + assert(ChannelFeatures(ChannelTypes.AnchorOutputsZeroFeeHtlcTx, Features.empty[InitFeature], Features[InitFeature](Wumbo -> Optional)).features == Set(StaticRemoteKey, AnchorOutputsZeroFeeHtlcTx)) + assert(ChannelFeatures(ChannelTypes.AnchorOutputsZeroFeeHtlcTx, Features[InitFeature](Wumbo -> Optional), Features[InitFeature](Wumbo -> Mandatory)).features == Set(StaticRemoteKey, AnchorOutputsZeroFeeHtlcTx, Wumbo)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/CommitmentsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/CommitmentsSpec.scala index 1673db2ebe..d18261043f 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/CommitmentsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/CommitmentsSpec.scala @@ -385,7 +385,7 @@ class CommitmentsSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val c = CommitmentsSpec.makeCommitments(100000000 msat, 50000000 msat, FeeratePerKw(2500 sat), 546 sat, isInitiator) val (_, cmdAdd) = makeCmdAdd(c.availableBalanceForSend, randomKey().publicKey, f.currentBlockHeight) val Right((c1, _)) = sendAdd(c, cmdAdd, f.currentBlockHeight, feeConfNoMismatch) - assert(c1.availableBalanceForSend === 0.msat) + assert(c1.availableBalanceForSend == 0.msat) // We should be able to handle a fee increase. val Right((c2, _)) = sendFee(c1, CMD_UPDATE_FEE(FeeratePerKw(3000 sat)), feeConfNoMismatch) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/DustExposureSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/DustExposureSpec.scala index 0bb2fda155..c277653adc 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/DustExposureSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/DustExposureSpec.scala @@ -42,18 +42,18 @@ class DustExposureSpec extends AnyFunSuiteLike { OutgoingHtlc(createHtlc(3, 500.sat.toMilliSatoshi)), ) val spec = CommitmentSpec(htlcs, FeeratePerKw(FeeratePerByte(50 sat)), 50000 msat, 75000 msat) - assert(DustExposure.computeExposure(spec, 450 sat, Transactions.ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) === 898.sat.toMilliSatoshi) - assert(DustExposure.computeExposure(spec, 500 sat, Transactions.ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) === 2796.sat.toMilliSatoshi) - assert(DustExposure.computeExposure(spec, 500 sat, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) === 3796.sat.toMilliSatoshi) + assert(DustExposure.computeExposure(spec, 450 sat, Transactions.ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) == 898.sat.toMilliSatoshi) + assert(DustExposure.computeExposure(spec, 500 sat, Transactions.ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) == 2796.sat.toMilliSatoshi) + assert(DustExposure.computeExposure(spec, 500 sat, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) == 3796.sat.toMilliSatoshi) } { // Low feerate: buffer adds 10 sat/byte val dustLimit = 500.sat val feerate = FeeratePerKw(FeeratePerByte(10 sat)) - assert(Transactions.receivedHtlcTrimThreshold(dustLimit, feerate, Transactions.DefaultCommitmentFormat) === 2257.sat) - assert(Transactions.offeredHtlcTrimThreshold(dustLimit, feerate, Transactions.DefaultCommitmentFormat) === 2157.sat) - assert(Transactions.receivedHtlcTrimThreshold(dustLimit, feerate * 2, Transactions.DefaultCommitmentFormat) === 4015.sat) - assert(Transactions.offeredHtlcTrimThreshold(dustLimit, feerate * 2, Transactions.DefaultCommitmentFormat) === 3815.sat) + assert(Transactions.receivedHtlcTrimThreshold(dustLimit, feerate, Transactions.DefaultCommitmentFormat) == 2257.sat) + assert(Transactions.offeredHtlcTrimThreshold(dustLimit, feerate, Transactions.DefaultCommitmentFormat) == 2157.sat) + assert(Transactions.receivedHtlcTrimThreshold(dustLimit, feerate * 2, Transactions.DefaultCommitmentFormat) == 4015.sat) + assert(Transactions.offeredHtlcTrimThreshold(dustLimit, feerate * 2, Transactions.DefaultCommitmentFormat) == 3815.sat) val htlcs = Set[DirectedHtlc]( // Below the dust limit. IncomingHtlc(createHtlc(0, 450.sat.toMilliSatoshi)), @@ -70,8 +70,8 @@ class DustExposureSpec extends AnyFunSuiteLike { ) val spec = CommitmentSpec(htlcs, feerate, 50000 msat, 75000 msat) val expected = 450.sat + 450.sat + 2250.sat + 2150.sat + 4010.sat + 3810.sat - assert(DustExposure.computeExposure(spec, dustLimit, Transactions.DefaultCommitmentFormat) === expected.toMilliSatoshi) - assert(DustExposure.computeExposure(spec, feerate * 2, dustLimit, Transactions.DefaultCommitmentFormat) === DustExposure.computeExposure(spec, dustLimit, Transactions.DefaultCommitmentFormat)) + assert(DustExposure.computeExposure(spec, dustLimit, Transactions.DefaultCommitmentFormat) == expected.toMilliSatoshi) + assert(DustExposure.computeExposure(spec, feerate * 2, dustLimit, Transactions.DefaultCommitmentFormat) == DustExposure.computeExposure(spec, dustLimit, Transactions.DefaultCommitmentFormat)) assert(DustExposure.contributesToDustExposure(IncomingHtlc(createHtlc(4, 4010.sat.toMilliSatoshi)), spec, dustLimit, Transactions.DefaultCommitmentFormat)) assert(DustExposure.contributesToDustExposure(OutgoingHtlc(createHtlc(4, 3810.sat.toMilliSatoshi)), spec, dustLimit, Transactions.DefaultCommitmentFormat)) assert(!DustExposure.contributesToDustExposure(IncomingHtlc(createHtlc(5, 4020.sat.toMilliSatoshi)), spec, dustLimit, Transactions.DefaultCommitmentFormat)) @@ -81,10 +81,10 @@ class DustExposureSpec extends AnyFunSuiteLike { // High feerate: buffer adds 25% val dustLimit = 1000.sat val feerate = FeeratePerKw(FeeratePerByte(80 sat)) - assert(Transactions.receivedHtlcTrimThreshold(dustLimit, feerate, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) === 15120.sat) - assert(Transactions.offeredHtlcTrimThreshold(dustLimit, feerate, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) === 14320.sat) - assert(Transactions.receivedHtlcTrimThreshold(dustLimit, feerate * 1.25, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) === 18650.sat) - assert(Transactions.offeredHtlcTrimThreshold(dustLimit, feerate * 1.25, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) === 17650.sat) + assert(Transactions.receivedHtlcTrimThreshold(dustLimit, feerate, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) == 15120.sat) + assert(Transactions.offeredHtlcTrimThreshold(dustLimit, feerate, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) == 14320.sat) + assert(Transactions.receivedHtlcTrimThreshold(dustLimit, feerate * 1.25, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) == 18650.sat) + assert(Transactions.offeredHtlcTrimThreshold(dustLimit, feerate * 1.25, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) == 17650.sat) val htlcs = Set[DirectedHtlc]( // Below the dust limit. IncomingHtlc(createHtlc(0, 900.sat.toMilliSatoshi)), @@ -101,8 +101,8 @@ class DustExposureSpec extends AnyFunSuiteLike { ) val spec = CommitmentSpec(htlcs, feerate, 50000 msat, 75000 msat) val expected = 900.sat + 900.sat + 15000.sat + 14000.sat + 18000.sat + 17000.sat - assert(DustExposure.computeExposure(spec, dustLimit, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) === expected.toMilliSatoshi) - assert(DustExposure.computeExposure(spec, feerate * 1.25, dustLimit, Transactions.DefaultCommitmentFormat) === DustExposure.computeExposure(spec, dustLimit, Transactions.DefaultCommitmentFormat)) + assert(DustExposure.computeExposure(spec, dustLimit, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) == expected.toMilliSatoshi) + assert(DustExposure.computeExposure(spec, feerate * 1.25, dustLimit, Transactions.DefaultCommitmentFormat) == DustExposure.computeExposure(spec, dustLimit, Transactions.DefaultCommitmentFormat)) assert(DustExposure.contributesToDustExposure(IncomingHtlc(createHtlc(4, 18000.sat.toMilliSatoshi)), spec, dustLimit, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat)) assert(DustExposure.contributesToDustExposure(OutgoingHtlc(createHtlc(4, 17000.sat.toMilliSatoshi)), spec, dustLimit, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat)) assert(!DustExposure.contributesToDustExposure(IncomingHtlc(createHtlc(5, 19000.sat.toMilliSatoshi)), spec, dustLimit, Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat)) @@ -113,7 +113,7 @@ class DustExposureSpec extends AnyFunSuiteLike { test("filter incoming htlcs before forwarding") { val dustLimit = 1000.sat val initialSpec = CommitmentSpec(Set.empty, FeeratePerKw(10000 sat), 0 msat, 0 msat) - assert(DustExposure.computeExposure(initialSpec, dustLimit, Transactions.DefaultCommitmentFormat) === 0.msat) + assert(DustExposure.computeExposure(initialSpec, dustLimit, Transactions.DefaultCommitmentFormat) == 0.msat) assert(DustExposure.contributesToDustExposure(IncomingHtlc(createHtlc(0, 9000.sat.toMilliSatoshi)), initialSpec, dustLimit, Transactions.DefaultCommitmentFormat)) assert(DustExposure.contributesToDustExposure(OutgoingHtlc(createHtlc(0, 9000.sat.toMilliSatoshi)), initialSpec, dustLimit, Transactions.DefaultCommitmentFormat)) // NB: HTLC-success transactions are bigger than HTLC-timeout transactions: that means incoming htlcs have a higher @@ -128,7 +128,7 @@ class DustExposureSpec extends AnyFunSuiteLike { OutgoingHtlc(createHtlc(3, 9500.sat.toMilliSatoshi)), IncomingHtlc(createHtlc(4, 9500.sat.toMilliSatoshi)), )) - assert(DustExposure.computeExposure(updatedSpec, dustLimit, Transactions.DefaultCommitmentFormat) === 18500.sat.toMilliSatoshi) + assert(DustExposure.computeExposure(updatedSpec, dustLimit, Transactions.DefaultCommitmentFormat) == 18500.sat.toMilliSatoshi) val receivedHtlcs = Seq( createHtlc(5, 9500.sat.toMilliSatoshi), @@ -139,8 +139,8 @@ class DustExposureSpec extends AnyFunSuiteLike { createHtlc(10, 50000.sat.toMilliSatoshi), ) val (accepted, rejected) = DustExposure.filterBeforeForward(25000 sat, updatedSpec, dustLimit, 10000.sat.toMilliSatoshi, initialSpec, dustLimit, 15000.sat.toMilliSatoshi, receivedHtlcs, Transactions.DefaultCommitmentFormat) - assert(accepted.map(_.id).toSet === Set(5, 6, 8, 10)) - assert(rejected.map(_.id).toSet === Set(7, 9)) + assert(accepted.map(_.id).toSet == Set(5, 6, 8, 10)) + assert(rejected.map(_.id).toSet == Set(7, 9)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/HelpersSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/HelpersSpec.scala index 717444b105..47de53b8d3 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/HelpersSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/HelpersSpec.scala @@ -98,18 +98,18 @@ class HelpersSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStat awaitCond(bob.stateName == CLOSING) val lcp = alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get - assert(lcp.htlcTxs.size === 6) + assert(lcp.htlcTxs.size == 6) val htlcTimeoutTxs = getHtlcTimeoutTxs(lcp) - assert(htlcTimeoutTxs.length === 3) + assert(htlcTimeoutTxs.length == 3) val htlcSuccessTxs = getHtlcSuccessTxs(lcp) - assert(htlcSuccessTxs.length === 1) + assert(htlcSuccessTxs.length == 1) val rcp = bob.stateData.asInstanceOf[DATA_CLOSING].remoteCommitPublished.get - assert(rcp.claimHtlcTxs.size === 6) + assert(rcp.claimHtlcTxs.size == 6) val claimHtlcTimeoutTxs = getClaimHtlcTimeoutTxs(rcp) - assert(claimHtlcTimeoutTxs.length === 3) + assert(claimHtlcTimeoutTxs.length == 3) val claimHtlcSuccessTxs = getClaimHtlcSuccessTxs(rcp) - assert(claimHtlcSuccessTxs.length === 1) + assert(claimHtlcSuccessTxs.length == 1) Fixture(alice, lcp, Set(htlca1a, htlca1b, htlca2), bob, rcp, Set(htlcb1a, htlcb1b, htlcb2), probe) } @@ -197,24 +197,24 @@ class HelpersSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStat val aliceTimedOutHtlcs = htlcTimeoutTxs.map(htlcTimeout => { val timedOutHtlcs = Closing.trimmedOrTimedOutHtlcs(commitmentFormat, localCommit, localCommitPublished, dustLimit, htlcTimeout.tx) - assert(timedOutHtlcs.size === 1) + assert(timedOutHtlcs.size == 1) timedOutHtlcs.head }) - assert(aliceTimedOutHtlcs.toSet === aliceHtlcs) + assert(aliceTimedOutHtlcs.toSet == aliceHtlcs) val bobTimedOutHtlcs = claimHtlcTimeoutTxs.map(claimHtlcTimeout => { val timedOutHtlcs = Closing.trimmedOrTimedOutHtlcs(commitmentFormat, remoteCommit, remoteCommitPublished, dustLimit, claimHtlcTimeout.tx) - assert(timedOutHtlcs.size === 1) + assert(timedOutHtlcs.size == 1) timedOutHtlcs.head }) - assert(bobTimedOutHtlcs.toSet === bobHtlcs) + assert(bobTimedOutHtlcs.toSet == bobHtlcs) val bobTimedOutHtlcs2 = claimHtlcTimeoutTxsModifiedFees.map(claimHtlcTimeout => { val timedOutHtlcs = Closing.trimmedOrTimedOutHtlcs(commitmentFormat, remoteCommit, remoteCommitPublished, dustLimit, claimHtlcTimeout.tx) - assert(timedOutHtlcs.size === 1) + assert(timedOutHtlcs.size == 1) timedOutHtlcs.head }) - assert(bobTimedOutHtlcs2.toSet === bobHtlcs) + assert(bobTimedOutHtlcs2.toSet == bobHtlcs) htlcSuccessTxs.foreach(htlcSuccess => assert(Closing.trimmedOrTimedOutHtlcs(commitmentFormat, localCommit, localCommitPublished, dustLimit, htlcSuccess.tx).isEmpty)) htlcSuccessTxs.foreach(htlcSuccess => assert(Closing.trimmedOrTimedOutHtlcs(commitmentFormat, remoteCommit, remoteCommitPublished, dustLimit, htlcSuccess.tx).isEmpty)) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/RegisterSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/RegisterSpec.scala index c274b1a14e..c6a9b6aaac 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/RegisterSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/RegisterSpec.scala @@ -19,6 +19,6 @@ class RegisterSpec extends TestKitBaseClass with AnyFunSuiteLike with ParallelTe val customRestoredEvent = CustomChannelRestored(TestProbe().ref, randomBytes32(), TestProbe().ref, randomKey().publicKey) registerRef ! customRestoredEvent sender.send(registerRef, Symbol("channels")) - sender.expectMsgType[Map[ByteVector32, ActorRef]] === Map(customRestoredEvent.channelId -> customRestoredEvent.channel) + sender.expectMsgType[Map[ByteVector32, ActorRef]] == Map(customRestoredEvent.channelId -> customRestoredEvent.channel) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/RestoreSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/RestoreSpec.scala index beedd584f0..687cf9a917 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/RestoreSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/RestoreSpec.scala @@ -85,7 +85,7 @@ class RestoreSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Chan bob2alice.forward(newAlice) // ... and ask bob to publish its current commitment val error = alice2bob.expectMsgType[Error] - assert(new String(error.data.toArray) === PleasePublishYourCommitment(channelId(newAlice)).getMessage) + assert(new String(error.data.toArray) == PleasePublishYourCommitment(channelId(newAlice)).getMessage) // alice now waits for bob to publish its commitment awaitCond(newAlice.stateName == WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT) @@ -224,9 +224,9 @@ class RestoreSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Chan val u1 = channelUpdateListener.expectMsgType[ChannelUpdateParametersChanged] assert(!Announcements.areSameIgnoreFlags(u1.channelUpdate, oldStateData.channelUpdate)) - assert(u1.channelUpdate.feeBaseMsat === newConfig.relayParams.privateChannelFees.feeBase) - assert(u1.channelUpdate.feeProportionalMillionths === newConfig.relayParams.privateChannelFees.feeProportionalMillionths) - assert(u1.channelUpdate.cltvExpiryDelta === newConfig.channelConf.expiryDelta) + assert(u1.channelUpdate.feeBaseMsat == newConfig.relayParams.privateChannelFees.feeBase) + assert(u1.channelUpdate.feeProportionalMillionths == newConfig.relayParams.privateChannelFees.feeProportionalMillionths) + assert(u1.channelUpdate.cltvExpiryDelta == newConfig.channelConf.expiryDelta) newAlice ! INPUT_RECONNECTED(alice2bob.ref, aliceInit, bobInit) bob ! INPUT_RECONNECTED(bob2alice.ref, bobInit, aliceInit) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/FinalTxPublisherSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/FinalTxPublisherSpec.scala index a605788918..fb4df104f1 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/FinalTxPublisherSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/FinalTxPublisherSpec.scala @@ -83,8 +83,8 @@ class FinalTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bi publisher ! Publish(probe.ref, cmd) val w = watcher.expectMsgType[WatchParentTxConfirmed] - assert(w.txId === parentTx.txid) - assert(w.minDepth === 5) + assert(w.txId == parentTx.txid) + assert(w.minDepth == 5) createBlocks(5, probe) w.replyTo ! WatchParentTxConfirmedTriggered(currentBlockHeight(probe), 0, parentTx) @@ -143,8 +143,8 @@ class FinalTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bi createBlocks(1, probe) val response = probe.expectMsgType[TxRejected] - assert(response.cmd === cmd) - assert(response.reason === ConflictingTxConfirmed) + assert(response.cmd == cmd) + assert(response.reason == ConflictingTxConfirmed) // The actor should stop when requested: probe.watch(publisher.toClassic) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/MempoolTxMonitorSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/MempoolTxMonitorSpec.scala index f4b53544c0..e2dcddeb57 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/MempoolTxMonitorSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/MempoolTxMonitorSpec.scala @@ -253,9 +253,9 @@ class MempoolTxMonitorSpec extends TestKitBaseClass with AnyFunSuiteLike with Bi monitor ! Publish(probe.ref, tx, tx.txIn.head.outPoint, "test-tx", 15 sat) waitTxInMempool(bitcoinClient, tx.txid, probe) val txPublished = eventListener.expectMsgType[TransactionPublished] - assert(txPublished.tx === tx) - assert(txPublished.miningFee === 15.sat) - assert(txPublished.desc === "test-tx") + assert(txPublished.tx == tx) + assert(txPublished.miningFee == 15.sat) + assert(txPublished.desc == "test-tx") generateBlocks(TestConstants.Alice.nodeParams.channelConf.minDepthBlocks) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight())) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunderSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunderSpec.scala index 2315b2924f..16aa7226a0 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunderSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunderSpec.scala @@ -68,8 +68,8 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike { txOut = TxOut(amountOut, Script.pay2wpkh(PlaceHolderPubKey)) :: Nil, ))) val adjustedTx = adjustAnchorOutputChange(unsignedTx, commitTx.tx, amountIn, commitFeerate, targetFeerate, dustLimit) - assert(adjustedTx.txInfo.tx.txIn.size === unsignedTx.txInfo.tx.txIn.size) - assert(adjustedTx.txInfo.tx.txOut.size === 1) + assert(adjustedTx.txInfo.tx.txIn.size == unsignedTx.txInfo.tx.txIn.size) + assert(adjustedTx.txInfo.tx.txOut.size == 1) assert(adjustedTx.txInfo.tx.txOut.head.amount >= dustLimit) if (adjustedTx.txInfo.tx.txOut.head.amount > dustLimit) { // Simulate tx signing to check final feerate. @@ -133,8 +133,8 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike { for (unsignedTx <- Seq(unsignedHtlcSuccessTx, unsignedHtlcTimeoutTx)) { val totalAmountIn = unsignedTx.txInfo.input.txOut.amount + walletAmountIn val adjustedTx = adjustHtlcTxChange(unsignedTx, totalAmountIn, targetFeerate, dustLimit, ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) - assert(adjustedTx.txInfo.tx.txIn.size === unsignedTx.txInfo.tx.txIn.size) - assert(adjustedTx.txInfo.tx.txOut.size === 1 || adjustedTx.txInfo.tx.txOut.size === 2) + assert(adjustedTx.txInfo.tx.txIn.size == unsignedTx.txInfo.tx.txIn.size) + assert(adjustedTx.txInfo.tx.txOut.size == 1 || adjustedTx.txInfo.tx.txOut.size == 2) if (adjustedTx.txInfo.tx.txOut.size == 2) { // Simulate tx signing to check final feerate. val signedTx = { @@ -184,8 +184,8 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike { adjustClaimHtlcTxOutput(claimHtlc, targetFeerate, dustLimit) match { case Left(_) => assert(targetFeerate >= FeeratePerKw(7000 sat)) case Right(updatedClaimHtlc) => - assert(updatedClaimHtlc.txInfo.tx.txIn.length === 1) - assert(updatedClaimHtlc.txInfo.tx.txOut.length === 1) + assert(updatedClaimHtlc.txInfo.tx.txIn.length == 1) + assert(updatedClaimHtlc.txInfo.tx.txOut.length == 1) assert(updatedClaimHtlc.txInfo.tx.txOut.head.amount < previousAmount) previousAmount = updatedClaimHtlc.txInfo.tx.txOut.head.amount val signedTx = updatedClaimHtlc match { @@ -223,16 +223,16 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike { // We can handle a small feerate update by lowering the change output. val TxOutputAdjusted(feerateUpdate1) = adjustPreviousTxOutput(FundedTx(previousAnchorTx, 12000 sat, FeeratePerKw(2500 sat)), FeeratePerKw(5000 sat), commitments) - assert(feerateUpdate1.txInfo.tx.txIn === previousAnchorTx.txInfo.tx.txIn) - assert(feerateUpdate1.txInfo.tx.txOut.length === 1) + assert(feerateUpdate1.txInfo.tx.txIn == previousAnchorTx.txInfo.tx.txIn) + assert(feerateUpdate1.txInfo.tx.txOut.length == 1) val TxOutputAdjusted(feerateUpdate2) = adjustPreviousTxOutput(FundedTx(previousAnchorTx, 12000 sat, FeeratePerKw(2500 sat)), FeeratePerKw(6000 sat), commitments) - assert(feerateUpdate2.txInfo.tx.txIn === previousAnchorTx.txInfo.tx.txIn) - assert(feerateUpdate2.txInfo.tx.txOut.length === 1) + assert(feerateUpdate2.txInfo.tx.txIn == previousAnchorTx.txInfo.tx.txIn) + assert(feerateUpdate2.txInfo.tx.txOut.length == 1) assert(feerateUpdate2.txInfo.tx.txOut.head.amount < feerateUpdate1.txInfo.tx.txOut.head.amount) // But if the feerate increase is too large, we must add new wallet inputs. val AddWalletInputs(previousTx) = adjustPreviousTxOutput(FundedTx(previousAnchorTx, 12000 sat, FeeratePerKw(2500 sat)), FeeratePerKw(10000 sat), commitments) - assert(previousTx === previousAnchorTx) + assert(previousTx == previousAnchorTx) } test("adjust previous htlc transaction outputs", Tag("fuzzy")) { @@ -259,19 +259,19 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike { // We can handle a small feerate update by lowering the change output. val TxOutputAdjusted(feerateUpdate1) = adjustPreviousTxOutput(FundedTx(previousTx, 15000 sat, FeeratePerKw(2500 sat)), FeeratePerKw(5000 sat), commitments) - assert(feerateUpdate1.txInfo.tx.txIn === previousTx.txInfo.tx.txIn) - assert(feerateUpdate1.txInfo.tx.txOut.length === 2) - assert(feerateUpdate1.txInfo.tx.txOut.head === previousTx.txInfo.tx.txOut.head) + assert(feerateUpdate1.txInfo.tx.txIn == previousTx.txInfo.tx.txIn) + assert(feerateUpdate1.txInfo.tx.txOut.length == 2) + assert(feerateUpdate1.txInfo.tx.txOut.head == previousTx.txInfo.tx.txOut.head) val TxOutputAdjusted(feerateUpdate2) = adjustPreviousTxOutput(FundedTx(previousTx, 15000 sat, FeeratePerKw(2500 sat)), FeeratePerKw(6000 sat), commitments) - assert(feerateUpdate2.txInfo.tx.txIn === previousTx.txInfo.tx.txIn) - assert(feerateUpdate2.txInfo.tx.txOut.length === 2) - assert(feerateUpdate2.txInfo.tx.txOut.head === previousTx.txInfo.tx.txOut.head) + assert(feerateUpdate2.txInfo.tx.txIn == previousTx.txInfo.tx.txIn) + assert(feerateUpdate2.txInfo.tx.txOut.length == 2) + assert(feerateUpdate2.txInfo.tx.txOut.head == previousTx.txInfo.tx.txOut.head) assert(feerateUpdate2.txInfo.tx.txOut.last.amount < feerateUpdate1.txInfo.tx.txOut.last.amount) // If the previous funding attempt didn't add a change output, we must add new wallet inputs. val previousTxNoChange = previousTx.updateTx(previousTx.txInfo.tx.copy(txOut = Seq(previousTx.txInfo.tx.txOut.head))) val AddWalletInputs(tx) = adjustPreviousTxOutput(FundedTx(previousTxNoChange, 25000 sat, FeeratePerKw(2500 sat)), FeeratePerKw(5000 sat), commitments) - assert(tx === previousTxNoChange) + assert(tx == previousTxNoChange) for (_ <- 1 to 100) { val amountIn = Random.nextInt(25_000_000).sat @@ -283,11 +283,11 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike { val targetFeerate = FeeratePerKw(2500 sat) + FeeratePerKw(Random.nextInt(20000).sat) adjustPreviousTxOutput(FundedTx(fuzzyPreviousTx, amountIn, FeeratePerKw(2500 sat)), targetFeerate, commitments) match { case AdjustPreviousTxOutputResult.Skip(_) => // nothing do check - case AddWalletInputs(tx) => assert(tx === fuzzyPreviousTx) + case AddWalletInputs(tx) => assert(tx == fuzzyPreviousTx) case TxOutputAdjusted(updatedTx) => - assert(updatedTx.txInfo.tx.txIn === fuzzyPreviousTx.txInfo.tx.txIn) + assert(updatedTx.txInfo.tx.txIn == fuzzyPreviousTx.txInfo.tx.txIn) assert(Set(1, 2).contains(updatedTx.txInfo.tx.txOut.length)) - assert(updatedTx.txInfo.tx.txOut.head === fuzzyPreviousTx.txInfo.tx.txOut.head) + assert(updatedTx.txInfo.tx.txOut.head == fuzzyPreviousTx.txInfo.tx.txOut.head) assert(updatedTx.txInfo.tx.txOut.last.amount >= 600.sat) } } @@ -308,8 +308,8 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike { case AdjustPreviousTxOutputResult.Skip(_) => assert(targetFeerate >= FeeratePerKw(10000 sat)) case AddWalletInputs(_) => fail("shouldn't add wallet inputs to claim-htlc-tx") case TxOutputAdjusted(updatedTx) => - assert(updatedTx.txInfo.tx.txIn === claimHtlc.txInfo.tx.txIn) - assert(updatedTx.txInfo.tx.txOut.length === 1) + assert(updatedTx.txInfo.tx.txIn == claimHtlc.txInfo.tx.txIn) + assert(updatedTx.txInfo.tx.txOut.length == 1) assert(updatedTx.txInfo.tx.txOut.head.amount < previousAmount) previousAmount = updatedTx.txInfo.tx.txOut.head.amount } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisherSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisherSpec.scala index 9444f32da7..3d136c5ae7 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisherSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/ReplaceableTxPublisherSpec.scala @@ -160,7 +160,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val publishCommitTx = alice2blockchain.expectMsg(PublishFinalTx(commitTx, commitTx.fee, None)) // Forward the anchor tx to the publisher. val publishAnchor = alice2blockchain.expectMsgType[PublishReplaceableTx] - assert(publishAnchor.txInfo.input.outPoint.txid === commitTx.tx.txid) + assert(publishAnchor.txInfo.input.outPoint.txid == commitTx.tx.txid) assert(publishAnchor.txInfo.isInstanceOf[ClaimLocalAnchorOutputTx]) val anchorTx = publishAnchor.txInfo.asInstanceOf[ClaimLocalAnchorOutputTx].copy(confirmBefore = overrideCommitTarget) @@ -177,8 +177,8 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w publisher ! Publish(probe.ref, anchorTx) val result = probe.expectMsgType[TxRejected] - assert(result.cmd === anchorTx) - assert(result.reason === TxSkipped(retryNextBlock = true)) + assert(result.cmd == anchorTx) + assert(result.reason == TxSkipped(retryNextBlock = true)) } } @@ -194,8 +194,8 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w setFeerate(FeeratePerKw(10_000 sat)) publisher ! Publish(probe.ref, anchorTx) val result = probe.expectMsgType[TxRejected] - assert(result.cmd === anchorTx) - assert(result.reason === TxSkipped(retryNextBlock = false)) + assert(result.cmd == anchorTx) + assert(result.reason == TxSkipped(retryNextBlock = false)) } } @@ -212,8 +212,8 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w publisher ! Publish(probe.ref, anchorTx) val result = probe.expectMsgType[TxRejected] - assert(result.cmd === anchorTx) - assert(result.reason === TxSkipped(retryNextBlock = false)) + assert(result.cmd == anchorTx) + assert(result.reason == TxSkipped(retryNextBlock = false)) } } @@ -230,8 +230,8 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w setFeerate(FeeratePerKw(10_000 sat)) publisher ! Publish(probe.ref, anchorTx) val result = probe.expectMsgType[TxRejected] - assert(result.cmd === anchorTx) - assert(result.reason === TxSkipped(retryNextBlock = false)) + assert(result.cmd == anchorTx) + assert(result.reason == TxSkipped(retryNextBlock = false)) } } @@ -247,10 +247,10 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w setFeerate(FeeratePerKw(10_000 sat)) publisher ! Publish(probe.ref, anchorTx) val result = probe.expectMsgType[TxRejected] - assert(result.cmd === anchorTx) + assert(result.cmd == anchorTx) // When the remote commit tx is still unconfirmed, we want to retry in case it is evicted from the mempool and our // commit is then published. - assert(result.reason === TxSkipped(retryNextBlock = true)) + assert(result.reason == TxSkipped(retryNextBlock = true)) } } @@ -259,7 +259,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w import f._ val remoteCommit = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.fullySignedLocalCommitTx(bob.underlyingActor.nodeParams.channelKeyManager) - assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.spec.commitTxFeerate === FeeratePerKw(2500 sat)) + assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.spec.commitTxFeerate == FeeratePerKw(2500 sat)) // We lower the feerate to make it easy to replace our commit tx by theirs in the mempool. val lowFeerate = FeeratePerKw(500 sat) @@ -278,15 +278,15 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val result = probe.expectMsgType[TxRejected] - assert(result.cmd === anchorTx) - assert(result.reason === InputGone) + assert(result.cmd == anchorTx) + assert(result.reason == InputGone) // Since our wallet input is gone, we will retry and discover that a commit tx has been confirmed. val publisher2 = createPublisher() publisher2 ! Publish(probe.ref, anchorTx) val result2 = probe.expectMsgType[TxRejected] - assert(result2.cmd === anchorTx) - assert(result2.reason === TxSkipped(retryNextBlock = false)) + assert(result2.cmd == anchorTx) + assert(result2.reason == TxSkipped(retryNextBlock = false)) } } @@ -300,9 +300,9 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val cmd = anchorTx.copy(commitments = anchorTx.commitments.copy(commitInput = InputInfo(OutPoint(randomBytes32(), 1), TxOut(0 sat, Nil), Nil))) publisher ! Publish(probe.ref, cmd) val result = probe.expectMsgType[TxRejected] - assert(result.cmd === cmd) + assert(result.cmd == cmd) // We should keep retrying until the funding transaction is available. - assert(result.reason === TxSkipped(retryNextBlock = true)) + assert(result.reason == TxSkipped(retryNextBlock = true)) } } @@ -318,10 +318,10 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w setFeerate(FeeratePerKw(25_000 sat)) publisher ! Publish(probe.ref, anchorTx) val result = probe.expectMsgType[TxRejected] - assert(result.cmd === anchorTx) + assert(result.cmd == anchorTx) // When the remote commit tx is still unconfirmed, we want to retry in case it is evicted from the mempool and our // commit is then published. - assert(result.reason === CouldNotFund) + assert(result.reason == CouldNotFund) } } @@ -332,7 +332,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val (commitTx, anchorTx) = closeChannelWithoutHtlcs(f, aliceBlockHeight() + 30) wallet.publishTransaction(commitTx.tx).pipeTo(probe.ref) probe.expectMsg(commitTx.tx.txid) - assert(getMempool().length === 1) + assert(getMempool().length == 1) val targetFeerate = FeeratePerKw(3000 sat) // NB: we try to get transactions confirmed *before* their confirmation target, so we aim for a more aggressive block target what's provided. @@ -349,7 +349,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w generateBlocks(5) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val result = probe.expectMsgType[TxConfirmed] - assert(result.cmd === anchorTx) + assert(result.cmd == anchorTx) assert(result.tx.txIn.map(_.outPoint.txid).contains(commitTx.tx.txid)) assert(mempoolTxs.map(_.txid).contains(result.tx.txid)) } @@ -377,7 +377,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w generateBlocks(5) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val result = probe.expectMsgType[TxConfirmed] - assert(result.cmd === anchorTx) + assert(result.cmd == anchorTx) assert(result.tx.txIn.map(_.outPoint.txid).contains(commitTx.tx.txid)) assert(mempoolTxs.map(_.txid).contains(result.tx.txid)) } @@ -412,7 +412,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w generateBlocks(5) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val result = probe.expectMsgType[TxConfirmed] - assert(result.cmd === anchorTx) + assert(result.cmd == anchorTx) assert(result.tx.txIn.map(_.outPoint.txid).contains(commitTx.tx.txid)) assert(result.tx.txIn.length > 2) // we added more than 1 wallet input assert(mempoolTxs.map(_.txid).contains(result.tx.txid)) @@ -438,7 +438,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w system.eventStream.publish(CurrentBlockHeight(aliceBlockHeight() + 5)) probe.expectNoMessage(500 millis) val mempoolTxs2 = getMempool() - assert(mempoolTxs.map(_.txid).toSet === mempoolTxs2.map(_.txid).toSet) + assert(mempoolTxs.map(_.txid).toSet == mempoolTxs2.map(_.txid).toSet) } } @@ -461,7 +461,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val mempoolTxs1 = getMempoolTxs(2) assert(mempoolTxs1.map(_.txid).contains(commitTx.tx.txid)) val mempoolAnchorTx1 = mempoolTxs1.filter(_.txid != commitTx.tx.txid).head - assert(mempoolAnchorTx1.txid === anchorTxId1) + assert(mempoolAnchorTx1.txid == anchorTxId1) // A new block is found, and the feerate has increased for our block target, so we bump the fees. val newFeerate = FeeratePerKw(5000 sat) @@ -471,7 +471,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w assert(!isInMempool(mempoolAnchorTx1.txid)) val mempoolTxs2 = getMempoolTxs(2) val mempoolAnchorTx2 = mempoolTxs2.filter(_.txid != commitTx.tx.txid).head - assert(mempoolAnchorTx2.txid === anchorTxId2) + assert(mempoolAnchorTx2.txid == anchorTxId2) assert(mempoolAnchorTx1.fees < mempoolAnchorTx2.fees) val targetFee = Transactions.weight2fee(newFeerate, mempoolTxs2.map(_.weight).sum.toInt) @@ -501,14 +501,14 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val mempoolTxs1 = getMempoolTxs(2) assert(mempoolTxs1.map(_.txid).contains(commitTx.tx.txid)) val anchorTx1 = getMempool().filter(_.txid != commitTx.tx.txid).head - assert(anchorTx1.txid === anchorTxId1) + assert(anchorTx1.txid == anchorTxId1) // A new block is found, and the feerate has increased for our block target, so we bump the fees. system.eventStream.publish(CurrentBlockHeight(aliceBlockHeight() + 15)) val anchorTxId2 = listener.expectMsgType[TransactionPublished].tx.txid assert(!isInMempool(anchorTx1.txid)) val anchorTx2 = getMempool().filter(_.txid != commitTx.tx.txid).head - assert(anchorTx2.txid === anchorTxId2) + assert(anchorTx2.txid == anchorTxId2) // We used different inputs to be able to bump to the desired feerate. assert(anchorTx1.txIn.map(_.outPoint).toSet != anchorTx2.txIn.map(_.outPoint).toSet) @@ -549,7 +549,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w case _ => false } val mempoolTxs2 = getMempool() - assert(mempoolTxs1.map(_.txid).toSet === mempoolTxs2.map(_.txid).toSet) + assert(mempoolTxs1.map(_.txid).toSet == mempoolTxs2.map(_.txid).toSet) } } @@ -580,7 +580,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w system.eventStream.publish(CurrentBlockHeight(aliceBlockHeight() + 15)) probe.expectMsgType[NotifyNodeOperator] val mempoolTxs2 = getMempool() - assert(mempoolTxs1.map(_.txid).toSet + walletTx.txid === mempoolTxs2.map(_.txid).toSet) + assert(mempoolTxs1.map(_.txid).toSet + walletTx.txid == mempoolTxs2.map(_.txid).toSet) } } @@ -605,7 +605,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val mempoolTxs1 = getMempoolTxs(2) assert(mempoolTxs1.map(_.txid).contains(commitTx.tx.txid)) val mempoolAnchorTx1 = mempoolTxs1.filter(_.txid != commitTx.tx.txid).head - assert(mempoolAnchorTx1.txid === anchorTxId1) + assert(mempoolAnchorTx1.txid == anchorTxId1) val targetFee1 = Transactions.weight2fee(feerateLow, mempoolTxs1.map(_.weight).sum.toInt) val actualFee1 = mempoolTxs1.map(_.fees).sum assert(targetFee1 * 0.9 <= actualFee1 && actualFee1 <= targetFee1 * 1.1, s"actualFee=$actualFee1 targetFee=$targetFee1") @@ -618,7 +618,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w awaitCond(!isInMempool(mempoolAnchorTx1.txid), interval = 200 millis, max = 30 seconds) val mempoolTxs2 = getMempoolTxs(2) val mempoolAnchorTx2 = mempoolTxs2.filter(_.txid != commitTx.tx.txid).head - assert(mempoolAnchorTx2.txid === anchorTxId2) + assert(mempoolAnchorTx2.txid == anchorTxId2) assert(mempoolAnchorTx1.fees < mempoolAnchorTx2.fees) val targetFee2 = Transactions.weight2fee(feerateHigh, mempoolTxs2.map(_.weight).sum.toInt) @@ -645,7 +645,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val publisher2 = createPublisher() publisher2 ! Publish(probe.ref, anchorTx) val result = probe.expectMsgType[TxRejected] - assert(result.reason === ConflictingTxUnconfirmed) + assert(result.reason == ConflictingTxUnconfirmed) getMempoolTxs(2) // the previous anchor tx and the commit tx are still in the mempool // our parent will stop us when receiving the TxRejected message. @@ -655,7 +655,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w // the first publishing attempt succeeds generateBlocks(5) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) - assert(probe.expectMsgType[TxConfirmed].cmd === anchorTx) + assert(probe.expectMsgType[TxConfirmed].cmd == anchorTx) } } @@ -712,15 +712,15 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val htlcSuccessPublisher = createPublisher() htlcSuccessPublisher ! Publish(probe.ref, htlcSuccess) val result1 = probe.expectMsgType[TxRejected] - assert(result1.cmd === htlcSuccess) - assert(result1.reason === ConflictingTxConfirmed) + assert(result1.cmd == htlcSuccess) + assert(result1.reason == ConflictingTxConfirmed) htlcSuccessPublisher ! Stop val htlcTimeoutPublisher = createPublisher() htlcTimeoutPublisher ! Publish(probe.ref, htlcTimeout) val result2 = probe.expectMsgType[TxRejected] - assert(result2.cmd === htlcTimeout) - assert(result2.reason === ConflictingTxConfirmed) + assert(result2.cmd == htlcTimeout) + assert(result2.reason == ConflictingTxConfirmed) htlcTimeoutPublisher ! Stop } } @@ -738,7 +738,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w // Force-close channel and verify txs sent to watcher. val commitTx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.fullySignedLocalCommitTx(alice.underlyingActor.nodeParams.channelKeyManager) - assert(commitTx.tx.txOut.size === 6) + assert(commitTx.tx.txOut.size == 6) probe.send(alice, CMD_FORCECLOSE(probe.ref)) probe.expectMsgType[CommandSuccess[CMD_FORCECLOSE]] @@ -779,8 +779,8 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w w.replyTo ! WatchParentTxConfirmedTriggered(currentBlockHeight(probe), 0, commitTx) val result = probe.expectMsgType[TxRejected] - assert(result.cmd === htlcSuccess) - assert(result.reason === CouldNotFund) + assert(result.cmd == htlcSuccess) + assert(result.reason == CouldNotFund) htlcSuccessPublisher ! Stop } } @@ -799,7 +799,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w generateBlocks(4) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val htlcSuccessResult = probe.expectMsgType[TxConfirmed] - assert(htlcSuccessResult.cmd === htlcSuccess) + assert(htlcSuccessResult.cmd == htlcSuccess) assert(htlcSuccessResult.tx.txIn.map(_.outPoint.txid).contains(commitTx.txid)) htlcSuccessPublisher ! Stop htlcSuccessResult.tx @@ -828,7 +828,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w generateBlocks(4) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val htlcTimeoutResult = probe.expectMsgType[TxConfirmed] - assert(htlcTimeoutResult.cmd === htlcTimeout) + assert(htlcTimeoutResult.cmd == htlcTimeout) assert(htlcTimeoutResult.tx.txIn.map(_.outPoint.txid).contains(commitTx.txid)) htlcTimeoutPublisher ! Stop htlcTimeoutResult.tx @@ -843,10 +843,10 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w setFeerate(currentFeerate) val htlcSuccessTx = testPublishHtlcSuccess(f, commitTx, htlcSuccess, currentFeerate) assert(htlcSuccess.txInfo.fee > 0.sat) - assert(htlcSuccessTx.txIn.length === 1) + assert(htlcSuccessTx.txIn.length == 1) val htlcTimeoutTx = testPublishHtlcTimeout(f, commitTx, htlcTimeout, currentFeerate) assert(htlcTimeout.txInfo.fee > 0.sat) - assert(htlcTimeoutTx.txIn.length === 1) + assert(htlcTimeoutTx.txIn.length == 1) } } @@ -873,10 +873,10 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val (commitTx, htlcSuccess, htlcTimeout) = closeChannelWithHtlcs(f, aliceBlockHeight() + 30) // NB: we try to get transactions confirmed *before* their confirmation target, so we aim for a more aggressive block target than what's provided. setFeerate(targetFeerate, blockTarget = 12) - assert(htlcSuccess.txInfo.fee === 0.sat) + assert(htlcSuccess.txInfo.fee == 0.sat) val htlcSuccessTx = testPublishHtlcSuccess(f, commitTx, htlcSuccess, targetFeerate) assert(htlcSuccessTx.txIn.length > 1) - assert(htlcTimeout.txInfo.fee === 0.sat) + assert(htlcTimeout.txInfo.fee == 0.sat) val htlcTimeoutTx = testPublishHtlcTimeout(f, commitTx, htlcTimeout, targetFeerate) assert(htlcTimeoutTx.txIn.length > 1) } @@ -890,10 +890,10 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val targetFeerate = commitFeerate / 2 val (commitTx, htlcSuccess, htlcTimeout) = closeChannelWithHtlcs(f, aliceBlockHeight() + 30) setFeerate(targetFeerate) - assert(htlcSuccess.txInfo.fee === 0.sat) + assert(htlcSuccess.txInfo.fee == 0.sat) val htlcSuccessTx = testPublishHtlcSuccess(f, commitTx, htlcSuccess, targetFeerate) assert(htlcSuccessTx.txIn.length > 1) - assert(htlcTimeout.txInfo.fee === 0.sat) + assert(htlcTimeout.txInfo.fee == 0.sat) val htlcTimeoutTx = testPublishHtlcTimeout(f, commitTx, htlcTimeout, targetFeerate) assert(htlcTimeoutTx.txIn.length > 1) } @@ -947,7 +947,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val htlcSuccessTxId1 = listener.expectMsgType[TransactionPublished].tx.txid val htlcSuccessTx1 = getMempoolTxs(1).head val htlcSuccessInputs1 = getMempool().head.txIn.map(_.outPoint).toSet - assert(htlcSuccessTx1.txid === htlcSuccessTxId1) + assert(htlcSuccessTx1.txid == htlcSuccessTxId1) // New blocks are found, which makes us aim for a more aggressive block target, so we bump the fees. val targetFeerate = FeeratePerKw(25_000 sat) @@ -957,9 +957,9 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w assert(!isInMempool(htlcSuccessTx1.txid)) val htlcSuccessTx2 = getMempoolTxs(1).head val htlcSuccessInputs2 = getMempool().head.txIn.map(_.outPoint).toSet - assert(htlcSuccessTx2.txid === htlcSuccessTxId2) + assert(htlcSuccessTx2.txid == htlcSuccessTxId2) assert(htlcSuccessTx1.fees < htlcSuccessTx2.fees) - assert(htlcSuccessInputs1 === htlcSuccessInputs2) + assert(htlcSuccessInputs1 == htlcSuccessInputs2) val htlcSuccessTargetFee = Transactions.weight2fee(targetFeerate, htlcSuccessTx2.weight.toInt) assert(htlcSuccessTargetFee * 0.9 <= htlcSuccessTx2.fees && htlcSuccessTx2.fees <= htlcSuccessTargetFee * 1.4, s"actualFee=${htlcSuccessTx2.fees} targetFee=$htlcSuccessTargetFee") } @@ -983,7 +983,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val htlcSuccessTxId1 = listener.expectMsgType[TransactionPublished].tx.txid val htlcSuccessTx1 = getMempoolTxs(1).head val htlcSuccessInputs1 = getMempool().head.txIn.map(_.outPoint).toSet - assert(htlcSuccessTx1.txid === htlcSuccessTxId1) + assert(htlcSuccessTx1.txid == htlcSuccessTxId1) // New blocks are found, which makes us aim for a more aggressive block target, so we bump the fees. val targetFeerate = FeeratePerKw(75_000 sat) @@ -993,7 +993,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w awaitCond(!isInMempool(htlcSuccessTx1.txid), interval = 200 millis, max = 30 seconds) val htlcSuccessTx2 = getMempoolTxs(1).head val htlcSuccessInputs2 = getMempool().head.txIn.map(_.outPoint).toSet - assert(htlcSuccessTx2.txid === htlcSuccessTxId2) + assert(htlcSuccessTx2.txid == htlcSuccessTxId2) assert(htlcSuccessTx1.fees < htlcSuccessTx2.fees) assert(htlcSuccessInputs1 !== htlcSuccessInputs2) val htlcSuccessTargetFee = Transactions.weight2fee(targetFeerate, htlcSuccessTx2.weight.toInt) @@ -1018,7 +1018,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w w.replyTo ! WatchParentTxConfirmedTriggered(aliceBlockHeight(), 0, commitTx) val htlcSuccessTxId = listener.expectMsgType[TransactionPublished].tx.txid var htlcSuccessTx = getMempoolTxs(1).head - assert(htlcSuccessTx.txid === htlcSuccessTxId) + assert(htlcSuccessTx.txid == htlcSuccessTxId) // We are only 6 blocks away from the confirmation target, so we bump the fees at each new block. (1 to 3).foreach(i => { @@ -1026,7 +1026,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val bumpedHtlcSuccessTxId = listener.expectMsgType[TransactionPublished].tx.txid assert(!isInMempool(htlcSuccessTx.txid)) val bumpedHtlcSuccessTx = getMempoolTxs(1).head - assert(bumpedHtlcSuccessTx.txid === bumpedHtlcSuccessTxId) + assert(bumpedHtlcSuccessTx.txid == bumpedHtlcSuccessTxId) assert(htlcSuccessTx.fees < bumpedHtlcSuccessTx.fees) htlcSuccessTx = bumpedHtlcSuccessTx }) @@ -1054,7 +1054,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val htlcTimeoutTxId1 = listener.expectMsgType[TransactionPublished].tx.txid val htlcTimeoutTx1 = getMempoolTxs(1).head val htlcTimeoutInputs1 = getMempool().head.txIn.map(_.outPoint).toSet - assert(htlcTimeoutTx1.txid === htlcTimeoutTxId1) + assert(htlcTimeoutTx1.txid == htlcTimeoutTxId1) // A new block is found, and we've already reached the confirmation target, so we bump the fees. system.eventStream.publish(CurrentBlockHeight(aliceBlockHeight() + 145)) @@ -1062,9 +1062,9 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w assert(!isInMempool(htlcTimeoutTx1.txid)) val htlcTimeoutTx2 = getMempoolTxs(1).head val htlcTimeoutInputs2 = getMempool().head.txIn.map(_.outPoint).toSet - assert(htlcTimeoutTx2.txid === htlcTimeoutTxId2) + assert(htlcTimeoutTx2.txid == htlcTimeoutTxId2) assert(htlcTimeoutTx1.fees < htlcTimeoutTx2.fees) - assert(htlcTimeoutInputs1 === htlcTimeoutInputs2) + assert(htlcTimeoutInputs1 == htlcTimeoutInputs2) // Once the confirmation target is reach, we should raise the feerate by at least 20% at every block. val htlcTimeoutTargetFee = Transactions.weight2fee(feerate * 1.2, htlcTimeoutTx2.weight.toInt) assert(htlcTimeoutTargetFee * 0.9 <= htlcTimeoutTx2.fees && htlcTimeoutTx2.fees <= htlcTimeoutTargetFee * 1.1, s"actualFee=${htlcTimeoutTx2.fees} targetFee=$htlcTimeoutTargetFee") @@ -1113,7 +1113,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val w2 = alice2blockchain.expectMsgType[WatchParentTxConfirmed] w2.replyTo ! WatchParentTxConfirmedTriggered(currentBlockHeight(probe), 0, commitTx) val result = probe.expectMsgType[TxRejected] - assert(result.reason === ConflictingTxUnconfirmed) + assert(result.reason == ConflictingTxUnconfirmed) getMempoolTxs(1) // the previous htlc-success tx is still in the mempool // our parent will stop us when receiving the TxRejected message. @@ -1123,7 +1123,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w // the first publishing attempt succeeds generateBlocks(5) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) - assert(probe.expectMsgType[TxConfirmed].cmd === htlcSuccess) + assert(probe.expectMsgType[TxConfirmed].cmd == htlcSuccess) publisher1 ! Stop } } @@ -1160,7 +1160,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w // Force-close channel. val localCommitTx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.fullySignedLocalCommitTx(alice.underlyingActor.nodeParams.channelKeyManager) val remoteCommitTx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.fullySignedLocalCommitTx(bob.underlyingActor.nodeParams.channelKeyManager) - assert(remoteCommitTx.tx.txOut.size === 6) + assert(remoteCommitTx.tx.txOut.size == 6) probe.send(alice, WatchFundingSpentTriggered(remoteCommitTx.tx)) alice2blockchain.expectMsgType[PublishFinalTx] // claim main output val claimHtlcTimeout = alice2blockchain.expectMsgType[PublishReplaceableTx] @@ -1178,15 +1178,15 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val claimHtlcSuccessPublisher = createPublisher() claimHtlcSuccessPublisher ! Publish(probe.ref, claimHtlcSuccess) val result1 = probe.expectMsgType[TxRejected] - assert(result1.cmd === claimHtlcSuccess) - assert(result1.reason === ConflictingTxConfirmed) + assert(result1.cmd == claimHtlcSuccess) + assert(result1.reason == ConflictingTxConfirmed) claimHtlcSuccessPublisher ! Stop val claimHtlcTimeoutPublisher = createPublisher() claimHtlcTimeoutPublisher ! Publish(probe.ref, claimHtlcTimeout) val result2 = probe.expectMsgType[TxRejected] - assert(result2.cmd === claimHtlcTimeout) - assert(result2.reason === ConflictingTxConfirmed) + assert(result2.cmd == claimHtlcTimeout) + assert(result2.reason == ConflictingTxConfirmed) claimHtlcTimeoutPublisher ! Stop } } @@ -1205,9 +1205,9 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w // Force-close channel and verify txs sent to watcher. val remoteCommitTx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.fullySignedLocalCommitTx(bob.underlyingActor.nodeParams.channelKeyManager) if (bob.stateData.asInstanceOf[DATA_NORMAL].commitments.commitmentFormat == DefaultCommitmentFormat) { - assert(remoteCommitTx.tx.txOut.size === 4) + assert(remoteCommitTx.tx.txOut.size == 4) } else { - assert(remoteCommitTx.tx.txOut.size === 6) + assert(remoteCommitTx.tx.txOut.size == 6) } probe.send(alice, WatchFundingSpentTriggered(remoteCommitTx.tx)) @@ -1247,7 +1247,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w generateBlocks(4) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val claimHtlcSuccessResult = probe.expectMsgType[TxConfirmed] - assert(claimHtlcSuccessResult.cmd === claimHtlcSuccess) + assert(claimHtlcSuccessResult.cmd == claimHtlcSuccess) assert(claimHtlcSuccessResult.tx.txIn.map(_.outPoint.txid).contains(remoteCommitTx.txid)) claimHtlcSuccessPublisher ! Stop claimHtlcSuccessResult.tx @@ -1276,7 +1276,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w generateBlocks(4) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val claimHtlcTimeoutResult = probe.expectMsgType[TxConfirmed] - assert(claimHtlcTimeoutResult.cmd === claimHtlcTimeout) + assert(claimHtlcTimeoutResult.cmd == claimHtlcTimeout) assert(claimHtlcTimeoutResult.tx.txIn.map(_.outPoint.txid).contains(remoteCommitTx.txid)) claimHtlcTimeoutPublisher ! Stop claimHtlcTimeoutResult.tx @@ -1290,10 +1290,10 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val (remoteCommitTx, claimHtlcSuccess, claimHtlcTimeout) = remoteCloseChannelWithHtlcs(f, aliceBlockHeight() + 50) val claimHtlcSuccessTx = testPublishClaimHtlcSuccess(f, remoteCommitTx, claimHtlcSuccess, currentFeerate) assert(claimHtlcSuccess.txInfo.fee > 0.sat) - assert(claimHtlcSuccessTx.txIn.length === 1) + assert(claimHtlcSuccessTx.txIn.length == 1) val claimHtlcTimeoutTx = testPublishClaimHtlcTimeout(f, remoteCommitTx, claimHtlcTimeout, currentFeerate) assert(claimHtlcTimeout.txInfo.fee > 0.sat) - assert(claimHtlcTimeoutTx.txIn.length === 1) + assert(claimHtlcTimeoutTx.txIn.length == 1) } } @@ -1306,12 +1306,12 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w // NB: we try to get transactions confirmed *before* their confirmation target, so we aim for a more aggressive block target than what's provided. setFeerate(targetFeerate, blockTarget = 12) val claimHtlcSuccessTx = testPublishClaimHtlcSuccess(f, remoteCommitTx, claimHtlcSuccess, targetFeerate) - assert(claimHtlcSuccessTx.txIn.length === 1) - assert(claimHtlcSuccessTx.txOut.length === 1) + assert(claimHtlcSuccessTx.txIn.length == 1) + assert(claimHtlcSuccessTx.txOut.length == 1) assert(claimHtlcSuccessTx.txOut.head.amount < claimHtlcSuccess.txInfo.tx.txOut.head.amount) val claimHtlcTimeoutTx = testPublishClaimHtlcTimeout(f, remoteCommitTx, claimHtlcTimeout, targetFeerate) - assert(claimHtlcTimeoutTx.txIn.length === 1) - assert(claimHtlcTimeoutTx.txOut.length === 1) + assert(claimHtlcTimeoutTx.txIn.length == 1) + assert(claimHtlcTimeoutTx.txOut.length == 1) assert(claimHtlcTimeoutTx.txOut.head.amount < claimHtlcTimeout.txInfo.tx.txOut.head.amount) } } @@ -1333,7 +1333,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w generateBlocks(4) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val claimHtlcSuccessResult = probe.expectMsgType[TxConfirmed] - assert(claimHtlcSuccessResult.cmd === claimHtlcSuccess) + assert(claimHtlcSuccessResult.cmd == claimHtlcSuccess) assert(claimHtlcSuccessResult.tx.txIn.map(_.outPoint.txid).contains(remoteCommitTx.txid)) claimHtlcSuccessPublisher ! Stop @@ -1350,7 +1350,7 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w generateBlocks(4) system.eventStream.publish(CurrentBlockHeight(currentBlockHeight(probe))) val claimHtlcTimeoutResult = probe.expectMsgType[TxConfirmed] - assert(claimHtlcTimeoutResult.cmd === claimHtlcTimeout) + assert(claimHtlcTimeoutResult.cmd == claimHtlcTimeout) assert(claimHtlcTimeoutResult.tx.txIn.map(_.outPoint.txid).contains(remoteCommitTx.txid)) claimHtlcTimeoutPublisher ! Stop } @@ -1368,8 +1368,8 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val w1 = alice2blockchain.expectMsgType[WatchParentTxConfirmed] w1.replyTo ! WatchParentTxConfirmedTriggered(currentBlockHeight(probe), 0, remoteCommitTx) val result1 = probe.expectMsgType[TxRejected] - assert(result1.cmd === claimHtlcSuccess) - assert(result1.reason === TxSkipped(retryNextBlock = true)) + assert(result1.cmd == claimHtlcSuccess) + assert(result1.reason == TxSkipped(retryNextBlock = true)) claimHtlcSuccessPublisher ! Stop val claimHtlcTimeoutPublisher = createPublisher() @@ -1379,8 +1379,8 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val w2 = alice2blockchain.expectMsgType[WatchParentTxConfirmed] w2.replyTo ! WatchParentTxConfirmedTriggered(currentBlockHeight(probe), 0, remoteCommitTx) val result2 = probe.expectMsgType[TxRejected] - assert(result2.cmd === claimHtlcTimeout) - assert(result2.reason === TxSkipped(retryNextBlock = true)) + assert(result2.cmd == claimHtlcTimeout) + assert(result2.reason == TxSkipped(retryNextBlock = true)) claimHtlcTimeoutPublisher ! Stop } } @@ -1402,21 +1402,21 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val claimHtlcSuccessPublisher = createPublisher() claimHtlcSuccessPublisher ! Publish(probe.ref, claimHtlcSuccess) val claimHtlcSuccessTx1 = getMempoolTxs(1).head - assert(listener.expectMsgType[TransactionPublished].tx.txid === claimHtlcSuccessTx1.txid) + assert(listener.expectMsgType[TransactionPublished].tx.txid == claimHtlcSuccessTx1.txid) setFeerate(targetFeerate) system.eventStream.publish(CurrentBlockHeight(aliceBlockHeight() + 5)) val claimHtlcSuccessTxId2 = listener.expectMsgType[TransactionPublished].tx.txid assert(!isInMempool(claimHtlcSuccessTx1.txid)) val claimHtlcSuccessTx2 = getMempoolTxs(1).head - assert(claimHtlcSuccessTx2.txid === claimHtlcSuccessTxId2) + assert(claimHtlcSuccessTx2.txid == claimHtlcSuccessTxId2) assert(claimHtlcSuccessTx1.fees < claimHtlcSuccessTx2.fees) val targetHtlcSuccessFee = Transactions.weight2fee(targetFeerate, claimHtlcSuccessTx2.weight.toInt) assert(targetHtlcSuccessFee * 0.9 <= claimHtlcSuccessTx2.fees && claimHtlcSuccessTx2.fees <= targetHtlcSuccessFee * 1.1, s"actualFee=${claimHtlcSuccessTx2.fees} targetFee=$targetHtlcSuccessFee") val finalHtlcSuccessTx = getMempool().head - assert(finalHtlcSuccessTx.txIn.length === 1) - assert(finalHtlcSuccessTx.txOut.length === 1) - assert(finalHtlcSuccessTx.txIn.head.outPoint.txid === remoteCommitTx.txid) + assert(finalHtlcSuccessTx.txIn.length == 1) + assert(finalHtlcSuccessTx.txOut.length == 1) + assert(finalHtlcSuccessTx.txIn.head.outPoint.txid == remoteCommitTx.txid) // The Claim-HTLC-timeout will be published after the timeout. setFeerate(initialFeerate) @@ -1424,23 +1424,23 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w claimHtlcTimeoutPublisher ! Publish(probe.ref, claimHtlcTimeout) generateBlocks(144) system.eventStream.publish(CurrentBlockHeight(aliceBlockHeight() + 144)) - assert(probe.expectMsgType[TxConfirmed].tx.txid === finalHtlcSuccessTx.txid) // the claim-htlc-success is now confirmed + assert(probe.expectMsgType[TxConfirmed].tx.txid == finalHtlcSuccessTx.txid) // the claim-htlc-success is now confirmed val claimHtlcTimeoutTx1 = getMempoolTxs(1).head - assert(listener.expectMsgType[TransactionPublished].tx.txid === claimHtlcTimeoutTx1.txid) + assert(listener.expectMsgType[TransactionPublished].tx.txid == claimHtlcTimeoutTx1.txid) setFeerate(targetFeerate) system.eventStream.publish(CurrentBlockHeight(aliceBlockHeight() + 145)) val claimHtlcTimeoutTxId2 = listener.expectMsgType[TransactionPublished].tx.txid assert(!isInMempool(claimHtlcTimeoutTx1.txid)) val claimHtlcTimeoutTx2 = getMempoolTxs(1).head - assert(claimHtlcTimeoutTx2.txid === claimHtlcTimeoutTxId2) + assert(claimHtlcTimeoutTx2.txid == claimHtlcTimeoutTxId2) assert(claimHtlcTimeoutTx1.fees < claimHtlcTimeoutTx2.fees) val targetHtlcTimeoutFee = Transactions.weight2fee(targetFeerate, claimHtlcTimeoutTx2.weight.toInt) assert(targetHtlcTimeoutFee * 0.9 <= claimHtlcTimeoutTx2.fees && claimHtlcTimeoutTx2.fees <= targetHtlcTimeoutFee * 1.1, s"actualFee=${claimHtlcTimeoutTx2.fees} targetFee=$targetHtlcTimeoutFee") val finalHtlcTimeoutTx = getMempool().head - assert(finalHtlcTimeoutTx.txIn.length === 1) - assert(finalHtlcTimeoutTx.txOut.length === 1) - assert(finalHtlcTimeoutTx.txIn.head.outPoint.txid === remoteCommitTx.txid) + assert(finalHtlcTimeoutTx.txIn.length == 1) + assert(finalHtlcTimeoutTx.txOut.length == 1) + assert(finalHtlcTimeoutTx.txIn.head.outPoint.txid == remoteCommitTx.txid) } } @@ -1459,14 +1459,14 @@ class ReplaceableTxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike w val w1 = alice2blockchain.expectMsgType[WatchParentTxConfirmed] w1.replyTo ! WatchParentTxConfirmedTriggered(currentBlockHeight(probe), 0, remoteCommitTx) val claimHtlcSuccessTx = getMempoolTxs(1).head - assert(listener.expectMsgType[TransactionPublished].tx.txid === claimHtlcSuccessTx.txid) + assert(listener.expectMsgType[TransactionPublished].tx.txid == claimHtlcSuccessTx.txid) // New blocks are found and the feerate is higher, but the htlc would become dust, so we don't bump the fees. setFeerate(FeeratePerKw(50_000 sat)) system.eventStream.publish(CurrentBlockHeight(aliceBlockHeight() + 5)) probe.expectNoMessage(500 millis) val mempoolTxs = getMempool() - assert(mempoolTxs.map(_.txid).toSet === Set(claimHtlcSuccessTx.txid)) + assert(mempoolTxs.map(_.txid).toSet == Set(claimHtlcSuccessTx.txid)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/TxPublisherSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/TxPublisherSpec.scala index f4c58a4446..fdd48f7443 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/TxPublisherSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/TxPublisherSpec.scala @@ -75,7 +75,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { val cmd = PublishFinalTx(tx, tx.txIn.head.outPoint, "final-tx", 5 sat, None) txPublisher ! cmd val child = factory.expectMsgType[FinalTxPublisherSpawned].actor - assert(child.expectMsgType[FinalTxPublisher.Publish].cmd === cmd) + assert(child.expectMsgType[FinalTxPublisher.Publish].cmd == cmd) } test("publish final tx duplicate") { f => @@ -107,7 +107,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { txPublisher ! cmd val child = factory.expectMsgType[ReplaceableTxPublisherSpawned].actor val p = child.expectMsgType[ReplaceableTxPublisher.Publish] - assert(p.cmd === cmd) + assert(p.cmd == cmd) } test("publish replaceable tx duplicate") { f => @@ -119,7 +119,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { val cmd = PublishReplaceableTx(anchorTx, null) txPublisher ! cmd val child = factory.expectMsgType[ReplaceableTxPublisherSpawned].actor - assert(child.expectMsgType[ReplaceableTxPublisher.Publish].cmd === cmd) + assert(child.expectMsgType[ReplaceableTxPublisher.Publish].cmd == cmd) // We ignore duplicates that don't use a more aggressive confirmation target: txPublisher ! PublishReplaceableTx(anchorTx, null) @@ -192,7 +192,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { // We automatically retry the failed attempt with new wallet inputs: val attempt3 = factory.expectMsgType[ReplaceableTxPublisherSpawned] - assert(attempt3.actor.expectMsgType[ReplaceableTxPublisher.Publish].cmd === cmd2) + assert(attempt3.actor.expectMsgType[ReplaceableTxPublisher.Publish].cmd == cmd2) } test("publishing attempt fails (main input gone)") { f => @@ -212,7 +212,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { factory.expectNoMessage(100 millis) system.eventStream.publish(CurrentBlockHeight(BlockHeight(8200))) val attempt2 = factory.expectMsgType[FinalTxPublisherSpawned] - assert(attempt2.actor.expectMsgType[FinalTxPublisher.Publish].cmd === cmd) + assert(attempt2.actor.expectMsgType[FinalTxPublisher.Publish].cmd == cmd) } test("publishing attempt fails (not enough funds)") { f => @@ -233,7 +233,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { factory.expectNoMessage(100 millis) system.eventStream.publish(CurrentBlockHeight(BlockHeight(8200))) val attempt2 = factory.expectMsgType[ReplaceableTxPublisherSpawned] - assert(attempt2.actor.expectMsgType[ReplaceableTxPublisher.Publish].cmd === cmd) + assert(attempt2.actor.expectMsgType[ReplaceableTxPublisher.Publish].cmd == cmd) } test("publishing attempt fails (transaction skipped)") { f => @@ -259,7 +259,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { system.eventStream.publish(CurrentBlockHeight(BlockHeight(8200))) val attempt3 = factory.expectMsgType[FinalTxPublisherSpawned] - assert(attempt3.actor.expectMsgType[publish.FinalTxPublisher.Publish].cmd === cmd2) + assert(attempt3.actor.expectMsgType[publish.FinalTxPublisher.Publish].cmd == cmd2) factory.expectNoMessage(100 millis) } @@ -297,7 +297,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { // We retry when a new block is found: system.eventStream.publish(CurrentBlockHeight(nodeParams.currentBlockHeight + 1)) val attempt2 = factory.expectMsgType[ReplaceableTxPublisherSpawned] - assert(attempt2.actor.expectMsgType[ReplaceableTxPublisher.Publish].cmd === cmd) + assert(attempt2.actor.expectMsgType[ReplaceableTxPublisher.Publish].cmd == cmd) } test("publishing attempt fails (confirmed conflicting transaction)") { f => @@ -339,9 +339,9 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { // No attempts. val attempts = PublishAttempts.empty assert(attempts.isEmpty) - assert(attempts.count === 0) + assert(attempts.count == 0) assert(attempts.attempts.isEmpty) - assert(attempts.remove(UUID.randomUUID()) === (Nil, attempts)) + assert(attempts.remove(UUID.randomUUID()) == (Nil, attempts)) } { // Only final attempts. @@ -349,19 +349,19 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { val attempt2 = FinalAttempt(UUID.randomUUID(), null, null) val attempts = PublishAttempts.empty.add(attempt1).add(attempt2) assert(!attempts.isEmpty) - assert(attempts.count === 2) + assert(attempts.count == 2) assert(attempts.replaceableAttempt_opt.isEmpty) - assert(attempts.remove(UUID.randomUUID()) === (Nil, attempts)) - assert(attempts.remove(attempt1.id) === (Seq(attempt1), PublishAttempts(Seq(attempt2), None))) + assert(attempts.remove(UUID.randomUUID()) == (Nil, attempts)) + assert(attempts.remove(attempt1.id) == (Seq(attempt1), PublishAttempts(Seq(attempt2), None))) } { // Only replaceable attempts. val attempt = ReplaceableAttempt(UUID.randomUUID(), null, BlockHeight(0), null) val attempts = PublishAttempts(Nil, Some(attempt)) assert(!attempts.isEmpty) - assert(attempts.count === 1) - assert(attempts.remove(UUID.randomUUID()) === (Nil, attempts)) - assert(attempts.remove(attempt.id) === (Seq(attempt), PublishAttempts.empty)) + assert(attempts.count == 1) + assert(attempts.remove(UUID.randomUUID()) == (Nil, attempts)) + assert(attempts.remove(attempt.id) == (Seq(attempt), PublishAttempts.empty)) } { // Mix of final and replaceable attempts with the same id. @@ -370,9 +370,9 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { val attempt3 = FinalAttempt(UUID.randomUUID(), null, null) val attempts = PublishAttempts(Seq(attempt2), Some(attempt1)).add(attempt3) assert(!attempts.isEmpty) - assert(attempts.count === 3) - assert(attempts.remove(attempt3.id) === (Seq(attempt3), PublishAttempts(Seq(attempt2), Some(attempt1)))) - assert(attempts.remove(attempt1.id) === (Seq(attempt2, attempt1), PublishAttempts(Seq(attempt3), None))) + assert(attempts.count == 3) + assert(attempts.remove(attempt3.id) == (Seq(attempt3), PublishAttempts(Seq(attempt2), Some(attempt1)))) + assert(attempts.remove(attempt1.id) == (Seq(attempt2, attempt1), PublishAttempts(Seq(attempt3), None))) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/TxTimeLocksMonitorSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/TxTimeLocksMonitorSpec.scala index eafbc13294..0795a5dad1 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/TxTimeLocksMonitorSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/publish/TxTimeLocksMonitorSpec.scala @@ -67,8 +67,8 @@ class TxTimeLocksMonitorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik monitor ! CheckTx(probe.ref, tx, "relative-delay") val w = watcher.expectMsgType[WatchParentTxConfirmed] - assert(w.txId === parentTx.txid) - assert(w.minDepth === 3) + assert(w.txId == parentTx.txid) + assert(w.minDepth == 3) probe.expectNoMessage(100 millis) w.replyTo ! WatchParentTxConfirmedTriggered(BlockHeight(651), 0, parentTx) @@ -92,7 +92,7 @@ class TxTimeLocksMonitorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik val w1 = watcher.expectMsgType[WatchParentTxConfirmed] val w2 = watcher.expectMsgType[WatchParentTxConfirmed] watcher.expectNoMessage(100 millis) - assert(Seq(w1, w2).map(w => (w.txId, w.minDepth)).toSet === Set((parentTx1.txid, 3), (parentTx2.txid, 1))) + assert(Seq(w1, w2).map(w => (w.txId, w.minDepth)).toSet == Set((parentTx1.txid, 3), (parentTx2.txid, 1))) probe.expectNoMessage(100 millis) w1.replyTo ! WatchParentTxConfirmedTriggered(BlockHeight(651), 0, parentTx1) @@ -121,7 +121,7 @@ class TxTimeLocksMonitorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLik val w1 = watcher.expectMsgType[WatchParentTxConfirmed] val w2 = watcher.expectMsgType[WatchParentTxConfirmed] watcher.expectNoMessage(100 millis) - assert(Seq(w1, w2).map(w => (w.txId, w.minDepth)).toSet === Set((parentTx1.txid, 3), (parentTx2.txid, 6))) + assert(Seq(w1, w2).map(w => (w.txId, w.minDepth)).toSet == Set((parentTx1.txid, 3), (parentTx2.txid, 6))) probe.expectNoMessage(100 millis) w1.replyTo ! WatchParentTxConfirmedTriggered(BlockHeight(651), 0, parentTx1) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala index a5461c8fcc..c470e466d1 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/ChannelStateTestsHelperMethods.scala @@ -205,9 +205,9 @@ trait ChannelStateTestsBase extends Assertions with Eventually { val aliceInit = Init(aliceParams.initFeatures) val bobInit = Init(bobParams.initFeatures) alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, fundingSatoshis, pushMsat, commitTxFeerate, TestConstants.feeratePerKw, aliceParams, alice2bob.ref, bobInit, channelFlags, channelConfig, channelType) - assert(alice2blockchain.expectMsgType[TxPublisher.SetChannelId].channelId === ByteVector32.Zeroes) + assert(alice2blockchain.expectMsgType[TxPublisher.SetChannelId].channelId == ByteVector32.Zeroes) bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, aliceInit, channelConfig, channelType) - assert(bob2blockchain.expectMsgType[TxPublisher.SetChannelId].channelId === ByteVector32.Zeroes) + assert(bob2blockchain.expectMsgType[TxPublisher.SetChannelId].channelId == ByteVector32.Zeroes) alice2bob.expectMsgType[OpenChannel] alice2bob.forward(bob) bob2alice.expectMsgType[AcceptChannel] @@ -417,8 +417,8 @@ trait ChannelStateTestsBase extends Assertions with Eventually { } // we watch the confirmation of the "final" transactions that send funds to our wallets (main delayed output and 2nd stage htlc transactions) - assert(s2blockchain.expectMsgType[WatchTxConfirmed].txId === commitTx.txid) - localCommitPublished.claimMainDelayedOutputTx.foreach(claimMain => assert(s2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.tx.txid)) + assert(s2blockchain.expectMsgType[WatchTxConfirmed].txId == commitTx.txid) + localCommitPublished.claimMainDelayedOutputTx.foreach(claimMain => assert(s2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.tx.txid)) // we watch outputs of the commitment tx that both parties may spend and anchor outputs val watchedOutputIndexes = localCommitPublished.htlcTxs.keySet.map(_.index) ++ localCommitPublished.claimAnchorTxs.collect { case tx: ClaimLocalAnchorOutputTx => tx.input.outPoint.index } @@ -453,8 +453,8 @@ trait ChannelStateTestsBase extends Assertions with Eventually { assert(publishedClaimHtlcTxs.map(_.input).toSet == claimHtlcTxs.map(_.input.outPoint).toSet) // we watch the confirmation of the "final" transactions that send funds to our wallets (main delayed output and 2nd stage htlc transactions) - assert(s2blockchain.expectMsgType[WatchTxConfirmed].txId === rCommitTx.txid) - remoteCommitPublished.claimMainOutputTx.foreach(claimMain => assert(s2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.tx.txid)) + assert(s2blockchain.expectMsgType[WatchTxConfirmed].txId == rCommitTx.txid) + remoteCommitPublished.claimMainOutputTx.foreach(claimMain => assert(s2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.tx.txid)) // we watch outputs of the commitment tx that both parties may spend val htlcOutputIndexes = remoteCommitPublished.claimHtlcTxs.keySet.map(_.index) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForAcceptChannelStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForAcceptChannelStateSpec.scala index 11f6dc52ba..0fa87ba812 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForAcceptChannelStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForAcceptChannelStateSpec.scala @@ -76,8 +76,8 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS import f._ val accept = bob2alice.expectMsgType[AcceptChannel] // Since https://github.com/lightningnetwork/lightning-rfc/pull/714 we must include an empty upfront_shutdown_script. - assert(accept.upfrontShutdownScript_opt === Some(ByteVector.empty)) - assert(accept.channelType_opt === Some(ChannelTypes.Standard)) + assert(accept.upfrontShutdownScript_opt == Some(ByteVector.empty)) + assert(accept.channelType_opt == Some(ChannelTypes.Standard)) bob2alice.forward(alice) awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL) aliceOrigin.expectNoMessage() @@ -86,39 +86,39 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS test("recv AcceptChannel (anchor outputs)", Tag(ChannelStateTestsTags.AnchorOutputs)) { f => import f._ val accept = bob2alice.expectMsgType[AcceptChannel] - assert(accept.channelType_opt === Some(ChannelTypes.AnchorOutputs)) + assert(accept.channelType_opt == Some(ChannelTypes.AnchorOutputs)) bob2alice.forward(alice) awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL) - assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType === ChannelTypes.AnchorOutputs) + assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType == ChannelTypes.AnchorOutputs) aliceOrigin.expectNoMessage() } test("recv AcceptChannel (anchor outputs zero fee htlc txs)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs)) { f => import f._ val accept = bob2alice.expectMsgType[AcceptChannel] - assert(accept.channelType_opt === Some(ChannelTypes.AnchorOutputsZeroFeeHtlcTx)) + assert(accept.channelType_opt == Some(ChannelTypes.AnchorOutputsZeroFeeHtlcTx)) bob2alice.forward(alice) awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL) - assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType === ChannelTypes.AnchorOutputsZeroFeeHtlcTx) + assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType == ChannelTypes.AnchorOutputsZeroFeeHtlcTx) aliceOrigin.expectNoMessage() } test("recv AcceptChannel (channel type not set)", Tag(ChannelStateTestsTags.AnchorOutputs)) { f => import f._ val accept = bob2alice.expectMsgType[AcceptChannel] - assert(accept.channelType_opt === Some(ChannelTypes.AnchorOutputs)) + assert(accept.channelType_opt == Some(ChannelTypes.AnchorOutputs)) // Alice explicitly asked for an anchor output channel. Bob doesn't support explicit channel type negotiation but // they both activated anchor outputs so it is the default choice anyway. bob2alice.forward(alice, accept.copy(tlvStream = TlvStream(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.empty)))) awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL) - assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType === ChannelTypes.AnchorOutputs) + assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType == ChannelTypes.AnchorOutputs) aliceOrigin.expectNoMessage() } test("recv AcceptChannel (channel type not set but feature bit set)", Tag(ChannelStateTestsTags.ChannelType), Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs)) { f => import f._ val accept = bob2alice.expectMsgType[AcceptChannel] - assert(accept.channelType_opt === Some(ChannelTypes.AnchorOutputsZeroFeeHtlcTx)) + assert(accept.channelType_opt == Some(ChannelTypes.AnchorOutputsZeroFeeHtlcTx)) bob2alice.forward(alice, accept.copy(tlvStream = TlvStream.empty)) alice2bob.expectMsg(Error(accept.temporaryChannelId, "option_channel_type was negotiated but channel_type is missing")) awaitCond(alice.stateName == CLOSED) @@ -129,17 +129,17 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS import f._ val accept = bob2alice.expectMsgType[AcceptChannel] // Alice asked for a standard channel whereas they both support anchor outputs. - assert(accept.channelType_opt === Some(ChannelTypes.Standard)) + assert(accept.channelType_opt == Some(ChannelTypes.Standard)) bob2alice.forward(alice, accept) awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL) - assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType === ChannelTypes.Standard) + assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType == ChannelTypes.Standard) aliceOrigin.expectNoMessage() } test("recv AcceptChannel (non-default channel type not set)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs), Tag("standard-channel-type")) { f => import f._ val accept = bob2alice.expectMsgType[AcceptChannel] - assert(accept.channelType_opt === Some(ChannelTypes.Standard)) + assert(accept.channelType_opt == Some(ChannelTypes.Standard)) // Alice asked for a standard channel whereas they both support anchor outputs. Bob doesn't support explicit channel // type negotiation so Alice needs to abort because the channel types won't match. bob2alice.forward(alice, accept.copy(tlvStream = TlvStream(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.empty)))) @@ -159,20 +159,20 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, TestConstants.anchorOutputsFeeratePerKw, TestConstants.feeratePerKw, aliceParams, alice2bob.ref, Init(bobParams.initFeatures), ChannelFlags.Private, channelConfig, ChannelTypes.AnchorOutputs) bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, Init(bobParams.initFeatures), channelConfig, ChannelTypes.AnchorOutputs) val open = alice2bob.expectMsgType[OpenChannel] - assert(open.channelType_opt === Some(ChannelTypes.AnchorOutputs)) + assert(open.channelType_opt == Some(ChannelTypes.AnchorOutputs)) alice2bob.forward(bob, open) val accept = bob2alice.expectMsgType[AcceptChannel] - assert(accept.channelType_opt === Some(ChannelTypes.AnchorOutputs)) + assert(accept.channelType_opt == Some(ChannelTypes.AnchorOutputs)) bob2alice.forward(alice, accept) awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL) - assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType === ChannelTypes.AnchorOutputs) + assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType == ChannelTypes.AnchorOutputs) aliceOrigin.expectNoMessage() } test("recv AcceptChannel (invalid channel type)") { f => import f._ val accept = bob2alice.expectMsgType[AcceptChannel] - assert(accept.channelType_opt === Some(ChannelTypes.Standard)) + assert(accept.channelType_opt == Some(ChannelTypes.Standard)) val invalidAccept = accept.copy(tlvStream = TlvStream(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.empty), ChannelTlv.ChannelTypeTlv(ChannelTypes.AnchorOutputs))) bob2alice.forward(alice, invalidAccept) alice2bob.expectMsg(Error(accept.temporaryChannelId, "invalid channel_type=anchor_outputs, expected channel_type=standard")) @@ -187,7 +187,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS val invalidMaxAcceptedHtlcs = 484 alice ! accept.copy(maxAcceptedHtlcs = invalidMaxAcceptedHtlcs) val error = alice2bob.expectMsgType[Error] - assert(error === Error(accept.temporaryChannelId, InvalidMaxAcceptedHtlcs(accept.temporaryChannelId, invalidMaxAcceptedHtlcs, Channel.MAX_ACCEPTED_HTLCS).getMessage)) + assert(error == Error(accept.temporaryChannelId, InvalidMaxAcceptedHtlcs(accept.temporaryChannelId, invalidMaxAcceptedHtlcs, Channel.MAX_ACCEPTED_HTLCS).getMessage)) awaitCond(alice.stateName == CLOSED) aliceOrigin.expectMsgType[Status.Failure] } @@ -199,7 +199,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS val lowDustLimitSatoshis = 353.sat alice ! accept.copy(dustLimitSatoshis = lowDustLimitSatoshis) val error = alice2bob.expectMsgType[Error] - assert(error === Error(accept.temporaryChannelId, DustLimitTooSmall(accept.temporaryChannelId, lowDustLimitSatoshis, Channel.MIN_DUST_LIMIT).getMessage)) + assert(error == Error(accept.temporaryChannelId, DustLimitTooSmall(accept.temporaryChannelId, lowDustLimitSatoshis, Channel.MIN_DUST_LIMIT).getMessage)) awaitCond(alice.stateName == CLOSED) aliceOrigin.expectMsgType[Status.Failure] } @@ -210,7 +210,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS val highDustLimitSatoshis = 2000.sat alice ! accept.copy(dustLimitSatoshis = highDustLimitSatoshis) val error = alice2bob.expectMsgType[Error] - assert(error === Error(accept.temporaryChannelId, DustLimitTooLarge(accept.temporaryChannelId, highDustLimitSatoshis, Alice.nodeParams.channelConf.maxRemoteDustLimit).getMessage)) + assert(error == Error(accept.temporaryChannelId, DustLimitTooLarge(accept.temporaryChannelId, highDustLimitSatoshis, Alice.nodeParams.channelConf.maxRemoteDustLimit).getMessage)) awaitCond(alice.stateName == CLOSED) aliceOrigin.expectMsgType[Status.Failure] } @@ -221,7 +221,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS val delayTooHigh = CltvExpiryDelta(10000) alice ! accept.copy(toSelfDelay = delayTooHigh) val error = alice2bob.expectMsgType[Error] - assert(error === Error(accept.temporaryChannelId, ToSelfDelayTooHigh(accept.temporaryChannelId, delayTooHigh, Alice.nodeParams.channelConf.maxToLocalDelay).getMessage)) + assert(error == Error(accept.temporaryChannelId, ToSelfDelayTooHigh(accept.temporaryChannelId, delayTooHigh, Alice.nodeParams.channelConf.maxToLocalDelay).getMessage)) awaitCond(alice.stateName == CLOSED) aliceOrigin.expectMsgType[Status.Failure] } @@ -233,7 +233,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS val reserveTooHigh = TestConstants.fundingSatoshis * 0.3 alice ! accept.copy(channelReserveSatoshis = reserveTooHigh) val error = alice2bob.expectMsgType[Error] - assert(error === Error(accept.temporaryChannelId, ChannelReserveTooHigh(accept.temporaryChannelId, reserveTooHigh, 0.3, 0.05).getMessage)) + assert(error == Error(accept.temporaryChannelId, ChannelReserveTooHigh(accept.temporaryChannelId, reserveTooHigh, 0.3, 0.05).getMessage)) awaitCond(alice.stateName == CLOSED) aliceOrigin.expectMsgType[Status.Failure] } @@ -244,7 +244,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS val reserveTooSmall = accept.dustLimitSatoshis - 1.sat alice ! accept.copy(channelReserveSatoshis = reserveTooSmall) val error = alice2bob.expectMsgType[Error] - assert(error === Error(accept.temporaryChannelId, DustLimitTooLarge(accept.temporaryChannelId, accept.dustLimitSatoshis, reserveTooSmall).getMessage)) + assert(error == Error(accept.temporaryChannelId, DustLimitTooLarge(accept.temporaryChannelId, accept.dustLimitSatoshis, reserveTooSmall).getMessage)) awaitCond(alice.stateName == CLOSED) aliceOrigin.expectMsgType[Status.Failure] } @@ -256,7 +256,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS val reserveTooSmall = open.dustLimitSatoshis - 1.sat alice ! accept.copy(channelReserveSatoshis = reserveTooSmall) val error = alice2bob.expectMsgType[Error] - assert(error === Error(accept.temporaryChannelId, ChannelReserveBelowOurDustLimit(accept.temporaryChannelId, reserveTooSmall, open.dustLimitSatoshis).getMessage)) + assert(error == Error(accept.temporaryChannelId, ChannelReserveBelowOurDustLimit(accept.temporaryChannelId, reserveTooSmall, open.dustLimitSatoshis).getMessage)) awaitCond(alice.stateName == CLOSED) aliceOrigin.expectMsgType[Status.Failure] } @@ -268,7 +268,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS val dustTooBig = open.channelReserveSatoshis + 1.sat alice ! accept.copy(dustLimitSatoshis = dustTooBig) val error = alice2bob.expectMsgType[Error] - assert(error === Error(accept.temporaryChannelId, DustLimitAboveOurChannelReserve(accept.temporaryChannelId, dustTooBig, open.channelReserveSatoshis).getMessage)) + assert(error == Error(accept.temporaryChannelId, DustLimitAboveOurChannelReserve(accept.temporaryChannelId, dustTooBig, open.channelReserveSatoshis).getMessage)) awaitCond(alice.stateName == CLOSED) aliceOrigin.expectMsgType[Status.Failure] } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala index 84ea97e2ce..f4220136fd 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala @@ -67,39 +67,39 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui import f._ val open = alice2bob.expectMsgType[OpenChannel] // Since https://github.com/lightningnetwork/lightning-rfc/pull/714 we must include an empty upfront_shutdown_script. - assert(open.upfrontShutdownScript_opt === Some(ByteVector.empty)) + assert(open.upfrontShutdownScript_opt == Some(ByteVector.empty)) // We always send a channel type, even for standard channels. - assert(open.channelType_opt === Some(ChannelTypes.Standard)) + assert(open.channelType_opt == Some(ChannelTypes.Standard)) alice2bob.forward(bob) awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) - assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.Standard) + assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType == ChannelTypes.Standard) } test("recv OpenChannel (anchor outputs)", Tag(ChannelStateTestsTags.AnchorOutputs)) { f => import f._ val open = alice2bob.expectMsgType[OpenChannel] - assert(open.channelType_opt === Some(ChannelTypes.AnchorOutputs)) + assert(open.channelType_opt == Some(ChannelTypes.AnchorOutputs)) alice2bob.forward(bob) awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) - assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.AnchorOutputs) + assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType == ChannelTypes.AnchorOutputs) } test("recv OpenChannel (anchor outputs zero fee htlc txs)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs)) { f => import f._ val open = alice2bob.expectMsgType[OpenChannel] - assert(open.channelType_opt === Some(ChannelTypes.AnchorOutputsZeroFeeHtlcTx)) + assert(open.channelType_opt == Some(ChannelTypes.AnchorOutputsZeroFeeHtlcTx)) alice2bob.forward(bob) awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) - assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.AnchorOutputsZeroFeeHtlcTx) + assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType == ChannelTypes.AnchorOutputsZeroFeeHtlcTx) } test("recv OpenChannel (non-default channel type)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs), Tag("standard-channel-type")) { f => import f._ val open = alice2bob.expectMsgType[OpenChannel] - assert(open.channelType_opt === Some(ChannelTypes.Standard)) + assert(open.channelType_opt == Some(ChannelTypes.Standard)) alice2bob.forward(bob) awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED) - assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.Standard) + assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType == ChannelTypes.Standard) } test("recv OpenChannel (invalid chain)") { f => @@ -109,7 +109,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val livenetChainHash = Block.LivenetGenesisBlock.hash bob ! open.copy(chainHash = livenetChainHash) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, InvalidChainHash(open.temporaryChannelId, Block.RegtestGenesisBlock.hash, livenetChainHash).getMessage)) + assert(error == Error(open.temporaryChannelId, InvalidChainHash(open.temporaryChannelId, Block.RegtestGenesisBlock.hash, livenetChainHash).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -120,7 +120,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val announceChannel = true bob ! open.copy(fundingSatoshis = lowFunding, channelFlags = ChannelFlags(announceChannel)) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, lowFunding, Bob.nodeParams.channelConf.minFundingSatoshis(announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) + assert(error == Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, lowFunding, Bob.nodeParams.channelConf.minFundingSatoshis(announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -131,7 +131,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val announceChannel = false bob ! open.copy(fundingSatoshis = lowFunding, channelFlags = ChannelFlags(announceChannel)) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, lowFunding, Bob.nodeParams.channelConf.minFundingSatoshis(announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) + assert(error == Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, lowFunding, Bob.nodeParams.channelConf.minFundingSatoshis(announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -141,7 +141,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val highFundingMsat = 100000000.sat bob ! open.copy(fundingSatoshis = highFundingMsat) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, highFundingMsat, Bob.nodeParams.channelConf.minFundingSatoshis(open.channelFlags.announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) + assert(error == Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, highFundingMsat, Bob.nodeParams.channelConf.minFundingSatoshis(open.channelFlags.announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -151,7 +151,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val highFundingSat = Bob.nodeParams.channelConf.maxFundingSatoshis + Btc(1) bob ! open.copy(fundingSatoshis = highFundingSat) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, highFundingSat, Bob.nodeParams.channelConf.minFundingSatoshis(open.channelFlags.announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) + assert(error == Error(open.temporaryChannelId, InvalidFundingAmount(open.temporaryChannelId, highFundingSat, Bob.nodeParams.channelConf.minFundingSatoshis(open.channelFlags.announceChannel), Bob.nodeParams.channelConf.maxFundingSatoshis).getMessage)) } test("recv OpenChannel (invalid max accepted htlcs)") { f => @@ -160,7 +160,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val invalidMaxAcceptedHtlcs = Channel.MAX_ACCEPTED_HTLCS + 1 bob ! open.copy(maxAcceptedHtlcs = invalidMaxAcceptedHtlcs) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, InvalidMaxAcceptedHtlcs(open.temporaryChannelId, invalidMaxAcceptedHtlcs, Channel.MAX_ACCEPTED_HTLCS).getMessage)) + assert(error == Error(open.temporaryChannelId, InvalidMaxAcceptedHtlcs(open.temporaryChannelId, invalidMaxAcceptedHtlcs, Channel.MAX_ACCEPTED_HTLCS).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -170,7 +170,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val invalidPushMsat = 100000000000L.msat bob ! open.copy(pushMsat = invalidPushMsat) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, InvalidPushAmount(open.temporaryChannelId, invalidPushMsat, open.fundingSatoshis.toMilliSatoshi).getMessage)) + assert(error == Error(open.temporaryChannelId, InvalidPushAmount(open.temporaryChannelId, invalidPushMsat, open.fundingSatoshis.toMilliSatoshi).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -180,7 +180,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val delayTooHigh = CltvExpiryDelta(10000) bob ! open.copy(toSelfDelay = delayTooHigh) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, ToSelfDelayTooHigh(open.temporaryChannelId, delayTooHigh, Alice.nodeParams.channelConf.maxToLocalDelay).getMessage)) + assert(error == Error(open.temporaryChannelId, ToSelfDelayTooHigh(open.temporaryChannelId, delayTooHigh, Alice.nodeParams.channelConf.maxToLocalDelay).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -191,7 +191,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val reserveTooHigh = TestConstants.fundingSatoshis * 0.3 bob ! open.copy(channelReserveSatoshis = reserveTooHigh) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, ChannelReserveTooHigh(open.temporaryChannelId, reserveTooHigh, 0.3, 0.05).getMessage)) + assert(error == Error(open.temporaryChannelId, ChannelReserveTooHigh(open.temporaryChannelId, reserveTooHigh, 0.3, 0.05).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -203,7 +203,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(feeratePerKw = tinyFee) val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id - assert(error === Error(open.temporaryChannelId, "local/remote feerates are too different: remoteFeeratePerKw=253 localFeeratePerKw=10000")) + assert(error == Error(open.temporaryChannelId, "local/remote feerates are too different: remoteFeeratePerKw=253 localFeeratePerKw=10000")) awaitCond(bob.stateName == CLOSED) } @@ -215,7 +215,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(feeratePerKw = tinyFee) val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id - assert(error === Error(open.temporaryChannelId, "remote fee rate is too small: remoteFeeratePerKw=252")) + assert(error == Error(open.temporaryChannelId, "remote fee rate is too small: remoteFeeratePerKw=252")) awaitCond(bob.stateName == CLOSED) } @@ -226,7 +226,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(channelReserveSatoshis = reserveTooSmall) val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id - assert(error === Error(open.temporaryChannelId, DustLimitTooLarge(open.temporaryChannelId, open.dustLimitSatoshis, reserveTooSmall).getMessage)) + assert(error == Error(open.temporaryChannelId, DustLimitTooLarge(open.temporaryChannelId, open.dustLimitSatoshis, reserveTooSmall).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -236,7 +236,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui val dustLimitTooHigh = 2000.sat bob ! open.copy(dustLimitSatoshis = dustLimitTooHigh) val error = bob2alice.expectMsgType[Error] - assert(error === Error(open.temporaryChannelId, DustLimitTooLarge(open.temporaryChannelId, dustLimitTooHigh, Bob.nodeParams.channelConf.maxRemoteDustLimit).getMessage)) + assert(error == Error(open.temporaryChannelId, DustLimitTooLarge(open.temporaryChannelId, dustLimitTooHigh, Bob.nodeParams.channelConf.maxRemoteDustLimit).getMessage)) awaitCond(bob.stateName == CLOSED) } @@ -248,7 +248,7 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui bob ! open.copy(fundingSatoshis = fundingSatoshis, pushMsat = pushMsat) val error = bob2alice.expectMsgType[Error] // we check that the error uses the temporary channel id - assert(error === Error(open.temporaryChannelId, ChannelReserveNotMet(open.temporaryChannelId, pushMsat, (open.channelReserveSatoshis - 1.sat).toMilliSatoshi, open.channelReserveSatoshis).getMessage)) + assert(error == Error(open.temporaryChannelId, ChannelReserveNotMet(open.temporaryChannelId, pushMsat, (open.channelReserveSatoshis - 1.sat).toMilliSatoshi, open.channelReserveSatoshis).getMessage)) awaitCond(bob.stateName == CLOSED) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingCreatedStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingCreatedStateSpec.scala index 3c8232860c..84bb3b43e1 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingCreatedStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingCreatedStateSpec.scala @@ -86,7 +86,7 @@ class WaitForFundingCreatedStateSpec extends TestKitBaseClass with FixtureAnyFun bob2blockchain.expectMsgType[TxPublisher.SetChannelId] bob2blockchain.expectMsgType[WatchFundingSpent] val watchConfirmed = bob2blockchain.expectMsgType[WatchFundingConfirmed] - assert(watchConfirmed.minDepth === Alice.nodeParams.channelConf.minDepthBlocks) + assert(watchConfirmed.minDepth == Alice.nodeParams.channelConf.minDepthBlocks) } test("recv FundingCreated (wumbo)", Tag(ChannelStateTestsTags.Wumbo)) { f => @@ -111,7 +111,7 @@ class WaitForFundingCreatedStateSpec extends TestKitBaseClass with FixtureAnyFun val fundingCreated = alice2bob.expectMsgType[FundingCreated] alice2bob.forward(bob) val error = bob2alice.expectMsgType[Error] - assert(error === Error(fundingCreated.temporaryChannelId, s"can't pay the fee: missing=${-missing} reserve=$reserve fees=$fees")) + assert(error == Error(fundingCreated.temporaryChannelId, s"can't pay the fee: missing=${-missing} reserve=$reserve fees=$fees")) awaitCond(bob.stateName == CLOSED) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingSignedStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingSignedStateSpec.scala index 2a8a475072..9596b3c33b 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingSignedStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingSignedStateSpec.scala @@ -88,10 +88,10 @@ class WaitForFundingSignedStateSpec extends TestKitBaseClass with FixtureAnyFunS awaitCond(alice.stateName == WAIT_FOR_FUNDING_CONFIRMED) val fundingTxId = alice2blockchain.expectMsgType[WatchFundingSpent].txId val txPublished = listener.expectMsgType[TransactionPublished] - assert(txPublished.tx.txid === fundingTxId) + assert(txPublished.tx.txid == fundingTxId) assert(txPublished.miningFee > 0.sat) val watchConfirmed = alice2blockchain.expectMsgType[WatchFundingConfirmed] - assert(watchConfirmed.minDepth === Alice.nodeParams.channelConf.minDepthBlocks) + assert(watchConfirmed.minDepth == Alice.nodeParams.channelConf.minDepthBlocks) aliceOrigin.expectMsgType[ChannelOpenResponse.ChannelOpened] } @@ -103,7 +103,7 @@ class WaitForFundingSignedStateSpec extends TestKitBaseClass with FixtureAnyFunS alice2blockchain.expectMsgType[WatchFundingSpent] val watchConfirmed = alice2blockchain.expectMsgType[WatchFundingConfirmed] // when we are funder, we keep our regular min depth even for wumbo channels - assert(watchConfirmed.minDepth === Alice.nodeParams.channelConf.minDepthBlocks) + assert(watchConfirmed.minDepth == Alice.nodeParams.channelConf.minDepthBlocks) aliceOrigin.expectMsgType[ChannelOpenResponse.ChannelOpened] } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingConfirmedStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingConfirmedStateSpec.scala index 3bb70833cb..149f4d9255 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingConfirmedStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingConfirmedStateSpec.scala @@ -89,9 +89,9 @@ class WaitForFundingConfirmedStateSpec extends TestKitBaseClass with FixtureAnyF val fundingTx = alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].fundingTx.get bob ! WatchFundingConfirmedTriggered(BlockHeight(42000), 42, fundingTx) val txPublished = listener.expectMsgType[TransactionPublished] - assert(txPublished.tx === fundingTx) - assert(txPublished.miningFee === 0.sat) // bob is fundee - assert(listener.expectMsgType[TransactionConfirmed].tx === fundingTx) + assert(txPublished.tx == fundingTx) + assert(txPublished.miningFee == 0.sat) // bob is fundee + assert(listener.expectMsgType[TransactionConfirmed].tx == fundingTx) val msg = bob2alice.expectMsgType[FundingLocked] bob2alice.forward(alice) awaitCond(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].deferred.contains(msg)) @@ -106,7 +106,7 @@ class WaitForFundingConfirmedStateSpec extends TestKitBaseClass with FixtureAnyF alice.underlying.system.eventStream.subscribe(listener.ref, classOf[TransactionConfirmed]) val fundingTx = alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].fundingTx.get alice ! WatchFundingConfirmedTriggered(BlockHeight(42000), 42, fundingTx) - assert(listener.expectMsgType[TransactionConfirmed].tx === fundingTx) + assert(listener.expectMsgType[TransactionConfirmed].tx == fundingTx) awaitCond(alice.stateName == WAIT_FOR_FUNDING_LOCKED) alice2blockchain.expectMsgType[WatchFundingLost] alice2bob.expectMsgType[FundingLocked] @@ -182,7 +182,7 @@ class WaitForFundingConfirmedStateSpec extends TestKitBaseClass with FixtureAnyF awaitCond(bob.stateName == OFFLINE) // We reset the waiting period to the current block height when starting up after updating eclair. val currentBlockHeight = bob.underlyingActor.nodeParams.currentBlockHeight - assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].waitingSince === currentBlockHeight) + assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].waitingSince == currentBlockHeight) } test("recv WatchFundingSpentTriggered (remote commit)") { f => @@ -191,7 +191,7 @@ class WaitForFundingConfirmedStateSpec extends TestKitBaseClass with FixtureAnyF val tx = bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! WatchFundingSpentTriggered(tx) alice2blockchain.expectMsgType[TxPublisher.PublishTx] - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == tx.txid) awaitCond(alice.stateName == CLOSING) } @@ -200,7 +200,7 @@ class WaitForFundingConfirmedStateSpec extends TestKitBaseClass with FixtureAnyF val tx = alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! WatchFundingSpentTriggered(Transaction(0, Nil, Nil, 0)) alice2bob.expectMsgType[Error] - assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid === tx.txid) + assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid == tx.txid) awaitCond(alice.stateName == ERR_INFORMATION_LEAK) } @@ -209,9 +209,9 @@ class WaitForFundingConfirmedStateSpec extends TestKitBaseClass with FixtureAnyF val tx = alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! Error(ByteVector32.Zeroes, "oops") awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid === tx.txid) + assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[TxPublisher.PublishTx] // claim-main-delayed - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == tx.txid) } test("recv Error (nothing at stake)", Tag(ChannelStateTestsTags.NoPushMsat)) { f => @@ -235,9 +235,9 @@ class WaitForFundingConfirmedStateSpec extends TestKitBaseClass with FixtureAnyF val tx = alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! CMD_FORCECLOSE(sender.ref) awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid === tx.txid) + assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[TxPublisher.PublishTx] // claim-main-delayed - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == tx.txid) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingLockedStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingLockedStateSpec.scala index a1bb4b4098..01345af1e2 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingLockedStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingLockedStateSpec.scala @@ -89,8 +89,8 @@ class WaitForFundingLockedStateSpec extends TestKitBaseClass with FixtureAnyFunS bob2alice.forward(alice) awaitCond(alice.stateName == NORMAL) val initialChannelUpdate = alice.stateData.asInstanceOf[DATA_NORMAL].channelUpdate - assert(initialChannelUpdate.feeBaseMsat === relayFees.feeBase) - assert(initialChannelUpdate.feeProportionalMillionths === relayFees.feeProportionalMillionths) + assert(initialChannelUpdate.feeBaseMsat == relayFees.feeBase) + assert(initialChannelUpdate.feeProportionalMillionths == relayFees.feeProportionalMillionths) bob2alice.expectNoMessage(200 millis) } @@ -100,7 +100,7 @@ class WaitForFundingLockedStateSpec extends TestKitBaseClass with FixtureAnyFunS val tx = bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_LOCKED].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! WatchFundingSpentTriggered(tx) alice2blockchain.expectMsgType[TxPublisher.PublishTx] - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == tx.txid) awaitCond(alice.stateName == CLOSING) } @@ -109,7 +109,7 @@ class WaitForFundingLockedStateSpec extends TestKitBaseClass with FixtureAnyFunS val tx = alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_LOCKED].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! WatchFundingSpentTriggered(Transaction(0, Nil, Nil, 0)) alice2bob.expectMsgType[Error] - assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid === tx.txid) + assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[TxPublisher.PublishTx] awaitCond(alice.stateName == ERR_INFORMATION_LEAK) } @@ -119,9 +119,9 @@ class WaitForFundingLockedStateSpec extends TestKitBaseClass with FixtureAnyFunS val tx = alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_LOCKED].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! Error(ByteVector32.Zeroes, "oops") awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid === tx.txid) + assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[TxPublisher.PublishTx] - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == tx.txid) } test("recv Error (nothing at stake)", Tag(ChannelStateTestsTags.NoPushMsat)) { f => @@ -129,8 +129,8 @@ class WaitForFundingLockedStateSpec extends TestKitBaseClass with FixtureAnyFunS val tx = bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_LOCKED].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx bob ! Error(ByteVector32.Zeroes, "funding double-spent") awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid === tx.txid) - assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId === tx.txid) + assert(bob2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid == tx.txid) + assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId == tx.txid) } test("recv CMD_CLOSE") { f => @@ -147,8 +147,8 @@ class WaitForFundingLockedStateSpec extends TestKitBaseClass with FixtureAnyFunS val tx = alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_LOCKED].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! CMD_FORCECLOSE(sender.ref) awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid === tx.txid) + assert(alice2blockchain.expectMsgType[TxPublisher.PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[TxPublisher.PublishTx] - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == tx.txid) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalStateSpec.scala index d0bc69f39c..bafc54d154 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalStateSpec.scala @@ -183,7 +183,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val sender = TestProbe() // Alice has a minimum set to 0 msat (which should be invalid, but may mislead Bob into relaying 0-value HTLCs which is forbidden by the spec). - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localParams.htlcMinimum === 0.msat) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localParams.htlcMinimum == 0.msat) val initialState = bob.stateData.asInstanceOf[DATA_NORMAL] val add = CMD_ADD_HTLC(sender.ref, 0 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket, localOrigin(sender.ref)) bob ! add @@ -244,7 +244,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val sender = TestProbe() addHtlc(758640000 msat, alice, bob, alice2bob, bob2alice) crossSign(alice, bob, alice2bob, bob2alice) - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.availableBalanceForSend === 0.msat) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.availableBalanceForSend == 0.msat) // actual test begins // at this point alice has the minimal amount to sustain a channel @@ -302,8 +302,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val sender = TestProbe() val initialState = bob.stateData.asInstanceOf[DATA_NORMAL] - assert(initialState.commitments.localParams.maxHtlcValueInFlightMsat === UInt64.MaxValue) - assert(initialState.commitments.remoteParams.maxHtlcValueInFlightMsat === UInt64(150000000)) + assert(initialState.commitments.localParams.maxHtlcValueInFlightMsat == UInt64.MaxValue) + assert(initialState.commitments.remoteParams.maxHtlcValueInFlightMsat == UInt64(150000000)) val add = CMD_ADD_HTLC(sender.ref, 151000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket, localOrigin(sender.ref)) bob ! add val error = HtlcValueTooHighInFlight(channelId(bob), maximum = 150000000, actual = 151000000 msat) @@ -315,8 +315,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val sender = TestProbe() val initialState = bob.stateData.asInstanceOf[DATA_NORMAL] - assert(initialState.commitments.localParams.maxHtlcValueInFlightMsat === UInt64.MaxValue) - assert(initialState.commitments.remoteParams.maxHtlcValueInFlightMsat === UInt64(150000000)) + assert(initialState.commitments.localParams.maxHtlcValueInFlightMsat == UInt64.MaxValue) + assert(initialState.commitments.remoteParams.maxHtlcValueInFlightMsat == UInt64(150000000)) val add = CMD_ADD_HTLC(sender.ref, 75500000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket, localOrigin(sender.ref)) bob ! add sender.expectMsgType[RES_SUCCESS[CMD_ADD_HTLC]] @@ -332,8 +332,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val sender = TestProbe() val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] - assert(initialState.commitments.localParams.maxHtlcValueInFlightMsat === UInt64(150000000)) - assert(initialState.commitments.remoteParams.maxHtlcValueInFlightMsat === UInt64.MaxValue) + assert(initialState.commitments.localParams.maxHtlcValueInFlightMsat == UInt64(150000000)) + assert(initialState.commitments.remoteParams.maxHtlcValueInFlightMsat == UInt64.MaxValue) val add = CMD_ADD_HTLC(sender.ref, 151000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket, localOrigin(sender.ref)) alice ! add val error = HtlcValueTooHighInFlight(channelId(alice), maximum = 150000000, actual = 151000000 msat) @@ -345,8 +345,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val sender = TestProbe() val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] - assert(initialState.commitments.localParams.maxAcceptedHtlcs === 100) - assert(initialState.commitments.remoteParams.maxAcceptedHtlcs === 30) // Bob accepts a maximum of 30 htlcs + assert(initialState.commitments.localParams.maxAcceptedHtlcs == 100) + assert(initialState.commitments.remoteParams.maxAcceptedHtlcs == 30) // Bob accepts a maximum of 30 htlcs for (_ <- 0 until 30) { alice ! CMD_ADD_HTLC(sender.ref, 10000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket, localOrigin(sender.ref)) sender.expectMsgType[RES_SUCCESS[CMD_ADD_HTLC]] @@ -363,8 +363,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val sender = TestProbe() val initialState = bob.stateData.asInstanceOf[DATA_NORMAL] - assert(initialState.commitments.localParams.maxAcceptedHtlcs === 30) // Bob accepts a maximum of 30 htlcs - assert(initialState.commitments.remoteParams.maxAcceptedHtlcs === 100) // Alice accepts more, but Bob will stop at 30 HTLCs + assert(initialState.commitments.localParams.maxAcceptedHtlcs == 30) // Bob accepts a maximum of 30 htlcs + assert(initialState.commitments.remoteParams.maxAcceptedHtlcs == 100) // Alice accepts more, but Bob will stop at 30 HTLCs for (_ <- 0 until 30) { bob ! CMD_ADD_HTLC(sender.ref, 500000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket, localOrigin(sender.ref)) sender.expectMsgType[RES_SUCCESS[CMD_ADD_HTLC]] @@ -382,11 +382,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val sender = TestProbe() val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] val aliceCommitments = initialState.commitments - assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 25_000.sat) - assert(Transactions.offeredHtlcTrimThreshold(aliceCommitments.localParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) === 7730.sat) - assert(Transactions.receivedHtlcTrimThreshold(aliceCommitments.localParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) === 8130.sat) - assert(Transactions.offeredHtlcTrimThreshold(aliceCommitments.remoteParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) === 7630.sat) - assert(Transactions.receivedHtlcTrimThreshold(aliceCommitments.remoteParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) === 8030.sat) + assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 25_000.sat) + assert(Transactions.offeredHtlcTrimThreshold(aliceCommitments.localParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) == 7730.sat) + assert(Transactions.receivedHtlcTrimThreshold(aliceCommitments.localParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) == 8130.sat) + assert(Transactions.offeredHtlcTrimThreshold(aliceCommitments.remoteParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) == 7630.sat) + assert(Transactions.receivedHtlcTrimThreshold(aliceCommitments.remoteParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) == 8030.sat) // Alice sends HTLCs to Bob that add 10 000 sat to the dust exposure: addHtlc(500.sat.toMilliSatoshi, alice, bob, alice2bob, bob2alice) // dust htlc @@ -423,7 +423,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val sender = TestProbe() val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] - assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 25_000.sat) + assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 25_000.sat) // Alice sends HTLCs to Bob that add 20 000 sat to the dust exposure. // She signs them but Bob doesn't answer yet. @@ -449,9 +449,9 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val sender = TestProbe() val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] - assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 25_000.sat) - assert(alice.underlyingActor.nodeParams.channelConf.dustLimit === 1100.sat) - assert(bob.underlyingActor.nodeParams.channelConf.dustLimit === 1000.sat) + assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 25_000.sat) + assert(alice.underlyingActor.nodeParams.channelConf.dustLimit == 1100.sat) + assert(bob.underlyingActor.nodeParams.channelConf.dustLimit == 1000.sat) // Alice sends HTLCs to Bob that add 21 000 sat to the dust exposure. // She signs them but Bob doesn't answer yet. @@ -473,9 +473,9 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val sender = TestProbe() val initialState = bob.stateData.asInstanceOf[DATA_NORMAL] - assert(bob.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(alice.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 30_000.sat) - assert(alice.underlyingActor.nodeParams.channelConf.dustLimit === 1100.sat) - assert(bob.underlyingActor.nodeParams.channelConf.dustLimit === 1000.sat) + assert(bob.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(alice.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 30_000.sat) + assert(alice.underlyingActor.nodeParams.channelConf.dustLimit == 1100.sat) + assert(bob.underlyingActor.nodeParams.channelConf.dustLimit == 1000.sat) // Bob sends HTLCs to Alice that add 21 000 sat to the dust exposure. // He signs them but Alice doesn't answer yet. @@ -596,9 +596,9 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob ! htlc.copy(id = 3) bob ! htlc.copy(id = 42) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === UnexpectedHtlcId(channelId(bob), expected = 4, actual = 42).getMessage) + assert(new String(error.data.toArray) == UnexpectedHtlcId(channelId(bob), expected = 4, actual = 42).getMessage) awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -609,11 +609,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val htlc = UpdateAddHtlc(ByteVector32.Zeroes, 0, 150 msat, randomBytes32(), cltvExpiry = CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket) alice2bob.forward(bob, htlc) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === HtlcValueTooSmall(channelId(bob), minimum = 1000 msat, actual = 150 msat).getMessage) + assert(new String(error.data.toArray) == HtlcValueTooSmall(channelId(bob), minimum = 1000 msat, actual = 150 msat).getMessage) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -624,11 +624,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val htlc = UpdateAddHtlc(ByteVector32.Zeroes, 0, MilliSatoshi(Long.MaxValue), randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket) alice2bob.forward(bob, htlc) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === InsufficientFunds(channelId(bob), amount = MilliSatoshi(Long.MaxValue), missing = 9223372036083735L sat, reserve = 20000 sat, fees = 8960 sat).getMessage) + assert(new String(error.data.toArray) == InsufficientFunds(channelId(bob), amount = MilliSatoshi(Long.MaxValue), missing = 9223372036083735L sat, reserve = 20000 sat, fees = 8960 sat).getMessage) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -640,11 +640,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.forward(bob, UpdateAddHtlc(ByteVector32.Zeroes, 1, 300000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket)) alice2bob.forward(bob, UpdateAddHtlc(ByteVector32.Zeroes, 2, 100000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === InsufficientFunds(channelId(bob), amount = 100000000 msat, missing = 24760 sat, reserve = 20000 sat, fees = 4760 sat).getMessage) + assert(new String(error.data.toArray) == InsufficientFunds(channelId(bob), amount = 100000000 msat, missing = 24760 sat, reserve = 20000 sat, fees = 4760 sat).getMessage) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) } test("recv UpdateAddHtlc (insufficient funds w/ pending htlcs 1/2)") { f => @@ -655,11 +655,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.forward(bob, UpdateAddHtlc(ByteVector32.Zeroes, 2, 167600000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket)) alice2bob.forward(bob, UpdateAddHtlc(ByteVector32.Zeroes, 3, 10000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === InsufficientFunds(channelId(bob), amount = 10000000 msat, missing = 11720 sat, reserve = 20000 sat, fees = 14120 sat).getMessage) + assert(new String(error.data.toArray) == InsufficientFunds(channelId(bob), amount = 10000000 msat, missing = 11720 sat, reserve = 20000 sat, fees = 14120 sat).getMessage) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -671,11 +671,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.forward(bob, UpdateAddHtlc(ByteVector32.Zeroes, 1, 300000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket)) alice2bob.forward(bob, UpdateAddHtlc(ByteVector32.Zeroes, 2, 500000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === InsufficientFunds(channelId(bob), amount = 500000000 msat, missing = 332400 sat, reserve = 20000 sat, fees = 12400 sat).getMessage) + assert(new String(error.data.toArray) == InsufficientFunds(channelId(bob), amount = 500000000 msat, missing = 332400 sat, reserve = 20000 sat, fees = 12400 sat).getMessage) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -685,11 +685,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val tx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice2bob.forward(alice, UpdateAddHtlc(ByteVector32.Zeroes, 0, 151000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket)) val error = alice2bob.expectMsgType[Error] - assert(new String(error.data.toArray) === HtlcValueTooHighInFlight(channelId(alice), maximum = 150000000, actual = 151000000 msat).getMessage) + assert(new String(error.data.toArray) == HtlcValueTooHighInFlight(channelId(alice), maximum = 150000000, actual = 151000000 msat).getMessage) awaitCond(alice.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] alice2blockchain.expectMsgType[WatchTxConfirmed] } @@ -703,11 +703,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with } alice2bob.forward(bob, UpdateAddHtlc(ByteVector32.Zeroes, 30, 1000000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === TooManyAcceptedHtlcs(channelId(bob), maximum = 30).getMessage) + assert(new String(error.data.toArray) == TooManyAcceptedHtlcs(channelId(bob), maximum = 30).getMessage) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -795,8 +795,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // actual test starts here crossSign(alice, bob, alice2bob, bob2alice) // depending on who starts signing first, there will be one or two commitments because both sides have changes - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index === 2) - assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index === 3) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index == 2) + assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index == 3) assert(alice.underlyingActor.nodeParams.db.channels.listHtlcInfos(alice.stateData.asInstanceOf[DATA_NORMAL].channelId, 1).size == 0) assert(alice.underlyingActor.nodeParams.db.channels.listHtlcInfos(alice.stateData.asInstanceOf[DATA_NORMAL].channelId, 2).size == 2) assert(alice.underlyingActor.nodeParams.db.channels.listHtlcInfos(alice.stateData.asInstanceOf[DATA_NORMAL].channelId, 3).size == 4) @@ -824,7 +824,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.htlcTxsAndRemoteSigs.size == htlcCount) val htlcTxs = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.htlcTxsAndRemoteSigs val amounts = htlcTxs.map(_.htlcTx.tx.txOut.head.amount.toLong) - assert(amounts === amounts.sorted) + assert(amounts == amounts.sorted) } test("recv CMD_SIGN (no changes)") { f => @@ -844,12 +844,12 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[CommitSig] awaitCond(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo.isLeft) val waitForRevocation = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo.left.toOption.get - assert(waitForRevocation.reSignAsap === false) + assert(waitForRevocation.reSignAsap == false) // actual test starts here alice ! CMD_SIGN() sender.expectNoMessage(300 millis) - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo === Left(waitForRevocation)) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo == Left(waitForRevocation)) } test("recv CMD_SIGN (while waiting for RevokeAndAck (with pending changes)") { f => @@ -861,13 +861,13 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[CommitSig] awaitCond(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo.isLeft) val waitForRevocation = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo.left.toOption.get - assert(waitForRevocation.reSignAsap === false) + assert(waitForRevocation.reSignAsap == false) // actual test starts here addHtlc(50000000 msat, alice, bob, alice2bob, bob2alice) alice ! CMD_SIGN() sender.expectNoMessage(300 millis) - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo === Left(waitForRevocation.copy(reSignAsap = true))) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo == Left(waitForRevocation.copy(reSignAsap = true))) } test("recv CMD_SIGN (going above reserve)", Tag(ChannelStateTestsTags.NoPushMsat)) { f => @@ -890,7 +890,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // it should update its channel_update awaitCond(bob.stateData.asInstanceOf[DATA_NORMAL].channelUpdate.channelFlags.isEnabled) // and broadcast it - assert(listener.expectMsgType[LocalChannelUpdate].channelUpdate === bob.stateData.asInstanceOf[DATA_NORMAL].channelUpdate) + assert(listener.expectMsgType[LocalChannelUpdate].channelUpdate == bob.stateData.asInstanceOf[DATA_NORMAL].channelUpdate) } test("recv CMD_SIGN (after CMD_UPDATE_FEE)") { f => @@ -960,14 +960,14 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice ! CMD_SIGN() val aliceCommitSig = alice2bob.expectMsgType[CommitSig] - assert(aliceCommitSig.htlcSignatures.length === 3) + assert(aliceCommitSig.htlcSignatures.length == 3) alice2bob.forward(bob, aliceCommitSig) bob2alice.expectMsgType[RevokeAndAck] bob2alice.forward(alice) // actual test begins val bobCommitSig = bob2alice.expectMsgType[CommitSig] - assert(bobCommitSig.htlcSignatures.length === 5) + assert(bobCommitSig.htlcSignatures.length == 5) bob2alice.forward(alice, bobCommitSig) awaitCond(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index == 1) @@ -987,14 +987,14 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice ! CMD_SIGN() val aliceCommitSig = alice2bob.expectMsgType[CommitSig] - assert(aliceCommitSig.htlcSignatures.length === 2) + assert(aliceCommitSig.htlcSignatures.length == 2) alice2bob.forward(bob, aliceCommitSig) bob2alice.expectMsgType[RevokeAndAck] bob2alice.forward(alice) // actual test begins val bobCommitSig = bob2alice.expectMsgType[CommitSig] - assert(bobCommitSig.htlcSignatures.length === 3) + assert(bobCommitSig.htlcSignatures.length == 3) bob2alice.forward(alice, bobCommitSig) awaitCond(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index == 1) @@ -1014,14 +1014,14 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice ! CMD_SIGN() val aliceCommitSig = alice2bob.expectMsgType[CommitSig] - assert(aliceCommitSig.htlcSignatures.length === 3) + assert(aliceCommitSig.htlcSignatures.length == 3) alice2bob.forward(bob, aliceCommitSig) bob2alice.expectMsgType[RevokeAndAck] bob2alice.forward(alice) // actual test begins val bobCommitSig = bob2alice.expectMsgType[CommitSig] - assert(bobCommitSig.htlcSignatures.length === 5) + assert(bobCommitSig.htlcSignatures.length == 5) bob2alice.forward(alice, bobCommitSig) awaitCond(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index == 1) @@ -1036,7 +1036,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // actual test begins (note that channel sends a CMD_SIGN to itself when it receives RevokeAndAck and there are changes) val updateFee = alice2bob.expectMsgType[UpdateFee] - assert(updateFee.feeratePerKw === TestConstants.feeratePerKw + FeeratePerKw(1000 sat)) + assert(updateFee.feeratePerKw == TestConstants.feeratePerKw + FeeratePerKw(1000 sat)) alice2bob.forward(bob) alice2bob.expectMsgType[CommitSig] alice2bob.forward(bob) @@ -1079,8 +1079,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(new String(error.data.toArray).startsWith("cannot sign when there are no changes")) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1095,7 +1095,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val error = bob2alice.expectMsgType[Error] assert(new String(error.data.toArray).startsWith("invalid commitment signature")) awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1113,8 +1113,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val badCommitSig = commitSig.copy(htlcSignatures = commitSig.htlcSignatures ::: commitSig.htlcSignatures) bob ! badCommitSig val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === HtlcSigCountMismatch(channelId(bob), expected = 1, actual = 2).getMessage) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(new String(error.data.toArray) == HtlcSigCountMismatch(channelId(bob), expected = 1, actual = 2).getMessage) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1133,7 +1133,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob ! badCommitSig val error = bob2alice.expectMsgType[Error] assert(new String(error.data.toArray).startsWith("invalid htlc signature")) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1177,7 +1177,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo.isRight) // now bob will forward the htlc downstream val forward = bob2relayer.expectMsgType[RelayForward] - assert(forward.add === htlc) + assert(forward.add == htlc) } test("recv RevokeAndAck (multiple htlcs in both directions)") { f => @@ -1221,7 +1221,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with addHtlc(50000000 msat, alice, bob, alice2bob, bob2alice) alice ! CMD_SIGN() sender.expectNoMessage(300 millis) - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo.left.toOption.get.reSignAsap === true) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.remoteNextCommitInfo.left.toOption.get.reSignAsap == true) // actual test starts here bob2alice.expectMsgType[RevokeAndAck] @@ -1244,8 +1244,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] alice2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1253,9 +1253,9 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with test("recv RevokeAndAck (over max dust htlc exposure)") { f => import f._ val aliceCommitments = alice.stateData.asInstanceOf[DATA_NORMAL].commitments - assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 25_000.sat) - assert(Transactions.offeredHtlcTrimThreshold(aliceCommitments.localParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) === 7730.sat) - assert(Transactions.receivedHtlcTrimThreshold(aliceCommitments.remoteParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) === 8030.sat) + assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 25_000.sat) + assert(Transactions.offeredHtlcTrimThreshold(aliceCommitments.localParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) == 7730.sat) + assert(Transactions.receivedHtlcTrimThreshold(aliceCommitments.remoteParams.dustLimit, aliceCommitments.localCommit.spec, aliceCommitments.commitmentFormat) == 8030.sat) // Alice sends HTLCs to Bob that add 10 000 sat to the dust exposure: addHtlc(500.sat.toMilliSatoshi, alice, bob, alice2bob, bob2alice) // dust htlc @@ -1285,7 +1285,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[UpdateFailHtlc], alice2bob.expectMsgType[UpdateFailHtlc] ) - assert(failedHtlcs.map(_.id).toSet === Set(dust1.id, dust2.id, trimmed1.id)) + assert(failedHtlcs.map(_.id).toSet == Set(dust1.id, dust2.id, trimmed1.id)) alice2bob.expectMsgType[CommitSig] alice2bob.expectNoMessage(100 millis) } @@ -1293,7 +1293,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with test("recv RevokeAndAck (over max dust htlc exposure with pending local changes)") { f => import f._ val sender = TestProbe() - assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 25_000.sat) + assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 25_000.sat) // Bob sends HTLCs to Alice that add 10 000 sat to the dust exposure. addHtlc(4000.sat.toMilliSatoshi, bob, alice, bob2alice, alice2bob) @@ -1323,7 +1323,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // Alice forwards HTLCs that fit in the dust exposure and instantly fails the others. alice2relayer.expectMsg(RelayForward(acceptedHtlc)) alice2relayer.expectNoMessage(100 millis) - assert(alice2bob.expectMsgType[UpdateFailHtlc].id === rejectedHtlc.id) + assert(alice2bob.expectMsgType[UpdateFailHtlc].id == rejectedHtlc.id) alice2bob.expectMsgType[CommitSig] alice2bob.expectNoMessage(100 millis) } @@ -1331,7 +1331,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with def testRevokeAndAckDustOverflowSingleCommit(f: FixtureParam): Unit = { import f._ val sender = TestProbe() - assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 25_000.sat) + assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 25_000.sat) // Bob sends HTLCs to Alice that add 10 500 sat to the dust exposure. (1 to 10).foreach(_ => addHtlc(1050.sat.toMilliSatoshi, bob, alice, bob2alice, alice2bob)) @@ -1365,16 +1365,16 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with test("recv RevokeAndAck (over max dust htlc exposure in local commit only with pending local changes)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs), Tag(ChannelStateTestsTags.HighDustLimitDifferenceAliceBob)) { f => import f._ val sender = TestProbe() - assert(alice.underlyingActor.nodeParams.channelConf.dustLimit === 5000.sat) - assert(bob.underlyingActor.nodeParams.channelConf.dustLimit === 1000.sat) + assert(alice.underlyingActor.nodeParams.channelConf.dustLimit == 5000.sat) + assert(bob.underlyingActor.nodeParams.channelConf.dustLimit == 1000.sat) testRevokeAndAckDustOverflowSingleCommit(f) } test("recv RevokeAndAck (over max dust htlc exposure in remote commit only with pending local changes)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs), Tag(ChannelStateTestsTags.HighDustLimitDifferenceBobAlice)) { f => import f._ val sender = TestProbe() - assert(alice.underlyingActor.nodeParams.channelConf.dustLimit === 1000.sat) - assert(bob.underlyingActor.nodeParams.channelConf.dustLimit === 5000.sat) + assert(alice.underlyingActor.nodeParams.channelConf.dustLimit == 1000.sat) + assert(bob.underlyingActor.nodeParams.channelConf.dustLimit == 5000.sat) testRevokeAndAckDustOverflowSingleCommit(f) } @@ -1386,8 +1386,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] alice2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1414,8 +1414,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob2alice.forward(alice) // alice will forward the fail upstream val forward = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.RemoteFail]] - assert(forward.result.fail === fail) - assert(forward.htlc === htlc) + assert(forward.result.fail == fail) + assert(forward.htlc == htlc) } test("recv RevokeAndAck (forward UpdateFailMalformedHtlc)") { f => @@ -1440,8 +1440,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob2alice.forward(alice) // alice will forward the fail upstream val forward = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.RemoteFailMalformed]] - assert(forward.result.fail === fail) - assert(forward.htlc === htlc) + assert(forward.result.fail == fail) + assert(forward.htlc == htlc) } def testRevokeAndAckHtlcStaticRemoteKey(f: FixtureParam): Unit = { @@ -1606,8 +1606,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with commitments = initialState.commitments.copy(remoteChanges = initialState.commitments.remoteChanges.copy(initialState.commitments.remoteChanges.proposed :+ fulfill)))) // alice immediately propagates the fulfill upstream val forward = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.RemoteFulfill]] - assert(forward.result.fulfill === fulfill) - assert(forward.htlc === htlc) + assert(forward.result.fulfill == fulfill) + assert(forward.htlc == htlc) } test("recv UpdateFulfillHtlc") { @@ -1638,8 +1638,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] alice2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1651,8 +1651,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] alice2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1669,8 +1669,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout alice2blockchain.expectMsgType[WatchTxConfirmed] @@ -1685,7 +1685,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val initialState = bob.stateData.asInstanceOf[DATA_NORMAL] val cmd = CMD_FAIL_HTLC(htlc.id, Right(PermanentChannelFailure)) val Right(fail) = OutgoingPaymentPacket.buildHtlcFailure(Bob.nodeParams.privateKey, cmd, htlc) - assert(fail.id === htlc.id) + assert(fail.id == htlc.id) bob ! cmd bob2alice.expectMsg(fail) awaitCond(bob.stateData == initialState.copy( @@ -1865,9 +1865,9 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val fail = UpdateFailMalformedHtlc(ByteVector32.Zeroes, htlc.id, Sphinx.hash(htlc.onionRoutingPacket), 42) alice ! fail val error = alice2bob.expectMsgType[Error] - assert(new String(error.data.toArray) === InvalidFailureCode(ByteVector32.Zeroes).getMessage) + assert(new String(error.data.toArray) == InvalidFailureCode(ByteVector32.Zeroes).getMessage) awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout alice2blockchain.expectMsgType[WatchTxConfirmed] @@ -1885,8 +1885,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] alice2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1898,8 +1898,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] alice2blockchain.expectMsgType[WatchTxConfirmed] } @@ -1911,9 +1911,9 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // Bob receives a failure with a completely invalid onion error (missing mac) bob ! CMD_FAIL_HTLC(htlc.id, Left(ByteVector.fill(260)(42))) val fail = bob2alice.expectMsgType[UpdateFailHtlc] - assert(fail.id === htlc.id) + assert(fail.id == htlc.id) // We should rectify the packet length before forwarding upstream. - assert(fail.reason.length === Sphinx.FailurePacket.PacketLength) + assert(fail.reason.length == Sphinx.FailurePacket.PacketLength) } private def testCmdUpdateFee(f: FixtureParam): Unit = { @@ -1942,8 +1942,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with addHtlc(14000.sat.toMilliSatoshi, alice, bob, alice2bob, bob2alice) crossSign(alice, bob, alice2bob, bob2alice) val aliceCommitments = alice.stateData.asInstanceOf[DATA_NORMAL].commitments - assert(DustExposure.computeExposure(aliceCommitments.localCommit.spec, aliceCommitments.localParams.dustLimit, aliceCommitments.commitmentFormat) === 0.msat) - assert(DustExposure.computeExposure(aliceCommitments.remoteCommit.spec, aliceCommitments.remoteParams.dustLimit, aliceCommitments.commitmentFormat) === 0.msat) + assert(DustExposure.computeExposure(aliceCommitments.localCommit.spec, aliceCommitments.localParams.dustLimit, aliceCommitments.commitmentFormat) == 0.msat) + assert(DustExposure.computeExposure(aliceCommitments.remoteCommit.spec, aliceCommitments.remoteParams.dustLimit, aliceCommitments.commitmentFormat) == 0.msat) // A large feerate increase would make these HTLCs overflow alice's dust exposure, so she rejects it: val sender = TestProbe() @@ -1955,7 +1955,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with test("recv CMD_UPDATE_FEE (over max dust htlc exposure with pending local changes)") { f => import f._ val sender = TestProbe() - assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 25_000.sat) + assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 25_000.sat) // Alice sends an HTLC to Bob that is not included in the dust exposure at the current feerate. // She signs them but Bob doesn't answer yet. @@ -1967,8 +1967,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // Alice sends another HTLC to Bob that is not included in the dust exposure at the current feerate. addHtlc(14000.sat.toMilliSatoshi, alice, bob, alice2bob, bob2alice) val aliceCommitments = alice.stateData.asInstanceOf[DATA_NORMAL].commitments - assert(DustExposure.computeExposure(aliceCommitments.localCommit.spec, aliceCommitments.localParams.dustLimit, aliceCommitments.commitmentFormat) === 0.msat) - assert(DustExposure.computeExposure(aliceCommitments.remoteCommit.spec, aliceCommitments.remoteParams.dustLimit, aliceCommitments.commitmentFormat) === 0.msat) + assert(DustExposure.computeExposure(aliceCommitments.localCommit.spec, aliceCommitments.localParams.dustLimit, aliceCommitments.commitmentFormat) == 0.msat) + assert(DustExposure.computeExposure(aliceCommitments.remoteCommit.spec, aliceCommitments.remoteParams.dustLimit, aliceCommitments.commitmentFormat) == 0.msat) // A large feerate increase would make these HTLCs overflow alice's dust exposure, so she rejects it: val cmd = CMD_UPDATE_FEE(FeeratePerKw(20000 sat), replyTo_opt = Some(sender.ref)) @@ -1986,21 +1986,21 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with updateFee(initialFeerate, alice, bob, alice2bob, bob2alice) val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] val aliceCommitments = initialState.commitments - assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 25_000.sat) + assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 25_000.sat) val higherDustLimit = Seq(aliceCommitments.localParams.dustLimit, aliceCommitments.remoteParams.dustLimit).max val lowerDustLimit = Seq(aliceCommitments.localParams.dustLimit, aliceCommitments.remoteParams.dustLimit).min // We have the following dust thresholds at the current feerate - assert(Transactions.offeredHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) === 6989.sat) - assert(Transactions.receivedHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) === 7109.sat) - assert(Transactions.offeredHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) === 2989.sat) - assert(Transactions.receivedHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) === 3109.sat) + assert(Transactions.offeredHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) == 6989.sat) + assert(Transactions.receivedHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) == 7109.sat) + assert(Transactions.offeredHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) == 2989.sat) + assert(Transactions.receivedHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) == 3109.sat) // And the following thresholds after the feerate update // NB: we apply the real feerate when sending update_fee, not the one adjusted for dust val updatedFeerate = FeeratePerKw(4000 sat) - assert(Transactions.offeredHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) === 7652.sat) - assert(Transactions.receivedHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) === 7812.sat) - assert(Transactions.offeredHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) === 3652.sat) - assert(Transactions.receivedHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) === 3812.sat) + assert(Transactions.offeredHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) == 7652.sat) + assert(Transactions.receivedHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) == 7812.sat) + assert(Transactions.offeredHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) == 3652.sat) + assert(Transactions.receivedHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) == 3812.sat) // Alice send HTLCs to Bob that are not included in the dust exposure at the current feerate. // She signs them but Bob doesn't answer yet. @@ -2065,7 +2065,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with test("recv UpdateFee (anchor outputs)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs)) { f => import f._ val initialData = bob.stateData.asInstanceOf[DATA_NORMAL] - assert(initialData.commitments.localCommit.spec.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw) + assert(initialData.commitments.localCommit.spec.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw) val fee = UpdateFee(ByteVector32.Zeroes, TestConstants.anchorOutputsFeeratePerKw * 0.8) bob ! fee awaitCond(bob.stateData == initialData.copy(commitments = initialData.commitments.copy(remoteChanges = initialData.commitments.remoteChanges.copy(proposed = initialData.commitments.remoteChanges.proposed :+ fee), remoteNextHtlcId = 0))) @@ -2088,8 +2088,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] alice2blockchain.expectMsgType[WatchTxConfirmed] } @@ -2102,11 +2102,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob.feeEstimator.setFeerate(FeeratesPerKw.single(fee.feeratePerKw)) bob ! fee val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === CannotAffordFees(channelId(bob), missing = 71620000L sat, reserve = 20000L sat, fees = 72400000L sat).getMessage) + assert(new String(error.data.toArray) == CannotAffordFees(channelId(bob), missing = 71620000L sat, reserve = 20000L sat, fees = 72400000L sat).getMessage) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx //bob2blockchain.expectMsgType[PublishTx] // main delayed (removed because of the high fees) bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -2117,11 +2117,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // This feerate is just above the threshold: (800000 (alice balance) - 20000 (reserve) - 660 (anchors)) / 1124 (commit tx weight) = 693363 bob ! UpdateFee(ByteVector32.Zeroes, FeeratePerKw(693364 sat)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === CannotAffordFees(channelId(bob), missing = 1 sat, reserve = 20000 sat, fees = 780001 sat).getMessage) + assert(new String(error.data.toArray) == CannotAffordFees(channelId(bob), missing = 1 sat, reserve = 20000 sat, fees = 780001 sat).getMessage) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx } test("recv UpdateFee (local/remote feerates are too different)") { f => @@ -2129,7 +2129,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val initialState = bob.stateData.asInstanceOf[DATA_NORMAL] val commitTx = initialState.commitments.localCommit.commitTxAndRemoteSig.commitTx.tx - assert(initialState.commitments.localCommit.spec.commitTxFeerate === TestConstants.feeratePerKw) + assert(initialState.commitments.localCommit.spec.commitTxFeerate == TestConstants.feeratePerKw) alice2bob.send(bob, UpdateFee(ByteVector32.Zeroes, TestConstants.feeratePerKw * 3)) bob2alice.expectNoMessage(250 millis) // we don't close because the commitment doesn't contain any HTLC @@ -2139,8 +2139,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(new String(error.data.toArray).contains("local/remote feerates are too different")) awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === commitTx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == commitTx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -2149,7 +2149,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val initialState = bob.stateData.asInstanceOf[DATA_NORMAL] - assert(initialState.commitments.localCommit.spec.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw) + assert(initialState.commitments.localCommit.spec.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw) val add = UpdateAddHtlc(ByteVector32.Zeroes, 0, 2500000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket) alice2bob.send(bob, add) val fee = UpdateFee(initialState.channelId, TestConstants.anchorOutputsFeeratePerKw * 3) @@ -2162,7 +2162,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val initialState = bob.stateData.asInstanceOf[DATA_NORMAL] - assert(initialState.commitments.localCommit.spec.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw) + assert(initialState.commitments.localCommit.spec.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw) val add = UpdateAddHtlc(ByteVector32.Zeroes, 0, 2500000 msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(currentBlockHeight), TestConstants.emptyOnionPacket) alice2bob.send(bob, add) val fee = UpdateFee(initialState.channelId, FeeratePerKw(FeeratePerByte(2 sat))) @@ -2179,11 +2179,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(bobCommitments.localCommit.spec.commitTxFeerate == expectedFeeratePerKw) bob ! UpdateFee(ByteVector32.Zeroes, FeeratePerKw(252 sat)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === "remote fee rate is too small: remoteFeeratePerKw=252") + assert(new String(error.data.toArray) == "remote fee rate is too small: remoteFeeratePerKw=252") awaitCond(bob.stateName == CLOSING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === bob.stateData.asInstanceOf[DATA_CLOSING].channelId) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == bob.stateData.asInstanceOf[DATA_CLOSING].channelId) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -2197,23 +2197,23 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with addHtlc(14000.sat.toMilliSatoshi, alice, bob, alice2bob, bob2alice) crossSign(alice, bob, alice2bob, bob2alice) val bobCommitments = bob.stateData.asInstanceOf[DATA_NORMAL].commitments - assert(DustExposure.computeExposure(bobCommitments.localCommit.spec, bobCommitments.localParams.dustLimit, bobCommitments.commitmentFormat) === 0.msat) - assert(DustExposure.computeExposure(bobCommitments.remoteCommit.spec, bobCommitments.remoteParams.dustLimit, bobCommitments.commitmentFormat) === 0.msat) + assert(DustExposure.computeExposure(bobCommitments.localCommit.spec, bobCommitments.localParams.dustLimit, bobCommitments.commitmentFormat) == 0.msat) + assert(DustExposure.computeExposure(bobCommitments.remoteCommit.spec, bobCommitments.remoteParams.dustLimit, bobCommitments.commitmentFormat) == 0.msat) val tx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx // A large feerate increase would make these HTLCs overflow Bob's dust exposure, so he force-closes: bob.feeEstimator.setFeerate(FeeratesPerKw.single(FeeratePerKw(20000 sat))) bob ! UpdateFee(channelId(bob), FeeratePerKw(20000 sat)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === LocalDustHtlcExposureTooHigh(channelId(bob), 30000 sat, 40500000 msat).getMessage) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(new String(error.data.toArray) == LocalDustHtlcExposureTooHigh(channelId(bob), 30000 sat, 40500000 msat).getMessage) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) awaitCond(bob.stateName == CLOSING) } test("recv UpdateFee (over max dust htlc exposure with pending local changes)") { f => import f._ val sender = TestProbe() - assert(bob.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(alice.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 30_000.sat) + assert(bob.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(alice.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 30_000.sat) // Bob sends HTLCs to Alice that are not included in the dust exposure at the current feerate. // He signs them but Alice doesn't answer yet. @@ -2226,16 +2226,16 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // Bob sends another HTLC to Alice that is not included in the dust exposure at the current feerate. addHtlc(14000.sat.toMilliSatoshi, bob, alice, bob2alice, alice2bob) val bobCommitments = bob.stateData.asInstanceOf[DATA_NORMAL].commitments - assert(DustExposure.computeExposure(bobCommitments.localCommit.spec, bobCommitments.localParams.dustLimit, bobCommitments.commitmentFormat) === 0.msat) - assert(DustExposure.computeExposure(bobCommitments.remoteCommit.spec, bobCommitments.remoteParams.dustLimit, bobCommitments.commitmentFormat) === 0.msat) + assert(DustExposure.computeExposure(bobCommitments.localCommit.spec, bobCommitments.localParams.dustLimit, bobCommitments.commitmentFormat) == 0.msat) + assert(DustExposure.computeExposure(bobCommitments.remoteCommit.spec, bobCommitments.remoteParams.dustLimit, bobCommitments.commitmentFormat) == 0.msat) // A large feerate increase would make these HTLCs overflow Bob's dust exposure, so he force-close: val tx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx bob.feeEstimator.setFeerate(FeeratesPerKw.single(FeeratePerKw(20000 sat))) bob ! UpdateFee(channelId(bob), FeeratePerKw(20000 sat)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === LocalDustHtlcExposureTooHigh(channelId(bob), 30000 sat, 40500000 msat).getMessage) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(new String(error.data.toArray) == LocalDustHtlcExposureTooHigh(channelId(bob), 30000 sat, 40500000 msat).getMessage) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) awaitCond(bob.stateName == CLOSING) } @@ -2249,21 +2249,21 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with updateFee(initialFeerate, alice, bob, alice2bob, bob2alice) val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] val aliceCommitments = initialState.commitments - assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure === 25_000.sat) + assert(alice.underlyingActor.nodeParams.onChainFeeConf.feerateToleranceFor(bob.underlyingActor.nodeParams.nodeId).dustTolerance.maxExposure == 25_000.sat) val higherDustLimit = Seq(aliceCommitments.localParams.dustLimit, aliceCommitments.remoteParams.dustLimit).max val lowerDustLimit = Seq(aliceCommitments.localParams.dustLimit, aliceCommitments.remoteParams.dustLimit).min // We have the following dust thresholds at the current feerate - assert(Transactions.offeredHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) === 6989.sat) - assert(Transactions.receivedHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) === 7109.sat) - assert(Transactions.offeredHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) === 2989.sat) - assert(Transactions.receivedHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) === 3109.sat) + assert(Transactions.offeredHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) == 6989.sat) + assert(Transactions.receivedHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) == 7109.sat) + assert(Transactions.offeredHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) == 2989.sat) + assert(Transactions.receivedHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = DustExposure.feerateForDustExposure(initialFeerate)), aliceCommitments.commitmentFormat) == 3109.sat) // And the following thresholds after the feerate update // NB: we apply the real feerate when sending update_fee, not the one adjusted for dust val updatedFeerate = FeeratePerKw(4000 sat) - assert(Transactions.offeredHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) === 7652.sat) - assert(Transactions.receivedHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) === 7812.sat) - assert(Transactions.offeredHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) === 3652.sat) - assert(Transactions.receivedHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) === 3812.sat) + assert(Transactions.offeredHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) == 7652.sat) + assert(Transactions.receivedHtlcTrimThreshold(higherDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) == 7812.sat) + assert(Transactions.offeredHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) == 3652.sat) + assert(Transactions.receivedHtlcTrimThreshold(lowerDustLimit, aliceCommitments.localCommit.spec.copy(commitTxFeerate = updatedFeerate), aliceCommitments.commitmentFormat) == 3812.sat) // Bob send HTLCs to Alice that are not included in the dust exposure at the current feerate. // He signs them but Alice doesn't answer yet. @@ -2281,8 +2281,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob ! UpdateFee(channelId(bob), updatedFeerate) val error = bob2alice.expectMsgType[Error] // NB: we don't need to distinguish local and remote, the error message is exactly the same. - assert(new String(error.data.toArray) === LocalDustHtlcExposureTooHigh(channelId(bob), 30000 sat, 37000000 msat).getMessage) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(new String(error.data.toArray) == LocalDustHtlcExposureTooHigh(channelId(bob), 30000 sat, 37000000 msat).getMessage) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) awaitCond(bob.stateName == CLOSING) } @@ -2317,7 +2317,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice ! CMD_CLOSE(sender.ref, script_opt, None) sender.expectMsgType[RES_SUCCESS[CMD_CLOSE]] val shutdown = alice2bob.expectMsgType[Shutdown] - script_opt.foreach(script => assert(script === shutdown.scriptPubKey)) + script_opt.foreach(script => assert(script == shutdown.scriptPubKey)) awaitCond(alice.stateName == NORMAL) awaitCond(alice.stateData.asInstanceOf[DATA_NORMAL].localShutdown.isDefined) } @@ -2492,7 +2492,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[ClosingSigned] awaitCond(alice.stateName == NEGOTIATING) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_NEGOTIATING].channelId) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_NEGOTIATING].channelId) } test("recv Shutdown (no pending htlcs)") { f => @@ -2525,7 +2525,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[Shutdown] awaitCond(alice.stateName == SHUTDOWN) // channel should be advertised as down - assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId === alice.stateData.asInstanceOf[DATA_SHUTDOWN].channelId) + assert(channelUpdateListener.expectMsgType[LocalChannelDown].channelId == alice.stateData.asInstanceOf[DATA_SHUTDOWN].channelId) } test("recv Shutdown (with unacked received htlcs)") { f => @@ -2721,11 +2721,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] val aliceCommitTx = initialState.commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! CurrentBlockHeight(BlockHeight(400145)) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == aliceCommitTx.txid) } test("recv CurrentBlockCount (fulfilled signed htlc ignored by upstream peer)") { f => @@ -2754,10 +2754,10 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(isFatal) assert(err.isInstanceOf[HtlcsWillTimeoutUpstream]) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == initialCommitTx.txid) bob2blockchain.expectMsgType[PublishTx] // main delayed - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txOut === htlcSuccessTx.txOut) - assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txOut == htlcSuccessTx.txOut) + assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId == initialCommitTx.txid) alice2blockchain.expectNoMessage(500 millis) } @@ -2787,10 +2787,10 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(isFatal) assert(err.isInstanceOf[HtlcsWillTimeoutUpstream]) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == initialCommitTx.txid) bob2blockchain.expectMsgType[PublishTx] // main delayed - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txOut === htlcSuccessTx.txOut) - assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txOut == htlcSuccessTx.txOut) + assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId == initialCommitTx.txid) alice2blockchain.expectNoMessage(500 millis) } @@ -2824,10 +2824,10 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(isFatal) assert(err.isInstanceOf[HtlcsWillTimeoutUpstream]) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == initialCommitTx.txid) bob2blockchain.expectMsgType[PublishTx] // main delayed - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txOut === htlcSuccessTx.txOut) - assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txOut == htlcSuccessTx.txOut) + assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId == initialCommitTx.txid) alice2blockchain.expectNoMessage(500 millis) } @@ -2842,7 +2842,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with test("recv CurrentFeerate (when funder, triggers an UpdateFee, anchor outputs)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs)) { f => import f._ val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] - assert(initialState.commitments.localCommit.spec.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw) + assert(initialState.commitments.localCommit.spec.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw) alice ! CurrentFeerates(FeeratesPerKw.single(TestConstants.anchorOutputsFeeratePerKw / 2).copy(mempoolMinFee = FeeratePerKw(250 sat))) alice2bob.expectMsg(UpdateFee(initialState.commitments.channelId, TestConstants.anchorOutputsFeeratePerKw / 2)) alice2bob.expectMsgType[CommitSig] @@ -2861,7 +2861,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with test("recv CurrentFeerate (when funder, doesn't trigger an UpdateFee, anchor outputs)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs)) { f => import f._ val initialState = alice.stateData.asInstanceOf[DATA_NORMAL] - assert(initialState.commitments.localCommit.spec.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw) + assert(initialState.commitments.localCommit.spec.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw) alice ! CurrentFeerates(FeeratesPerKw.single(TestConstants.anchorOutputsFeeratePerKw * 2).copy(mempoolMinFee = FeeratePerKw(250 sat))) alice2bob.expectNoMessage(500 millis) } @@ -2900,14 +2900,14 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.forward(bob) addHtlc(10000000 msat, alice, bob, alice2bob, bob2alice) crossSign(alice, bob, alice2bob, bob2alice) - assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.spec.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw / 2) + assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.spec.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw / 2) // The network fees spike, but Bob doesn't close the channel because we're using anchor outputs. bob.feeEstimator.setFeerate(FeeratesPerKw.single(TestConstants.anchorOutputsFeeratePerKw * 2)) val event = CurrentFeerates(FeeratesPerKw.single(TestConstants.anchorOutputsFeeratePerKw * 2)) bob ! event bob2alice.expectNoMessage(250 millis) - assert(bob.stateName === NORMAL) + assert(bob.stateName == NORMAL) } test("recv CurrentFeerate (when fundee, commit-fee/network-fee are very different, without HTLCs)") { f => @@ -2967,14 +2967,14 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with }).sum // at best we have a little less than 450 000 + 250 000 + 100 000 + 50 000 = 850 000 (because fees) val amountClaimed = claimMain.txOut.head.amount + htlcAmountClaimed - assert(amountClaimed === 814880.sat) + assert(amountClaimed == 814880.sat) // alice sets the confirmation targets to the HTLC expiry - assert(claimHtlcTxs.collect { case PublishReplaceableTx(tx: ClaimHtlcSuccessTx, _) => (tx.htlcId, tx.confirmBefore.toLong) }.toMap === Map(htlcb1.id -> htlcb1.cltvExpiry.toLong)) - assert(claimHtlcTxs.collect { case PublishReplaceableTx(tx: ClaimHtlcTimeoutTx, _) => (tx.htlcId, tx.confirmBefore.toLong) }.toMap === Map(htlca1.id -> htlca1.cltvExpiry.toLong, htlca2.id -> htlca2.cltvExpiry.toLong)) + assert(claimHtlcTxs.collect { case PublishReplaceableTx(tx: ClaimHtlcSuccessTx, _) => (tx.htlcId, tx.confirmBefore.toLong) }.toMap == Map(htlcb1.id -> htlcb1.cltvExpiry.toLong)) + assert(claimHtlcTxs.collect { case PublishReplaceableTx(tx: ClaimHtlcTimeoutTx, _) => (tx.htlcId, tx.confirmBefore.toLong) }.toMap == Map(htlca1.id -> htlca1.cltvExpiry.toLong, htlca2.id -> htlca2.cltvExpiry.toLong)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.txid) alice2blockchain.expectMsgType[WatchOutputSpent] // htlc 1 alice2blockchain.expectMsgType[WatchOutputSpent] // htlc 2 alice2blockchain.expectMsgType[WatchOutputSpent] // htlc 3 @@ -2984,7 +2984,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].remoteCommitPublished.isDefined) val rcp = alice.stateData.asInstanceOf[DATA_CLOSING].remoteCommitPublished.get - assert(rcp.claimHtlcTxs.size === 4) + assert(rcp.claimHtlcTxs.size == 4) assert(getClaimHtlcSuccessTxs(rcp).length == 1) assert(getClaimHtlcTimeoutTxs(rcp).length == 2) @@ -3058,13 +3058,13 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with }).sum // at best we have a little less than 500 000 + 250 000 + 100 000 = 850 000 (because fees) val amountClaimed = claimMain.txOut.head.amount + htlcAmountClaimed - assert(amountClaimed === 822310.sat) + assert(amountClaimed == 822310.sat) // alice sets the confirmation targets to the HTLC expiry - assert(claimHtlcTxs.collect { case PublishReplaceableTx(tx: ClaimHtlcTimeoutTx, _) => (tx.htlcId, tx.confirmBefore.toLong) }.toMap === Map(htlca1.id -> htlca1.cltvExpiry.toLong, htlca2.id -> htlca2.cltvExpiry.toLong)) + assert(claimHtlcTxs.collect { case PublishReplaceableTx(tx: ClaimHtlcTimeoutTx, _) => (tx.htlcId, tx.confirmBefore.toLong) }.toMap == Map(htlca1.id -> htlca1.cltvExpiry.toLong, htlca2.id -> htlca2.cltvExpiry.toLong)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.txid) // claim-main + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.txid) // claim-main alice2blockchain.expectMsgType[WatchOutputSpent] // htlc 1 alice2blockchain.expectMsgType[WatchOutputSpent] // htlc 2 alice2blockchain.expectMsgType[WatchOutputSpent] // htlc 3 @@ -3073,8 +3073,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].nextRemoteCommitPublished.isDefined) val rcp = alice.stateData.asInstanceOf[DATA_CLOSING].nextRemoteCommitPublished.get - assert(getClaimHtlcSuccessTxs(rcp).length === 0) - assert(getClaimHtlcTimeoutTxs(rcp).length === 2) + assert(getClaimHtlcSuccessTxs(rcp).length == 0) + assert(getClaimHtlcTimeoutTxs(rcp).length == 2) } test("recv WatchFundingSpentTriggered (their *next* commit w/ pending unsigned htlcs)") { f => @@ -3133,11 +3133,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val mainTx = alice2blockchain.expectMsgType[PublishFinalTx].tx val mainPenaltyTx = alice2blockchain.expectMsgType[PublishFinalTx].tx val htlcPenaltyTxs = for (_ <- 0 until 4) yield alice2blockchain.expectMsgType[PublishFinalTx].tx - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === revokedTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === mainTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == revokedTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == mainTx.txid) alice2blockchain.expectMsgType[WatchOutputSpent] // main-penalty // let's make sure that htlc-penalty txs each spend a different output - assert(htlcPenaltyTxs.map(_.txIn.head.outPoint.index).toSet.size === htlcPenaltyTxs.size) + assert(htlcPenaltyTxs.map(_.txIn.head.outPoint.index).toSet.size == htlcPenaltyTxs.size) htlcPenaltyTxs.foreach(_ => alice2blockchain.expectMsgType[WatchOutputSpent]) alice2blockchain.expectNoMessage(1 second) @@ -3146,12 +3146,12 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with htlcPenaltyTxs.foreach(htlcPenaltyTx => Transaction.correctlySpends(htlcPenaltyTx, Seq(revokedTx), ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS)) // two main outputs are 760 000 and 200 000 - assert(mainTx.txOut.head.amount === 741500.sat) - assert(mainPenaltyTx.txOut.head.amount === 195160.sat) - assert(htlcPenaltyTxs(0).txOut.head.amount === 4540.sat) - assert(htlcPenaltyTxs(1).txOut.head.amount === 4540.sat) - assert(htlcPenaltyTxs(2).txOut.head.amount === 4540.sat) - assert(htlcPenaltyTxs(3).txOut.head.amount === 4540.sat) + assert(mainTx.txOut.head.amount == 741500.sat) + assert(mainPenaltyTx.txOut.head.amount == 195160.sat) + assert(htlcPenaltyTxs(0).txOut.head.amount == 4540.sat) + assert(htlcPenaltyTxs(1).txOut.head.amount == 4540.sat) + assert(htlcPenaltyTxs(2).txOut.head.amount == 4540.sat) + assert(htlcPenaltyTxs(3).txOut.head.amount == 4540.sat) awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.size == 1) @@ -3198,9 +3198,9 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val mainPenaltyTx = alice2blockchain.expectMsgType[PublishFinalTx].tx val htlcPenaltyTxs = for (_ <- 0 until 2) yield alice2blockchain.expectMsgType[PublishFinalTx].tx // let's make sure that htlc-penalty txs each spend a different output - assert(htlcPenaltyTxs.map(_.txIn.head.outPoint.index).toSet.size === htlcPenaltyTxs.size) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === revokedTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === mainTx.txid) + assert(htlcPenaltyTxs.map(_.txIn.head.outPoint.index).toSet.size == htlcPenaltyTxs.size) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == revokedTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == mainTx.txid) alice2blockchain.expectMsgType[WatchOutputSpent] // main-penalty htlcPenaltyTxs.foreach(_ => alice2blockchain.expectMsgType[WatchOutputSpent]) alice2blockchain.expectNoMessage(1 second) @@ -3258,15 +3258,15 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // an error occurs and alice publishes her commit tx val aliceCommitTx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! Error(ByteVector32.Zeroes, "oops") - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) assert(aliceCommitTx.txOut.size == 6) // two main outputs and 4 pending htlcs awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.isDefined) val localCommitPublished = alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get assert(localCommitPublished.commitTx.txid == aliceCommitTx.txid) - assert(localCommitPublished.htlcTxs.size === 4) - assert(getHtlcSuccessTxs(localCommitPublished).length === 1) - assert(getHtlcTimeoutTxs(localCommitPublished).length === 2) + assert(localCommitPublished.htlcTxs.size == 4) + assert(getHtlcSuccessTxs(localCommitPublished).length == 1) + assert(getHtlcTimeoutTxs(localCommitPublished).length == 2) assert(localCommitPublished.claimHtlcDelayedTxs.isEmpty) // alice can only claim 3 out of 4 htlcs, she can't do anything regarding the htlc sent by bob for which she does not have the preimage @@ -3281,8 +3281,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // the main delayed output and htlc txs spend the commitment transaction Seq(claimMain, htlcTx1, htlcTx2, htlcTx3).foreach(tx => Transaction.correctlySpends(tx, aliceCommitTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === aliceCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.txid) // main-delayed + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.txid) // main-delayed alice2blockchain.expectMsgType[WatchOutputSpent] // htlc 1 alice2blockchain.expectMsgType[WatchOutputSpent] // htlc 2 alice2blockchain.expectMsgType[WatchOutputSpent] // htlc 3 @@ -3292,11 +3292,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // 3rd-stage txs are published when htlc txs confirm Seq(htlcTx1, htlcTx2, htlcTx3).foreach { htlcTimeoutTx => alice ! WatchOutputSpentTriggered(htlcTimeoutTx) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === htlcTimeoutTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == htlcTimeoutTx.txid) alice ! WatchTxConfirmedTriggered(BlockHeight(2701), 3, htlcTimeoutTx) val claimHtlcDelayedTx = alice2blockchain.expectMsgType[PublishFinalTx].tx Transaction.correctlySpends(claimHtlcDelayedTx, htlcTimeoutTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimHtlcDelayedTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimHtlcDelayedTx.txid) } awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.claimHtlcDelayedTxs.length == 3) alice2blockchain.expectNoMessage(1 second) @@ -3316,12 +3316,12 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // an error occurs and alice publishes her commit tx val aliceCommitTx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! Error(ByteVector32.Zeroes, "oops") - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) assert(aliceCommitTx.txOut.size == 8) // two main outputs, two anchors and 4 pending htlcs awaitCond(alice.stateName == CLOSING) val localAnchor = alice2blockchain.expectMsgType[PublishReplaceableTx] - assert(localAnchor.txInfo.confirmBefore.toLong === htlca1.cltvExpiry.toLong) // the target is set to match the first htlc that expires + assert(localAnchor.txInfo.confirmBefore.toLong == htlca1.cltvExpiry.toLong) // the target is set to match the first htlc that expires val claimMain = alice2blockchain.expectMsgType[PublishFinalTx] // alice can only claim 3 out of 4 htlcs, she can't do anything regarding the htlc sent by bob for which she does not have the preimage val htlcConfirmationTargets = Seq( @@ -3329,10 +3329,10 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2blockchain.expectMsgType[PublishReplaceableTx], // htlc 2 alice2blockchain.expectMsgType[PublishReplaceableTx], // htlc 3 ).map(p => p.txInfo.asInstanceOf[HtlcTx].htlcId -> p.txInfo.confirmBefore.toLong).toMap - assert(htlcConfirmationTargets === Map(htlcb1.id -> htlcb1.cltvExpiry.toLong, htlca1.id -> htlca1.cltvExpiry.toLong, htlca2.id -> htlca2.cltvExpiry.toLong)) + assert(htlcConfirmationTargets == Map(htlcb1.id -> htlcb1.cltvExpiry.toLong, htlca1.id -> htlca1.cltvExpiry.toLong, htlca2.id -> htlca2.cltvExpiry.toLong)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === aliceCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.tx.txid) val watchedOutputs = Seq( alice2blockchain.expectMsgType[WatchOutputSpent], // htlc 1 alice2blockchain.expectMsgType[WatchOutputSpent], // htlc 2 @@ -3341,7 +3341,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2blockchain.expectMsgType[WatchOutputSpent], // local anchor ).map(w => OutPoint(w.txId.reverse, w.outputIndex)).toSet val localCommitPublished = alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get - assert(watchedOutputs === localCommitPublished.htlcTxs.keySet + localAnchor.txInfo.input.outPoint) + assert(watchedOutputs == localCommitPublished.htlcTxs.keySet + localAnchor.txInfo.input.outPoint) alice2blockchain.expectNoMessage(1 second) } @@ -3351,7 +3351,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // an error occurs and alice publishes her commit tx val aliceCommitTx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! Error(ByteVector32.Zeroes, "oops") - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) assert(aliceCommitTx.txOut.size == 4) // two main outputs and two anchors awaitCond(alice.stateName == CLOSING) @@ -3359,11 +3359,11 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val blockTargets = alice.underlyingActor.nodeParams.onChainFeeConf.feeTargets val localAnchor = alice2blockchain.expectMsgType[PublishReplaceableTx] // When there are no pending HTLCs, there is no rush to get the commit tx confirmed - assert(localAnchor.txInfo.confirmBefore === currentBlockHeight + blockTargets.commitmentWithoutHtlcsBlockTarget) + assert(localAnchor.txInfo.confirmBefore == currentBlockHeight + blockTargets.commitmentWithoutHtlcsBlockTarget) val claimMain = alice2blockchain.expectMsgType[PublishFinalTx] - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === aliceCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.tx.txid) - assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex === localAnchor.input.index) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.tx.txid) + assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex == localAnchor.input.index) alice2blockchain.expectNoMessage(1 second) } @@ -3376,7 +3376,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // an error occurs and alice publishes her commit tx val bobCommitTx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx bob ! Error(ByteVector32.Zeroes, "oops") - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === bobCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == bobCommitTx.txid) assert(bobCommitTx.txOut.size == 1) // only one main output alice2blockchain.expectNoMessage(1 second) @@ -3458,7 +3458,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val normal = alice.stateData.asInstanceOf[DATA_NORMAL] normal.shortChannelId == annSigsA.shortChannelId && normal.buried && normal.channelAnnouncement.contains(channelAnn) && normal.channelUpdate.shortChannelId == annSigsA.shortChannelId }) - assert(channelUpdateListener.expectMsgType[LocalChannelUpdate].channelAnnouncement_opt === Some(channelAnn)) + assert(channelUpdateListener.expectMsgType[LocalChannelUpdate].channelAnnouncement_opt == Some(channelAnn)) } test("recv AnnouncementSignatures (re-send)", Tag(ChannelStateTestsTags.ChannelsPublic)) { f => @@ -3471,7 +3471,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import initialState.commitments.{localParams, remoteParams} val channelAnn = Announcements.makeChannelAnnouncement(Alice.nodeParams.chainHash, annSigsA.shortChannelId, Alice.nodeParams.nodeId, remoteParams.nodeId, Alice.channelKeyManager.fundingPublicKey(localParams.fundingKeyPath).publicKey, remoteParams.fundingPubKey, annSigsA.nodeSignature, annSigsB.nodeSignature, annSigsA.bitcoinSignature, annSigsB.bitcoinSignature) bob2alice.forward(alice) - awaitCond(alice.stateData.asInstanceOf[DATA_NORMAL].channelAnnouncement === Some(channelAnn)) + awaitCond(alice.stateData.asInstanceOf[DATA_NORMAL].channelAnnouncement == Some(channelAnn)) // actual test starts here // simulate bob re-sending its sigs @@ -3601,8 +3601,8 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // actual test starts here Thread.sleep(1100) alice ! INPUT_DISCONNECTED - assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.DisconnectedBeforeSigned]].htlc.paymentHash === htlc1.paymentHash) - assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.DisconnectedBeforeSigned]].htlc.paymentHash === htlc2.paymentHash) + assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.DisconnectedBeforeSigned]].htlc.paymentHash == htlc1.paymentHash) + assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.DisconnectedBeforeSigned]].htlc.paymentHash == htlc2.paymentHash) val update2a = channelUpdateListener.expectMsgType[LocalChannelUpdate] assert(update1a.channelUpdate.timestamp < update2a.channelUpdate.timestamp) assert(!update2a.channelUpdate.channelFlags.isEnabled) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/OfflineStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/OfflineStateSpec.scala index de429c16fe..cca34ac7d0 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/OfflineStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/OfflineStateSpec.scala @@ -256,11 +256,11 @@ class OfflineStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with reconnect(alice, bob, alice2bob, bob2alice) val reestablishA = alice2bob.expectMsgType[ChannelReestablish] - assert(reestablishA.nextLocalCommitmentNumber === 4) - assert(reestablishA.nextRemoteRevocationNumber === 3) + assert(reestablishA.nextLocalCommitmentNumber == 4) + assert(reestablishA.nextRemoteRevocationNumber == 3) val reestablishB = bob2alice.expectMsgType[ChannelReestablish] - assert(reestablishB.nextLocalCommitmentNumber === 5) - assert(reestablishB.nextRemoteRevocationNumber === 3) + assert(reestablishB.nextLocalCommitmentNumber == 5) + assert(reestablishB.nextRemoteRevocationNumber == 3) bob2alice.forward(alice, reestablishB) // alice does not re-send messages bob already received @@ -275,8 +275,8 @@ class OfflineStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2bob.expectMsgType[RevokeAndAck] alice2bob.forward(bob) - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index === 4) - assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index === 4) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index == 4) + assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.index == 4) } test("reconnect with an outdated commitment") { f => @@ -313,7 +313,7 @@ class OfflineStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob2alice.forward(alice, reestablishB) // ... and ask bob to publish its current commitment val error = alice2bob.expectMsgType[Error] - assert(error === Error(channelId(alice), PleasePublishYourCommitment(channelId(alice)).getMessage)) + assert(error == Error(channelId(alice), PleasePublishYourCommitment(channelId(alice)).getMessage)) alice2bob.forward(bob) // alice now waits for bob to publish its commitment @@ -370,7 +370,7 @@ class OfflineStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob2alice.forward(alice, reestablishB) // alice asks bob to publish its current commitment val error = alice2bob.expectMsgType[Error] - assert(error === Error(channelId(alice), PleasePublishYourCommitment(channelId(alice)).getMessage)) + assert(error == Error(channelId(alice), PleasePublishYourCommitment(channelId(alice)).getMessage)) alice2bob.forward(bob) // alice now waits for bob to publish its commitment @@ -400,10 +400,10 @@ class OfflineStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // alice then finds out bob is lying bob2alice.send(alice, invalidReestablish) val error = alice2bob.expectMsgType[Error] - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) val claimMainOutput = alice2blockchain.expectMsgType[PublishFinalTx].tx Transaction.correctlySpends(claimMainOutput, aliceCommitTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - assert(error === Error(channelId(alice), InvalidRevokedCommitProof(channelId(alice), 0, 42, invalidReestablish.yourLastPerCommitmentSecret).getMessage)) + assert(error == Error(channelId(alice), InvalidRevokedCommitProof(channelId(alice), 0, 42, invalidReestablish.yourLastPerCommitmentSecret).getMessage)) } test("change relay fee while offline") { f => @@ -434,8 +434,8 @@ class OfflineStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // then alice reaches NORMAL state, and after a delay she broadcasts the channel_update val channelUpdate = channelUpdateListener.expectMsgType[LocalChannelUpdate](20 seconds).channelUpdate - assert(channelUpdate.feeBaseMsat === 4200.msat) - assert(channelUpdate.feeProportionalMillionths === 123456) + assert(channelUpdate.feeBaseMsat == 4200.msat) + assert(channelUpdate.feeProportionalMillionths == 123456) assert(channelUpdate.channelFlags.isEnabled) // no more messages @@ -544,16 +544,16 @@ class OfflineStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(isFatal) assert(err.isInstanceOf[HtlcsWillTimeoutUpstream]) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == initialCommitTx.txid) bob2blockchain.expectMsgType[PublishTx] // main delayed - assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId == initialCommitTx.txid) bob2blockchain.expectMsgType[WatchTxConfirmed] // main delayed bob2blockchain.expectMsgType[WatchOutputSpent] // htlc - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == initialCommitTx.txid) bob2blockchain.expectMsgType[PublishTx] // main delayed - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txOut === htlcSuccessTx.txOut) - assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId === initialCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txOut == htlcSuccessTx.txOut) + assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId == initialCommitTx.txid) bob2blockchain.expectMsgType[WatchTxConfirmed] // main delayed bob2blockchain.expectMsgType[WatchOutputSpent] // htlc bob2blockchain.expectNoMessage(500 millis) @@ -607,7 +607,7 @@ class OfflineStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // alice is funder alice ! CurrentFeerates(networkFeerate) if (shouldClose) { - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) } else { alice2blockchain.expectNoMessage() } @@ -716,7 +716,7 @@ class OfflineStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // bob is fundee bob ! CurrentFeerates(networkFeerate) if (shouldClose) { - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === bobCommitTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == bobCommitTx.txid) } else { bob2blockchain.expectNoMessage() } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/f/ShutdownStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/f/ShutdownStateSpec.scala index 4ba4bebb71..a7e5bb68a8 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/f/ShutdownStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/f/ShutdownStateSpec.scala @@ -185,7 +185,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit alice ! fulfill alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout 1 alice2blockchain.expectMsgType[PublishTx] // htlc timeout 2 @@ -198,7 +198,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit alice ! UpdateFulfillHtlc(ByteVector32.Zeroes, 42, ByteVector32.Zeroes) alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout 1 alice2blockchain.expectMsgType[PublishTx] // htlc timeout 2 @@ -289,7 +289,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit alice ! UpdateFailHtlc(ByteVector32.Zeroes, 42, ByteVector.fill(152)(0)) alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout 1 alice2blockchain.expectMsgType[PublishTx] // htlc timeout 2 @@ -310,9 +310,9 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit val fail = UpdateFailMalformedHtlc(ByteVector32.Zeroes, 1, Crypto.sha256(ByteVector.empty), 42) alice ! fail val error = alice2bob.expectMsgType[Error] - assert(new String(error.data.toArray) === InvalidFailureCode(ByteVector32.Zeroes).getMessage) + assert(new String(error.data.toArray) == InvalidFailureCode(ByteVector32.Zeroes).getMessage) awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout 1 alice2blockchain.expectMsgType[PublishTx] // htlc timeout 2 @@ -354,12 +354,12 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit bob2alice.expectMsgType[CommitSig] awaitCond(bob.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.remoteNextCommitInfo.isLeft) val waitForRevocation = bob.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.remoteNextCommitInfo.left.toOption.get - assert(waitForRevocation.reSignAsap === false) + assert(waitForRevocation.reSignAsap == false) // actual test starts here bob ! CMD_SIGN(replyTo_opt = Some(sender.ref)) sender.expectNoMessage(300 millis) - assert(bob.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.remoteNextCommitInfo === Left(waitForRevocation)) + assert(bob.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.remoteNextCommitInfo == Left(waitForRevocation)) } test("recv CommitSig") { f => @@ -380,7 +380,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit bob ! CommitSig(ByteVector32.Zeroes, ByteVector64.Zeroes, Nil) bob2alice.expectMsgType[Error] awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx bob2blockchain.expectMsgType[PublishTx] // main delayed bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -391,7 +391,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit bob ! CommitSig(ByteVector32.Zeroes, ByteVector64.Zeroes, Nil) bob2alice.expectMsgType[Error] awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx bob2blockchain.expectMsgType[PublishTx] // main delayed bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -447,7 +447,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit bob ! RevokeAndAck(ByteVector32.Zeroes, PrivateKey(randomBytes32()), PrivateKey(randomBytes32()).publicKey) bob2alice.expectMsgType[Error] awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx bob2blockchain.expectMsgType[PublishTx] // main delayed bob2blockchain.expectMsgType[PublishTx] // htlc success bob2blockchain.expectMsgType[WatchTxConfirmed] @@ -460,7 +460,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit alice ! RevokeAndAck(ByteVector32.Zeroes, PrivateKey(randomBytes32()), PrivateKey(randomBytes32()).publicKey) alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout 1 alice2blockchain.expectMsgType[PublishTx] // htlc timeout 2 @@ -487,7 +487,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit bob2alice.forward(alice) // alice will forward the fail upstream val forward = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.RemoteFail]] - assert(forward.result.fail === fail) + assert(forward.result.fail == fail) } test("recv RevokeAndAck (forward UpdateFailMalformedHtlc)") { f => @@ -510,7 +510,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit bob2alice.forward(alice) // alice will forward the fail upstream val forward = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.RemoteFailMalformed]] - assert(forward.result.fail === fail) + assert(forward.result.fail == fail) } test("recv CMD_UPDATE_FEE") { f => @@ -548,7 +548,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit alice ! UpdateFee(ByteVector32.Zeroes, FeeratePerKw(12000 sat)) alice2bob.expectMsgType[Error] awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout 1 alice2blockchain.expectMsgType[PublishTx] // htlc timeout 2 @@ -563,9 +563,9 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit bob.feeEstimator.setFeerate(FeeratesPerKw.single(fee.feeratePerKw)) bob ! fee val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === CannotAffordFees(channelId(bob), missing = 72120000L sat, reserve = 20000L sat, fees = 72400000L sat).getMessage) + assert(new String(error.data.toArray) == CannotAffordFees(channelId(bob), missing = 72120000L sat, reserve = 20000L sat, fees = 72400000L sat).getMessage) awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx //bob2blockchain.expectMsgType[PublishTx] // main delayed (removed because of the high fees) bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -575,9 +575,9 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit val tx = bob.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx bob ! UpdateFee(ByteVector32.Zeroes, FeeratePerKw(65000 sat)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === "local/remote feerates are too different: remoteFeeratePerKw=65000 localFeeratePerKw=10000") + assert(new String(error.data.toArray) == "local/remote feerates are too different: remoteFeeratePerKw=65000 localFeeratePerKw=10000") awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx bob2blockchain.expectMsgType[PublishTx] // main delayed bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -587,9 +587,9 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit val tx = bob.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx bob ! UpdateFee(ByteVector32.Zeroes, FeeratePerKw(252 sat)) val error = bob2alice.expectMsgType[Error] - assert(new String(error.data.toArray) === "remote fee rate is too small: remoteFeeratePerKw=252") + assert(new String(error.data.toArray) == "remote fee rate is too small: remoteFeeratePerKw=252") awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) // commit tx + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) // commit tx bob2blockchain.expectMsgType[PublishTx] // main delayed bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -616,11 +616,11 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit val initialState = alice.stateData.asInstanceOf[DATA_SHUTDOWN] val aliceCommitTx = initialState.commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! CurrentBlockHeight(BlockHeight(400145)) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) // commit tx + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) // commit tx alice2blockchain.expectMsgType[PublishTx] // main delayed alice2blockchain.expectMsgType[PublishTx] // htlc timeout 1 alice2blockchain.expectMsgType[PublishTx] // htlc timeout 2 - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == aliceCommitTx.txid) } test("recv CurrentFeerate (when funder, triggers an UpdateFee)") { f => @@ -634,7 +634,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit test("recv CurrentFeerate (when funder, triggers an UpdateFee, anchor outputs)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs)) { f => import f._ val initialState = alice.stateData.asInstanceOf[DATA_SHUTDOWN] - assert(initialState.commitments.localCommit.spec.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw) + assert(initialState.commitments.localCommit.spec.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw) alice ! CurrentFeerates(FeeratesPerKw.single(TestConstants.anchorOutputsFeeratePerKw / 2).copy(mempoolMinFee = FeeratePerKw(250 sat))) alice2bob.expectMsg(UpdateFee(initialState.commitments.channelId, TestConstants.anchorOutputsFeeratePerKw / 2)) } @@ -649,7 +649,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit test("recv CurrentFeerate (when funder, doesn't trigger an UpdateFee, anchor outputs)", Tag(ChannelStateTestsTags.AnchorOutputsZeroFeeHtlcTxs)) { f => import f._ val initialState = alice.stateData.asInstanceOf[DATA_SHUTDOWN] - assert(initialState.commitments.localCommit.spec.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw) + assert(initialState.commitments.localCommit.spec.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw) alice ! CurrentFeerates(FeeratesPerKw.single(TestConstants.anchorOutputsFeeratePerKw * 2).copy(mempoolMinFee = FeeratePerKw(250 sat))) alice2bob.expectNoMessage(500 millis) } @@ -691,10 +691,10 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit }).sum // htlc will timeout and be eventually refunded so we have a little less than fundingSatoshis - pushMsat = 1000000 - 200000 = 800000 (because fees) val amountClaimed = htlcAmountClaimed + claimMain.txOut.head.amount - assert(amountClaimed === 774040.sat) + assert(amountClaimed == 774040.sat) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.txid) alice2blockchain.expectMsgType[WatchOutputSpent] alice2blockchain.expectMsgType[WatchOutputSpent] alice2blockchain.expectNoMessage(1 second) @@ -702,9 +702,9 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].remoteCommitPublished.isDefined) val rcp = alice.stateData.asInstanceOf[DATA_CLOSING].remoteCommitPublished.get - assert(rcp.claimHtlcTxs.size === 2) - assert(getClaimHtlcSuccessTxs(rcp).length === 0) - assert(getClaimHtlcTimeoutTxs(rcp).length === 2) + assert(rcp.claimHtlcTxs.size == 2) + assert(getClaimHtlcSuccessTxs(rcp).length == 0) + assert(getClaimHtlcTimeoutTxs(rcp).length == 2) } test("recv WatchFundingSpentTriggered (their next commit)") { f => @@ -741,19 +741,19 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit claimTx.txOut.head.amount }).sum // htlc will timeout and be eventually refunded so we have a little less than fundingSatoshis - pushMsat - htlc1 = 1000000 - 200000 - 300 000 = 500000 (because fees) - assert(amountClaimed === 481210.sat) + assert(amountClaimed == 481210.sat) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimTxs(0).txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimTxs(0).txid) alice2blockchain.expectMsgType[WatchOutputSpent] alice2blockchain.expectNoMessage(1 second) awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].nextRemoteCommitPublished.isDefined) val rcp = alice.stateData.asInstanceOf[DATA_CLOSING].nextRemoteCommitPublished.get - assert(rcp.claimHtlcTxs.size === 1) - assert(getClaimHtlcSuccessTxs(rcp).length === 0) - assert(getClaimHtlcTimeoutTxs(rcp).length === 1) + assert(rcp.claimHtlcTxs.size == 1) + assert(getClaimHtlcSuccessTxs(rcp).length == 0) + assert(getClaimHtlcTimeoutTxs(rcp).length == 1) } test("recv WatchFundingSpentTriggered (revoked tx)") { f => @@ -776,8 +776,8 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit val mainPenaltyTx = alice2blockchain.expectMsgType[PublishFinalTx].tx val htlc1PenaltyTx = alice2blockchain.expectMsgType[PublishFinalTx].tx val htlc2PenaltyTx = alice2blockchain.expectMsgType[PublishFinalTx].tx - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === revokedTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === mainTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == revokedTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == mainTx.txid) alice2blockchain.expectMsgType[WatchOutputSpent] // main-penalty alice2blockchain.expectMsgType[WatchOutputSpent] // htlc1-penalty alice2blockchain.expectMsgType[WatchOutputSpent] // htlc2-penalty @@ -789,10 +789,10 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit Transaction.correctlySpends(htlc2PenaltyTx, Seq(revokedTx), ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) // two main outputs are 300 000 and 200 000, htlcs are 300 000 and 200 000 - assert(mainTx.txOut.head.amount === 284940.sat) - assert(mainPenaltyTx.txOut.head.amount === 195160.sat) - assert(htlc1PenaltyTx.txOut.head.amount === 194540.sat) - assert(htlc2PenaltyTx.txOut.head.amount === 294540.sat) + assert(mainTx.txOut.head.amount == 284940.sat) + assert(mainPenaltyTx.txOut.head.amount == 195160.sat) + assert(htlc1PenaltyTx.txOut.head.amount == 194540.sat) + assert(htlc2PenaltyTx.txOut.head.amount == 294540.sat) awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.size == 1) @@ -801,13 +801,13 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit test("recv WatchFundingSpentTriggered (revoked tx with updated commitment)") { f => import f._ val initialCommitTx = bob.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx - assert(initialCommitTx.txOut.size === 4) // two main outputs + 2 htlc + assert(initialCommitTx.txOut.size == 4) // two main outputs + 2 htlc // bob fulfills one of the pending htlc (commitment update while in shutdown state) fulfillHtlc(0, r1, bob, alice, bob2alice, alice2bob) crossSign(bob, alice, bob2alice, alice2bob) val revokedTx = bob.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx - assert(revokedTx.txOut.size === 3) // two main outputs + 1 htlc + assert(revokedTx.txOut.size == 3) // two main outputs + 1 htlc // bob fulfills the second pending htlc (and revokes the previous commitment) fulfillHtlc(1, r2, bob, alice, bob2alice, alice2bob) @@ -821,8 +821,8 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit val mainTx = alice2blockchain.expectMsgType[PublishFinalTx].tx val mainPenaltyTx = alice2blockchain.expectMsgType[PublishFinalTx].tx val htlcPenaltyTx = alice2blockchain.expectMsgType[PublishFinalTx].tx - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === revokedTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === mainTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == revokedTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == mainTx.txid) alice2blockchain.expectMsgType[WatchOutputSpent] // main-penalty alice2blockchain.expectMsgType[WatchOutputSpent] // htlc-penalty alice2blockchain.expectNoMessage(1 second) @@ -832,9 +832,9 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit Transaction.correctlySpends(htlcPenaltyTx, Seq(revokedTx), ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) // two main outputs are 300 000 and 200 000, htlcs are 300 000 and 200 000 - assert(mainTx.txOut(0).amount === 286660.sat) - assert(mainPenaltyTx.txOut(0).amount === 495160.sat) - assert(htlcPenaltyTx.txOut(0).amount === 194540.sat) + assert(mainTx.txOut(0).amount == 286660.sat) + assert(mainPenaltyTx.txOut(0).amount == 495160.sat) + assert(htlcPenaltyTx.txOut(0).amount == 194540.sat) awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.size == 1) @@ -853,7 +853,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit val closingFeerates1 = ClosingFeerates(FeeratePerKw(500 sat), FeeratePerKw(250 sat), FeeratePerKw(2500 sat)) alice ! CMD_CLOSE(sender.ref, None, Some(closingFeerates1)) sender.expectMsgType[RES_SUCCESS[CMD_CLOSE]] - assert(alice.stateData.asInstanceOf[DATA_SHUTDOWN].closingFeerates === Some(closingFeerates1)) + assert(alice.stateData.asInstanceOf[DATA_SHUTDOWN].closingFeerates == Some(closingFeerates1)) val closingScript = alice.stateData.asInstanceOf[DATA_SHUTDOWN].localShutdown.scriptPubKey val closingFeerates2 = ClosingFeerates(FeeratePerKw(600 sat), FeeratePerKw(300 sat), FeeratePerKw(2500 sat)) @@ -861,7 +861,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit sender.expectMsgType[RES_FAILURE[CMD_CLOSE, ClosingAlreadyInProgress]] alice ! CMD_CLOSE(sender.ref, Some(closingScript), Some(closingFeerates2)) sender.expectMsgType[RES_SUCCESS[CMD_CLOSE]] - assert(alice.stateData.asInstanceOf[DATA_SHUTDOWN].closingFeerates === Some(closingFeerates2)) + assert(alice.stateData.asInstanceOf[DATA_SHUTDOWN].closingFeerates == Some(closingFeerates2)) } test("recv CMD_FORCECLOSE") { f => @@ -873,19 +873,19 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit val sender = TestProbe() alice ! CMD_FORCECLOSE(sender.ref) sender.expectMsgType[RES_SUCCESS[CMD_FORCECLOSE]] - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.isDefined) val lcp = alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get - assert(lcp.htlcTxs.size === 2) + assert(lcp.htlcTxs.size == 2) assert(lcp.claimHtlcDelayedTxs.isEmpty) // 3rd-stage txs will be published once htlc txs confirm val claimMain = alice2blockchain.expectMsgType[PublishFinalTx].tx val htlc1 = alice2blockchain.expectMsgType[PublishFinalTx].tx val htlc2 = alice2blockchain.expectMsgType[PublishFinalTx].tx Seq(claimMain, htlc1, htlc2).foreach(tx => Transaction.correctlySpends(tx, aliceCommitTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === aliceCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.txid) alice2blockchain.expectMsgType[WatchOutputSpent] alice2blockchain.expectMsgType[WatchOutputSpent] alice2blockchain.expectNoMessage(1 second) @@ -893,11 +893,11 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit // 3rd-stage txs are published when htlc txs confirm Seq(htlc1, htlc2).foreach(htlcTimeoutTx => { alice ! WatchOutputSpentTriggered(htlcTimeoutTx) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === htlcTimeoutTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == htlcTimeoutTx.txid) alice ! WatchTxConfirmedTriggered(BlockHeight(2701), 3, htlcTimeoutTx) val claimHtlcDelayedTx = alice2blockchain.expectMsgType[PublishFinalTx].tx Transaction.correctlySpends(claimHtlcDelayedTx, htlcTimeoutTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimHtlcDelayedTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimHtlcDelayedTx.txid) }) awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.claimHtlcDelayedTxs.length == 2) alice2blockchain.expectNoMessage(1 second) @@ -907,7 +907,7 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit import f._ val aliceCommitTx = alice.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! Error(ByteVector32.Zeroes, "oops") - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == aliceCommitTx.txid) assert(aliceCommitTx.txOut.size == 4) // two main outputs and two htlcs awaitCond(alice.stateName == CLOSING) assert(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.isDefined) @@ -919,8 +919,8 @@ class ShutdownStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wit val claimTxs = for (_ <- 0 until 3) yield alice2blockchain.expectMsgType[PublishFinalTx].tx // the main delayed output and htlc txs spend the commitment transaction claimTxs.foreach(tx => Transaction.correctlySpends(tx, aliceCommitTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === aliceCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimTxs(0).txid) // main-delayed + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == aliceCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimTxs(0).txid) // main-delayed alice2blockchain.expectMsgType[WatchOutputSpent] alice2blockchain.expectMsgType[WatchOutputSpent] alice2blockchain.expectNoMessage(1 second) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/g/NegotiatingStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/g/NegotiatingStateSpec.scala index 075e3274c5..bf5acc288a 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/g/NegotiatingStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/g/NegotiatingStateSpec.scala @@ -123,19 +123,19 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike // alice is funder so she initiates the negotiation val aliceCloseSig1 = alice2bob.expectMsgType[ClosingSigned] - assert(aliceCloseSig1.feeSatoshis === 3370.sat) // matches a feerate of 5000 sat/kw + assert(aliceCloseSig1.feeSatoshis == 3370.sat) // matches a feerate of 5000 sat/kw assert(aliceCloseSig1.feeRange_opt.nonEmpty) assert(aliceCloseSig1.feeRange_opt.get.min < aliceCloseSig1.feeSatoshis) assert(aliceCloseSig1.feeSatoshis < aliceCloseSig1.feeRange_opt.get.max) - assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.length === 1) - assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length === 1) + assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.length == 1) + assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length == 1) assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.isEmpty) if (alice.stateData.asInstanceOf[DATA_NEGOTIATING].commitments.channelFeatures.hasFeature(Features.UpfrontShutdownScript)) { // check that the closing tx uses Alice and Bob's default closing scripts val closingTx = alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.head.unsignedTx.tx val expectedLocalScript = alice.stateData.asInstanceOf[DATA_NEGOTIATING].commitments.localParams.defaultFinalScriptPubKey val expectedRemoteScript = bob.stateData.asInstanceOf[DATA_NEGOTIATING].commitments.localParams.defaultFinalScriptPubKey - assert(closingTx.txOut.map(_.publicKeyScript).toSet === Set(expectedLocalScript, expectedRemoteScript)) + assert(closingTx.txOut.map(_.publicKeyScript).toSet == Set(expectedLocalScript, expectedRemoteScript)) } alice2bob.forward(bob) // bob answers with a counter proposition in alice's fee range @@ -148,19 +148,19 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike bob2alice.forward(alice) // alice accepts this proposition val aliceCloseSig2 = alice2bob.expectMsgType[ClosingSigned] - assert(aliceCloseSig2.feeSatoshis === bobCloseSig1.feeSatoshis) + assert(aliceCloseSig2.feeSatoshis == bobCloseSig1.feeSatoshis) alice2bob.forward(bob) assert(alice.stateName == CLOSING) assert(bob.stateName == CLOSING) val mutualCloseTx = alice2blockchain.expectMsgType[PublishFinalTx].tx - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx === mutualCloseTx) - assert(mutualCloseTx.txOut.length === 2) // NB: in the anchor outputs case, anchors are removed from the closing tx + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx == mutualCloseTx) + assert(mutualCloseTx.txOut.length == 2) // NB: in the anchor outputs case, anchors are removed from the closing tx assert(aliceCloseSig2.feeSatoshis > Transactions.weight2fee(TestConstants.anchorOutputsFeeratePerKw, mutualCloseTx.weight())) // NB: closing fee is allowed to be higher than commit tx fee when using anchor outputs - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === mutualCloseTx.txid) - assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId === mutualCloseTx.txid) - assert(alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.map(_.tx) === List(mutualCloseTx)) - assert(bob.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.map(_.tx) === List(mutualCloseTx)) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == mutualCloseTx.txid) + assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId == mutualCloseTx.txid) + assert(alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.map(_.tx) == List(mutualCloseTx)) + assert(bob.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.map(_.tx) == List(mutualCloseTx)) } test("recv ClosingSigned (theirCloseFee != ourCloseFee)") { f => @@ -187,7 +187,7 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val aliceCloseSig = alice2bob.expectMsgType[ClosingSigned] alice2bob.forward(bob) val bobCloseSig = bob2alice.expectMsgType[ClosingSigned] - assert(bobCloseSig.feeSatoshis === aliceCloseSig.feeSatoshis) + assert(bobCloseSig.feeSatoshis == aliceCloseSig.feeSatoshis) } test("recv ClosingSigned (theirMaxCloseFee < ourCloseFee)") { f => @@ -198,7 +198,7 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val aliceCloseSig = alice2bob.expectMsgType[ClosingSigned] alice2bob.forward(bob) val bobCloseSig = bob2alice.expectMsgType[ClosingSigned] - assert(bobCloseSig.feeSatoshis === aliceCloseSig.feeRange_opt.get.max) + assert(bobCloseSig.feeSatoshis == aliceCloseSig.feeRange_opt.get.max) } private def testClosingSignedSameFees(f: FixtureParam, bobInitiates: Boolean = false): Unit = { @@ -216,16 +216,16 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike // alice is funder so she initiates the negotiation val aliceCloseSig1 = alice2bob.expectMsgType[ClosingSigned] - assert(aliceCloseSig1.feeSatoshis === 3370.sat) // matches a feerate of 5 000 sat/kw + assert(aliceCloseSig1.feeSatoshis == 3370.sat) // matches a feerate of 5 000 sat/kw assert(aliceCloseSig1.feeRange_opt.nonEmpty) alice2bob.forward(bob) // bob agrees with that proposal val bobCloseSig1 = bob2alice.expectMsgType[ClosingSigned] - assert(bobCloseSig1.feeSatoshis === aliceCloseSig1.feeSatoshis) + assert(bobCloseSig1.feeSatoshis == aliceCloseSig1.feeSatoshis) val mutualCloseTx = bob2blockchain.expectMsgType[PublishFinalTx].tx - assert(mutualCloseTx.txOut.length === 2) // NB: in the anchor outputs case, anchors are removed from the closing tx + assert(mutualCloseTx.txOut.length == 2) // NB: in the anchor outputs case, anchors are removed from the closing tx bob2alice.forward(alice) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === mutualCloseTx) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == mutualCloseTx) assert(alice.stateName == CLOSING) assert(bob.stateName == CLOSING) } @@ -253,20 +253,20 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike aliceClose(f, Some(ClosingFeerates(FeeratePerKw(2500 sat), FeeratePerKw(2000 sat), FeeratePerKw(3000 sat)))) // alice initiates the negotiation with a very low feerate val aliceCloseSig = alice2bob.expectMsgType[ClosingSigned] - assert(aliceCloseSig.feeSatoshis === 1685.sat) - assert(aliceCloseSig.feeRange_opt === Some(FeeRange(1348 sat, 2022 sat))) + assert(aliceCloseSig.feeSatoshis == 1685.sat) + assert(aliceCloseSig.feeRange_opt == Some(FeeRange(1348 sat, 2022 sat))) alice2bob.forward(bob) // bob chooses alice's highest fee val bobCloseSig = bob2alice.expectMsgType[ClosingSigned] - assert(bobCloseSig.feeSatoshis === 2022.sat) + assert(bobCloseSig.feeSatoshis == 2022.sat) bob2alice.forward(alice) // alice accepts this proposition - assert(alice2bob.expectMsgType[ClosingSigned].feeSatoshis === 2022.sat) + assert(alice2bob.expectMsgType[ClosingSigned].feeSatoshis == 2022.sat) alice2bob.forward(bob) val mutualCloseTx = alice2blockchain.expectMsgType[PublishFinalTx].tx - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx === mutualCloseTx) - awaitCond(alice.stateName === CLOSING) - awaitCond(bob.stateName === CLOSING) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx == mutualCloseTx) + awaitCond(alice.stateName == CLOSING) + awaitCond(bob.stateName == CLOSING) } test("override on-chain fee estimator (fundee)") { f => @@ -276,16 +276,16 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike bobClose(f, Some(ClosingFeerates(FeeratePerKw(2500 sat), FeeratePerKw(2000 sat), FeeratePerKw(3000 sat)))) // alice is funder, so bob's override will simply be ignored val aliceCloseSig = alice2bob.expectMsgType[ClosingSigned] - assert(aliceCloseSig.feeSatoshis === 6740.sat) // matches a feerate of 10000 sat/kw + assert(aliceCloseSig.feeSatoshis == 6740.sat) // matches a feerate of 10000 sat/kw alice2bob.forward(bob) // bob directly agrees because their fee estimator matches val bobCloseSig = bob2alice.expectMsgType[ClosingSigned] - assert(aliceCloseSig.feeSatoshis === bobCloseSig.feeSatoshis) + assert(aliceCloseSig.feeSatoshis == bobCloseSig.feeSatoshis) bob2alice.forward(alice) val mutualCloseTx = alice2blockchain.expectMsgType[PublishFinalTx].tx - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx === mutualCloseTx) - awaitCond(alice.stateName === CLOSING) - awaitCond(bob.stateName === CLOSING) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx == mutualCloseTx) + awaitCond(alice.stateName == CLOSING) + awaitCond(bob.stateName == CLOSING) } test("recv ClosingSigned (nothing at stake)", Tag(ChannelStateTestsTags.NoPushMsat)) { f => @@ -296,9 +296,9 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val aliceCloseFee = alice2bob.expectMsgType[ClosingSigned].feeSatoshis alice2bob.forward(bob) val bobCloseFee = bob2alice.expectMsgType[ClosingSigned].feeSatoshis - assert(aliceCloseFee === bobCloseFee) + assert(aliceCloseFee == bobCloseFee) bob2blockchain.expectMsgType[PublishTx] - awaitCond(bob.stateName === CLOSING) + awaitCond(bob.stateName == CLOSING) } private def makeLegacyClosingSigned(f: FixtureParam, closingFee: Satoshi): (ClosingSigned, ClosingSigned) = { @@ -320,9 +320,9 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike aliceClose(f) val aliceClosing1 = alice2bob.expectMsgType[ClosingSigned] val Some(FeeRange(_, maxFee)) = aliceClosing1.feeRange_opt - assert(aliceClosing1.feeSatoshis === 674.sat) - assert(maxFee === 1348.sat) - assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length === 1) + assert(aliceClosing1.feeSatoshis == 674.sat) + assert(maxFee == 1348.sat) + assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length == 1) assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.isEmpty) // bob makes a proposal outside our fee range val (_, bobClosing1) = makeLegacyClosingSigned(f, 2500 sat) @@ -330,27 +330,27 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val aliceClosing2 = alice2bob.expectMsgType[ClosingSigned] assert(aliceClosing1.feeSatoshis < aliceClosing2.feeSatoshis) assert(aliceClosing2.feeSatoshis < 1600.sat) - assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length === 2) + assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length == 2) assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.nonEmpty) val (_, bobClosing2) = makeLegacyClosingSigned(f, 2000 sat) bob2alice.send(alice, bobClosing2) val aliceClosing3 = alice2bob.expectMsgType[ClosingSigned] assert(aliceClosing2.feeSatoshis < aliceClosing3.feeSatoshis) assert(aliceClosing3.feeSatoshis < 1800.sat) - assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length === 3) + assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length == 3) assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.nonEmpty) val (_, bobClosing3) = makeLegacyClosingSigned(f, 1800 sat) bob2alice.send(alice, bobClosing3) val aliceClosing4 = alice2bob.expectMsgType[ClosingSigned] assert(aliceClosing3.feeSatoshis < aliceClosing4.feeSatoshis) assert(aliceClosing4.feeSatoshis < 1800.sat) - assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length === 4) + assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length == 4) assert(alice.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.nonEmpty) val (_, bobClosing4) = makeLegacyClosingSigned(f, aliceClosing4.feeSatoshis) bob2alice.send(alice, bobClosing4) - awaitCond(alice.stateName === CLOSING) - assert(alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.length === 1) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.head.tx) + awaitCond(alice.stateName == CLOSING) + assert(alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.length == 1) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.head.tx) } test("recv ClosingSigned (other side ignores our fee range, fundee)") { f => @@ -362,34 +362,34 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike alice2bob.send(bob, aliceClosing1) val bobClosing1 = bob2alice.expectMsgType[ClosingSigned] assert(3000.sat < bobClosing1.feeSatoshis) - assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length === 1) + assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length == 1) assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.nonEmpty) val (aliceClosing2, _) = makeLegacyClosingSigned(f, 750 sat) alice2bob.send(bob, aliceClosing2) val bobClosing2 = bob2alice.expectMsgType[ClosingSigned] assert(bobClosing2.feeSatoshis < bobClosing1.feeSatoshis) assert(2000.sat < bobClosing2.feeSatoshis) - assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length === 2) + assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length == 2) assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.nonEmpty) val (aliceClosing3, _) = makeLegacyClosingSigned(f, 1000 sat) alice2bob.send(bob, aliceClosing3) val bobClosing3 = bob2alice.expectMsgType[ClosingSigned] assert(bobClosing3.feeSatoshis < bobClosing2.feeSatoshis) assert(1500.sat < bobClosing3.feeSatoshis) - assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length === 3) + assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length == 3) assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.nonEmpty) val (aliceClosing4, _) = makeLegacyClosingSigned(f, 1300 sat) alice2bob.send(bob, aliceClosing4) val bobClosing4 = bob2alice.expectMsgType[ClosingSigned] assert(bobClosing4.feeSatoshis < bobClosing3.feeSatoshis) assert(1300.sat < bobClosing4.feeSatoshis) - assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length === 4) + assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].closingTxProposed.last.length == 4) assert(bob.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.nonEmpty) val (aliceClosing5, _) = makeLegacyClosingSigned(f, bobClosing4.feeSatoshis) alice2bob.send(bob, aliceClosing5) - awaitCond(bob.stateName === CLOSING) - assert(bob.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.length === 1) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx === bob.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.head.tx) + awaitCond(bob.stateName == CLOSING) + assert(bob.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.length == 1) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx == bob.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.head.tx) } test("recv ClosingSigned (other side ignores our fee range, max iterations reached)") { f => @@ -403,9 +403,9 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val (_, bobClosing) = makeLegacyClosingSigned(f, bobNextFee) bob2alice.send(alice, bobClosing) } - awaitCond(alice.stateName === CLOSING) - assert(alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.length === 1) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.head.tx) + awaitCond(alice.stateName == CLOSING) + assert(alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.length == 1) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == alice.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.head.tx) } test("recv ClosingSigned (fee too low, fundee)") { f => @@ -429,7 +429,7 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike alice2bob.forward(bob, aliceCloseSig.copy(feeSatoshis = 99000 sat)) // sig doesn't matter, it is checked later val error = bob2alice.expectMsgType[Error] assert(new String(error.data.toArray).startsWith("invalid close fee: fee_satoshis=99000 sat")) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -442,7 +442,7 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike bob ! aliceCloseSig.copy(signature = ByteVector64.Zeroes) val error = bob2alice.expectMsgType[Error] assert(new String(error.data.toArray).startsWith("invalid close signature")) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) bob2blockchain.expectMsgType[PublishTx] bob2blockchain.expectMsgType[WatchTxConfirmed] } @@ -454,12 +454,12 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike alice2bob.forward(bob, aliceCloseSig) // at this point alice and bob agree on closing fees, but alice has not yet received the final signature whereas bob has // bob publishes the mutual close and alice is notified that the funding tx has been spent - assert(alice.stateName === NEGOTIATING) + assert(alice.stateName == NEGOTIATING) val mutualCloseTx = bob2blockchain.expectMsgType[PublishFinalTx].tx - assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId === mutualCloseTx.txid) + assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId == mutualCloseTx.txid) alice ! WatchFundingSpentTriggered(mutualCloseTx) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === mutualCloseTx) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === mutualCloseTx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == mutualCloseTx) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == mutualCloseTx.txid) alice2blockchain.expectNoMessage(100 millis) assert(alice.stateName == CLOSING) } @@ -482,10 +482,10 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike assert(firstMutualCloseTx.tx.txid !== latestMutualCloseTx.tx.txid) // at this point bob will receive a new signature, but he decides instead to publish the first mutual close alice ! WatchFundingSpentTriggered(firstMutualCloseTx.tx) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === firstMutualCloseTx.tx) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === firstMutualCloseTx.tx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == firstMutualCloseTx.tx) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == firstMutualCloseTx.tx.txid) alice2blockchain.expectNoMessage(100 millis) - assert(alice.stateName === CLOSING) + assert(alice.stateName == CLOSING) } test("recv WatchFundingSpentTriggered (self mutual close)") { f => @@ -498,11 +498,11 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike bob2alice.expectMsgType[ClosingSigned] // at this point bob has received a mutual close signature from alice, but doesn't yet agree on the fee // bob's mutual close is published from the outside of the actor - assert(bob.stateName === NEGOTIATING) + assert(bob.stateName == NEGOTIATING) val mutualCloseTx = bob.stateData.asInstanceOf[DATA_NEGOTIATING].bestUnpublishedClosingTx_opt.get.tx bob ! WatchFundingSpentTriggered(mutualCloseTx) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx === mutualCloseTx) - assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId === mutualCloseTx.txid) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx == mutualCloseTx) + assert(bob2blockchain.expectMsgType[WatchTxConfirmed].txId == mutualCloseTx.txid) bob2blockchain.expectNoMessage(100 millis) assert(bob.stateName == CLOSING) } @@ -542,9 +542,9 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val aliceClosing3 = alice2bob.expectMsgType[ClosingSigned] alice2bob.forward(bob, aliceClosing3) val mutualCloseTx = alice2blockchain.expectMsgType[PublishFinalTx].tx - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx === mutualCloseTx) - awaitCond(alice.stateName === CLOSING) - awaitCond(bob.stateName === CLOSING) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx == mutualCloseTx) + awaitCond(alice.stateName == CLOSING) + awaitCond(bob.stateName == CLOSING) } test("recv Error") { f => @@ -554,9 +554,9 @@ class NegotiatingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val tx = alice.stateData.asInstanceOf[DATA_NEGOTIATING].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx alice ! Error(ByteVector32.Zeroes, "oops") awaitCond(alice.stateName == CLOSING) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid === tx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx.txid == tx.txid) alice2blockchain.expectMsgType[PublishTx] - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == tx.txid) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/h/ClosingStateSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/h/ClosingStateSpec.scala index 1d1440ebac..52052b9e67 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/h/ClosingStateSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/channel/states/h/ClosingStateSpec.scala @@ -186,7 +186,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // test starts here alice ! GetTxWithMetaResponse(fundingTx.txid, None, TimestampSecond.now()) alice2bob.expectNoMessage(200 millis) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === fundingTx) // we republish the funding tx + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == fundingTx) // we republish the funding tx assert(alice.stateName == CLOSING) // the above expectNoMsg will make us wait, so this checks that we are still in CLOSING } @@ -277,7 +277,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with def testMutualCloseBeforeConverge(f: FixtureParam, channelFeatures: ChannelFeatures): Unit = { import f._ val sender = TestProbe() - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures === channelFeatures) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures == channelFeatures) bob.feeEstimator.setFeerate(FeeratesPerKw.single(FeeratePerKw(2500 sat)).copy(mempoolMinFee = FeeratePerKw(250 sat), blocks_1008 = FeeratePerKw(250 sat))) // alice initiates a closing with a low fee alice ! CMD_CLOSE(sender.ref, None, Some(ClosingFeerates(FeeratePerKw(500 sat), FeeratePerKw(250 sat), FeeratePerKw(1000 sat)))) @@ -294,13 +294,13 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // let's make bob publish this closing tx bob ! Error(ByteVector32.Zeroes, "") awaitCond(bob.stateName == CLOSING) - assert(bob2blockchain.expectMsgType[PublishFinalTx].tx === mutualCloseTx.tx) - assert(mutualCloseTx === bob.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.last) + assert(bob2blockchain.expectMsgType[PublishFinalTx].tx == mutualCloseTx.tx) + assert(mutualCloseTx == bob.stateData.asInstanceOf[DATA_CLOSING].mutualClosePublished.last) // actual test starts here bob ! WatchFundingSpentTriggered(mutualCloseTx.tx) bob ! WatchTxConfirmedTriggered(BlockHeight(0), 0, mutualCloseTx.tx) - assert(txListener.expectMsgType[TransactionConfirmed].tx === mutualCloseTx.tx) + assert(txListener.expectMsgType[TransactionConfirmed].tx == mutualCloseTx.tx) awaitCond(bob.stateName == CLOSED) } @@ -353,15 +353,15 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val claimHtlcSuccessFromCommitTx = Transaction(version = 0, txIn = TxIn(outPoint = OutPoint(randomBytes32(), 0), signatureScript = ByteVector.empty, sequence = 0, witness = Scripts.witnessClaimHtlcSuccessFromCommitTx(Transactions.PlaceHolderSig, ra1, ByteVector.fill(130)(33))) :: Nil, txOut = Nil, lockTime = 0) alice ! WatchOutputSpentTriggered(claimHtlcSuccessFromCommitTx) val fulfill1 = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFulfill]] - assert(fulfill1.htlc === htlca1) - assert(fulfill1.result.paymentPreimage === ra1) + assert(fulfill1.htlc == htlca1) + assert(fulfill1.result.paymentPreimage == ra1) // scenario 2: bob claims the htlc output from his own commit tx using its preimage (let's assume both parties had published their commitment tx) val claimHtlcSuccessTx = Transaction(version = 0, txIn = TxIn(outPoint = OutPoint(randomBytes32(), 0), signatureScript = ByteVector.empty, sequence = 0, witness = Scripts.witnessHtlcSuccess(Transactions.PlaceHolderSig, Transactions.PlaceHolderSig, ra1, ByteVector.fill(130)(33), Transactions.DefaultCommitmentFormat)) :: Nil, txOut = Nil, lockTime = 0) alice ! WatchOutputSpentTriggered(claimHtlcSuccessTx) val fulfill2 = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFulfill]] - assert(fulfill2.htlc === htlca1) - assert(fulfill2.result.paymentPreimage === ra1) + assert(fulfill2.htlc == htlca1) + assert(fulfill2.result.paymentPreimage == ra1) assert(alice.stateData == initialState) // this was a no-op } @@ -369,7 +369,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with def testLocalCommitTxConfirmed(f: FixtureParam, channelFeatures: ChannelFeatures): Unit = { import f._ - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures === channelFeatures) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures == channelFeatures) val listener = TestProbe() alice.underlying.system.eventStream.subscribe(listener.ref, classOf[LocalCommitConfirmed]) @@ -385,28 +385,28 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // actual test starts here assert(closingState.claimMainDelayedOutputTx.isDefined) - assert(closingState.htlcTxs.size === 1) + assert(closingState.htlcTxs.size == 1) assert(getHtlcSuccessTxs(closingState).isEmpty) - assert(getHtlcTimeoutTxs(closingState).length === 1) + assert(getHtlcTimeoutTxs(closingState).length == 1) val htlcTimeoutTx = getHtlcTimeoutTxs(closingState).head.tx - assert(closingState.claimHtlcDelayedTxs.length === 0) + assert(closingState.claimHtlcDelayedTxs.length == 0) alice ! WatchTxConfirmedTriggered(BlockHeight(42), 0, closingState.commitTx) - assert(txListener.expectMsgType[TransactionConfirmed].tx === closingState.commitTx) + assert(txListener.expectMsgType[TransactionConfirmed].tx == closingState.commitTx) assert(listener.expectMsgType[LocalCommitConfirmed].refundAtBlock == BlockHeight(42) + bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localParams.toSelfDelay.toInt) assert(listener.expectMsgType[PaymentSettlingOnChain].paymentHash == htlca1.paymentHash) // htlcs below dust will never reach the chain, once the commit tx is confirmed we can consider them failed - assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc === htlca2) + assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc == htlca2) alice2relayer.expectNoMessage(100 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(200), 0, closingState.claimMainDelayedOutputTx.get.tx) alice ! WatchTxConfirmedTriggered(BlockHeight(201), 0, htlcTimeoutTx) - assert(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.irrevocablySpent.values.toSet === Set(closingState.commitTx, closingState.claimMainDelayedOutputTx.get.tx, htlcTimeoutTx)) - assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc === htlca1) + assert(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.irrevocablySpent.values.toSet == Set(closingState.commitTx, closingState.claimMainDelayedOutputTx.get.tx, htlcTimeoutTx)) + assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc == htlca1) alice2relayer.expectNoMessage(100 millis) // We claim the htlc-delayed output now that the HTLC tx has been confirmed. val claimHtlcDelayedTx = alice2blockchain.expectMsgType[PublishFinalTx] Transaction.correctlySpends(claimHtlcDelayedTx.tx, Seq(htlcTimeoutTx), ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.claimHtlcDelayedTxs.length === 1) + awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.claimHtlcDelayedTxs.length == 1) alice ! WatchTxConfirmedTriggered(BlockHeight(202), 0, claimHtlcDelayedTx.tx) awaitCond(alice.stateName == CLOSED) @@ -440,18 +440,18 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // actual test starts here assert(closingState.claimMainDelayedOutputTx.isDefined) - assert(closingState.htlcTxs.size === 4) + assert(closingState.htlcTxs.size == 4) assert(getHtlcSuccessTxs(closingState).isEmpty) val htlcTimeoutTxs = getHtlcTimeoutTxs(closingState).map(_.tx) - assert(htlcTimeoutTxs.length === 4) - assert(closingState.claimHtlcDelayedTxs.length === 0) + assert(htlcTimeoutTxs.length == 4) + assert(closingState.claimHtlcDelayedTxs.length == 0) // if commit tx and htlc-timeout txs end up in the same block, we may receive the htlc-timeout confirmation before the commit tx confirmation alice ! WatchTxConfirmedTriggered(BlockHeight(42), 0, htlcTimeoutTxs(0)) val forwardedFail1 = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc alice2relayer.expectNoMessage(250 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(42), 1, closingState.commitTx) - assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc === dust) + assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc == dust) alice2relayer.expectNoMessage(250 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(200), 0, closingState.claimMainDelayedOutputTx.get.tx) alice ! WatchTxConfirmedTriggered(BlockHeight(202), 0, htlcTimeoutTxs(1)) @@ -462,10 +462,10 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2relayer.expectNoMessage(250 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(203), 0, htlcTimeoutTxs(3)) val forwardedFail4 = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc - assert(Set(forwardedFail1, forwardedFail2, forwardedFail3, forwardedFail4) === Set(htlca1, htlca2, htlca3, htlca4)) + assert(Set(forwardedFail1, forwardedFail2, forwardedFail3, forwardedFail4) == Set(htlca1, htlca2, htlca3, htlca4)) alice2relayer.expectNoMessage(250 millis) - awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.claimHtlcDelayedTxs.length === 4) + awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.claimHtlcDelayedTxs.length == 4) val claimHtlcDelayedTxs = alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.claimHtlcDelayedTxs alice ! WatchTxConfirmedTriggered(BlockHeight(203), 0, claimHtlcDelayedTxs(0).tx) alice ! WatchTxConfirmedTriggered(BlockHeight(203), 1, claimHtlcDelayedTxs(1).tx) @@ -508,7 +508,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with crossSign(bob, alice, bob2alice, alice2bob) alice2relayer.expectMsgType[RelayForward] val aliceCommitTx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx - assert(aliceCommitTx.txOut.size === 3) // 2 main outputs + 1 htlc + assert(aliceCommitTx.txOut.size == 3) // 2 main outputs + 1 htlc // alice fulfills the HTLC but bob doesn't receive the signature alice ! CMD_FULFILL_HTLC(htlc.id, r, commit = true) @@ -518,9 +518,9 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // note that bob doesn't receive the new sig! // then we make alice unilaterally close the channel val closingState = localClose(alice, alice2blockchain) - assert(closingState.commitTx.txid === aliceCommitTx.txid) + assert(closingState.commitTx.txid == aliceCommitTx.txid) assert(getHtlcTimeoutTxs(closingState).isEmpty) - assert(getHtlcSuccessTxs(closingState).length === 1) + assert(getHtlcSuccessTxs(closingState).length == 1) } test("recv WatchTxConfirmedTriggered (local commit with fail not acked by remote)") { f => @@ -541,7 +541,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // note that alice doesn't receive the last revocation // then we make alice unilaterally close the channel val closingState = localClose(alice, alice2blockchain) - assert(closingState.commitTx.txOut.length === 2) // htlc has been removed + assert(closingState.commitTx.txOut.length == 2) // htlc has been removed // actual test starts here channelUpdateListener.expectMsgType[LocalChannelDown] @@ -575,12 +575,12 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // the commit tx hasn't been confirmed yet, so we watch the funding output first alice2blockchain.expectMsgType[WatchFundingSpent] // then we should re-publish unconfirmed transactions - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === closingState.commitTx) - closingState.claimMainDelayedOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimMain.tx)) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === htlcTimeoutTx.tx) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === closingState.commitTx.txid) - closingState.claimMainDelayedOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.tx.txid)) - assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex === htlcTimeoutTx.input.outPoint.index) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == closingState.commitTx) + closingState.claimMainDelayedOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimMain.tx)) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == htlcTimeoutTx.tx) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == closingState.commitTx.txid) + closingState.claimMainDelayedOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.tx.txid)) + assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex == htlcTimeoutTx.input.outPoint.index) // the htlc transaction confirms, so we publish a 3rd-stage transaction alice ! WatchTxConfirmedTriggered(BlockHeight(2701), 1, closingState.commitTx) @@ -588,8 +588,8 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].localCommitPublished.get.claimHtlcDelayedTxs.nonEmpty) val beforeSecondRestart = alice.stateData.asInstanceOf[DATA_CLOSING] val claimHtlcTimeoutTx = beforeSecondRestart.localCommitPublished.get.claimHtlcDelayedTxs.head - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimHtlcTimeoutTx.tx) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimHtlcTimeoutTx.tx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimHtlcTimeoutTx.tx) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimHtlcTimeoutTx.tx.txid) // simulate another node restart alice.setState(WAIT_FOR_INIT_INTERNAL, Nothing) @@ -598,10 +598,10 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(alice.stateName == CLOSING) // we should re-publish unconfirmed transactions - closingState.claimMainDelayedOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimMain.tx)) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimHtlcTimeoutTx.tx) - closingState.claimMainDelayedOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.tx.txid)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimHtlcTimeoutTx.tx.txid) + closingState.claimMainDelayedOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimMain.tx)) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimHtlcTimeoutTx.tx) + closingState.claimMainDelayedOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.tx.txid)) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimHtlcTimeoutTx.tx.txid) } test("recv WatchTxConfirmedTriggered (remote commit with htlcs only signed by local in next remote commit)") { f => @@ -641,7 +641,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(closingState.claimHtlcTxs.isEmpty) assert(alice.stateData.asInstanceOf[DATA_CLOSING].copy(remoteCommitPublished = None) == initialState) val txPublished = txListener.expectMsgType[TransactionPublished] - assert(txPublished.tx === bobCommitTx) + assert(txPublished.tx == bobCommitTx) assert(txPublished.miningFee > 0.sat) // alice is funder, she pays the fee for the remote commit } @@ -649,7 +649,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ mutualClose(alice, bob, alice2bob, bob2alice, alice2blockchain, bob2blockchain) val initialState = alice.stateData.asInstanceOf[DATA_CLOSING] - assert(initialState.commitments.channelFeatures === ChannelFeatures()) + assert(initialState.commitments.channelFeatures == ChannelFeatures()) // bob publishes his last current commit tx, the one it had when entering NEGOTIATING state val bobCommitTx = bobCommitTxs.last.commitTx.tx assert(bobCommitTx.txOut.size == 2) // two main outputs @@ -662,14 +662,14 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with txListener.expectMsgType[TransactionPublished] alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, bobCommitTx) alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, closingState.claimMainOutputTx.get.tx) - assert(txListener.expectMsgType[TransactionConfirmed].tx === bobCommitTx) + assert(txListener.expectMsgType[TransactionConfirmed].tx == bobCommitTx) awaitCond(alice.stateName == CLOSED) } test("recv WatchTxConfirmedTriggered (remote commit, option_static_remotekey)", Tag(ChannelStateTestsTags.StaticRemoteKey)) { f => import f._ mutualClose(alice, bob, alice2bob, bob2alice, alice2blockchain, bob2blockchain) - assert(alice.stateData.asInstanceOf[DATA_CLOSING].commitments.channelFeatures === ChannelFeatures(Features.StaticRemoteKey)) + assert(alice.stateData.asInstanceOf[DATA_CLOSING].commitments.channelFeatures == ChannelFeatures(Features.StaticRemoteKey)) // bob publishes his last current commit tx, the one it had when entering NEGOTIATING state val bobCommitTx = bobCommitTxs.last.commitTx.tx assert(bobCommitTx.txOut.size == 2) // two main outputs @@ -687,7 +687,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ mutualClose(alice, bob, alice2bob, bob2alice, alice2blockchain, bob2blockchain) val initialState = alice.stateData.asInstanceOf[DATA_CLOSING] - assert(initialState.commitments.channelFeatures === ChannelFeatures(Features.StaticRemoteKey, Features.AnchorOutputsZeroFeeHtlcTx)) + assert(initialState.commitments.channelFeatures == ChannelFeatures(Features.StaticRemoteKey, Features.AnchorOutputsZeroFeeHtlcTx)) // bob publishes his last current commit tx, the one it had when entering NEGOTIATING state val bobCommitTx = bobCommitTxs.last.commitTx.tx assert(bobCommitTx.txOut.size == 4) // two main outputs + two anchors @@ -705,7 +705,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with def testRemoteCommitTxWithHtlcsConfirmed(f: FixtureParam, channelFeatures: ChannelFeatures): Unit = { import f._ - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures === channelFeatures) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures == channelFeatures) // alice sends a first htlc to bob val (ra1, htlca1) = addHtlc(15000000 msat, alice, bob, alice2bob, bob2alice) @@ -719,13 +719,13 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // Bob publishes the latest commit tx. val bobCommitTx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx channelFeatures.commitmentFormat match { - case _: AnchorOutputsCommitmentFormat => assert(bobCommitTx.txOut.length === 7) // two main outputs + two anchors + 3 HTLCs - case DefaultCommitmentFormat => assert(bobCommitTx.txOut.length === 5) // two main outputs + 3 HTLCs + case _: AnchorOutputsCommitmentFormat => assert(bobCommitTx.txOut.length == 7) // two main outputs + two anchors + 3 HTLCs + case DefaultCommitmentFormat => assert(bobCommitTx.txOut.length == 5) // two main outputs + 3 HTLCs } val closingState = remoteClose(bobCommitTx, alice, alice2blockchain) - assert(closingState.claimHtlcTxs.size === 3) + assert(closingState.claimHtlcTxs.size == 3) val claimHtlcTimeoutTxs = getClaimHtlcTimeoutTxs(closingState).map(_.tx) - assert(claimHtlcTimeoutTxs.length === 3) + assert(claimHtlcTimeoutTxs.length == 3) alice ! WatchTxConfirmedTriggered(BlockHeight(42), 0, bobCommitTx) alice ! WatchTxConfirmedTriggered(BlockHeight(45), 0, closingState.claimMainOutputTx.get.tx) @@ -738,7 +738,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2relayer.expectNoMessage(250 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(203), 1, claimHtlcTimeoutTxs(2)) val forwardedFail3 = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc - assert(Set(forwardedFail1, forwardedFail2, forwardedFail3) === Set(htlca1, htlca2, htlca3)) + assert(Set(forwardedFail1, forwardedFail2, forwardedFail3) == Set(htlca1, htlca2, htlca3)) alice2relayer.expectNoMessage(250 millis) awaitCond(alice.stateName == CLOSED) } @@ -769,36 +769,36 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // Now Bob publishes the first commit tx (force-close). val bobCommitTx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx - assert(bobCommitTx.txOut.length === 3) // two main outputs + 1 HTLC + assert(bobCommitTx.txOut.length == 3) // two main outputs + 1 HTLC val closingState = remoteClose(bobCommitTx, alice, alice2blockchain) assert(closingState.claimMainOutputTx.nonEmpty) - assert(closingState.claimHtlcTxs.size === 1) + assert(closingState.claimHtlcTxs.size == 1) assert(getClaimHtlcSuccessTxs(closingState).isEmpty) // we don't have the preimage to claim the htlc-success yet assert(getClaimHtlcTimeoutTxs(closingState).isEmpty) // Alice receives the preimage for the first HTLC from downstream; she can now claim the corresponding HTLC output. alice ! CMD_FULFILL_HTLC(htlc1.id, r1, commit = true) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === closingState.claimMainOutputTx.get.tx) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == closingState.claimMainOutputTx.get.tx) val claimHtlcSuccessTx = getClaimHtlcSuccessTxs(alice.stateData.asInstanceOf[DATA_CLOSING].remoteCommitPublished.get).head.tx Transaction.correctlySpends(claimHtlcSuccessTx, bobCommitTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) val publishHtlcSuccessTx = alice2blockchain.expectMsgType[PublishReplaceableTx] - assert(publishHtlcSuccessTx.txInfo.tx === claimHtlcSuccessTx) - assert(publishHtlcSuccessTx.txInfo.confirmBefore.toLong === htlc1.cltvExpiry.toLong) + assert(publishHtlcSuccessTx.txInfo.tx == claimHtlcSuccessTx) + assert(publishHtlcSuccessTx.txInfo.confirmBefore.toLong == htlc1.cltvExpiry.toLong) // Alice resets watches on all relevant transactions. - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === closingState.claimMainOutputTx.get.tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == closingState.claimMainOutputTx.get.tx.txid) val watchHtlcSuccess = alice2blockchain.expectMsgType[WatchOutputSpent] - assert(watchHtlcSuccess.txId === bobCommitTx.txid) - assert(watchHtlcSuccess.outputIndex === claimHtlcSuccessTx.txIn.head.outPoint.index) + assert(watchHtlcSuccess.txId == bobCommitTx.txid) + assert(watchHtlcSuccess.outputIndex == claimHtlcSuccessTx.txIn.head.outPoint.index) alice2blockchain.expectNoMessage(100 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, bobCommitTx) // The second htlc was not included in the commit tx published on-chain, so we can consider it failed - assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc === htlc2) + assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc == htlc2) alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, closingState.claimMainOutputTx.get.tx) alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, claimHtlcSuccessTx) - assert(alice.stateData.asInstanceOf[DATA_CLOSING].remoteCommitPublished.get.irrevocablySpent.values.toSet === Set(bobCommitTx, closingState.claimMainOutputTx.get.tx, claimHtlcSuccessTx)) + assert(alice.stateData.asInstanceOf[DATA_CLOSING].remoteCommitPublished.get.irrevocablySpent.values.toSet == Set(bobCommitTx, closingState.claimMainOutputTx.get.tx, claimHtlcSuccessTx)) awaitCond(alice.stateName == CLOSED) alice2blockchain.expectNoMessage(100 millis) alice2relayer.expectNoMessage(100 millis) @@ -823,18 +823,18 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(alice.stateName == CLOSING) // we should re-publish unconfirmed transactions - closingState.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimMain.tx)) + closingState.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimMain.tx)) val publishHtlcTimeoutTx = alice2blockchain.expectMsgType[PublishReplaceableTx] - assert(publishHtlcTimeoutTx.txInfo.tx === htlcTimeoutTx.tx) - assert(publishHtlcTimeoutTx.txInfo.confirmBefore.toLong === htlca.cltvExpiry.toLong) - closingState.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.tx.txid)) - assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex === htlcTimeoutTx.input.outPoint.index) + assert(publishHtlcTimeoutTx.txInfo.tx == htlcTimeoutTx.tx) + assert(publishHtlcTimeoutTx.txInfo.confirmBefore.toLong == htlca.cltvExpiry.toLong) + closingState.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.tx.txid)) + assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex == htlcTimeoutTx.input.outPoint.index) } private def testNextRemoteCommitTxConfirmed(f: FixtureParam, channelFeatures: ChannelFeatures): (Transaction, RemoteCommitPublished, Set[UpdateAddHtlc]) = { import f._ - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures === channelFeatures) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures == channelFeatures) // alice sends a first htlc to bob val (ra1, htlca1) = addHtlc(15000000 msat, alice, bob, alice2bob, bob2alice) @@ -854,11 +854,11 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // Bob publishes the next commit tx. val bobCommitTx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx channelFeatures.commitmentFormat match { - case _: AnchorOutputsCommitmentFormat => assert(bobCommitTx.txOut.length === 7) // two main outputs + two anchors + 3 HTLCs - case DefaultCommitmentFormat => assert(bobCommitTx.txOut.length === 5) // two main outputs + 3 HTLCs + case _: AnchorOutputsCommitmentFormat => assert(bobCommitTx.txOut.length == 7) // two main outputs + two anchors + 3 HTLCs + case DefaultCommitmentFormat => assert(bobCommitTx.txOut.length == 5) // two main outputs + 3 HTLCs } val closingState = remoteClose(bobCommitTx, alice, alice2blockchain) - assert(getClaimHtlcTimeoutTxs(closingState).length === 3) + assert(getClaimHtlcTimeoutTxs(closingState).length == 3) (bobCommitTx, closingState, Set(htlca1, htlca2, htlca3)) } @@ -866,11 +866,11 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val (bobCommitTx, closingState, htlcs) = testNextRemoteCommitTxConfirmed(f, ChannelFeatures()) val txPublished = txListener.expectMsgType[TransactionPublished] - assert(txPublished.tx === bobCommitTx) + assert(txPublished.tx == bobCommitTx) assert(txPublished.miningFee > 0.sat) // alice is funder, she pays the fee for the remote commit val claimHtlcTimeoutTxs = getClaimHtlcTimeoutTxs(closingState).map(_.tx) alice ! WatchTxConfirmedTriggered(BlockHeight(42), 0, bobCommitTx) - assert(txListener.expectMsgType[TransactionConfirmed].tx === bobCommitTx) + assert(txListener.expectMsgType[TransactionConfirmed].tx == bobCommitTx) alice ! WatchTxConfirmedTriggered(BlockHeight(45), 0, closingState.claimMainOutputTx.get.tx) alice2relayer.expectNoMessage(100 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(201), 0, claimHtlcTimeoutTxs(0)) @@ -881,7 +881,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2relayer.expectNoMessage(250 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(203), 1, claimHtlcTimeoutTxs(2)) val forwardedFail3 = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc - assert(Set(forwardedFail1, forwardedFail2, forwardedFail3) === htlcs) + assert(Set(forwardedFail1, forwardedFail2, forwardedFail3) == htlcs) alice2relayer.expectNoMessage(250 millis) awaitCond(alice.stateName == CLOSED) } @@ -901,7 +901,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2relayer.expectNoMessage(250 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(203), 1, claimHtlcTimeoutTxs(2)) val forwardedFail3 = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc - assert(Set(forwardedFail1, forwardedFail2, forwardedFail3) === htlcs) + assert(Set(forwardedFail1, forwardedFail2, forwardedFail3) == htlcs) alice2relayer.expectNoMessage(250 millis) awaitCond(alice.stateName == CLOSED) } @@ -921,7 +921,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2relayer.expectNoMessage(250 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(203), 1, claimHtlcTimeoutTxs(2)) val forwardedFail3 = alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc - assert(Set(forwardedFail1, forwardedFail2, forwardedFail3) === htlcs) + assert(Set(forwardedFail1, forwardedFail2, forwardedFail3) == htlcs) alice2relayer.expectNoMessage(250 millis) awaitCond(alice.stateName == CLOSED) } @@ -943,38 +943,38 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // Now Bob publishes the next commit tx (force-close). val bobCommitTx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx - assert(bobCommitTx.txOut.length === 4) // two main outputs + 2 HTLCs + assert(bobCommitTx.txOut.length == 4) // two main outputs + 2 HTLCs val closingState = remoteClose(bobCommitTx, alice, alice2blockchain) assert(closingState.claimMainOutputTx.nonEmpty) - assert(closingState.claimHtlcTxs.size === 2) + assert(closingState.claimHtlcTxs.size == 2) assert(getClaimHtlcSuccessTxs(closingState).isEmpty) // we don't have the preimage to claim the htlc-success yet - assert(getClaimHtlcTimeoutTxs(closingState).length === 1) + assert(getClaimHtlcTimeoutTxs(closingState).length == 1) val claimHtlcTimeoutTx = getClaimHtlcTimeoutTxs(closingState).head.tx // Alice receives the preimage for the first HTLC from downstream; she can now claim the corresponding HTLC output. alice ! CMD_FULFILL_HTLC(htlc1.id, r1, commit = true) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === closingState.claimMainOutputTx.get.tx) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == closingState.claimMainOutputTx.get.tx) val claimHtlcSuccessTx = getClaimHtlcSuccessTxs(alice.stateData.asInstanceOf[DATA_CLOSING].nextRemoteCommitPublished.get).head.tx Transaction.correctlySpends(claimHtlcSuccessTx, bobCommitTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) val publishHtlcSuccessTx = alice2blockchain.expectMsgType[PublishReplaceableTx] - assert(publishHtlcSuccessTx.txInfo.tx === claimHtlcSuccessTx) - assert(publishHtlcSuccessTx.txInfo.confirmBefore.toLong === htlc1.cltvExpiry.toLong) + assert(publishHtlcSuccessTx.txInfo.tx == claimHtlcSuccessTx) + assert(publishHtlcSuccessTx.txInfo.confirmBefore.toLong == htlc1.cltvExpiry.toLong) val publishHtlcTimeoutTx = alice2blockchain.expectMsgType[PublishReplaceableTx] - assert(publishHtlcTimeoutTx.txInfo.tx === claimHtlcTimeoutTx) - assert(publishHtlcTimeoutTx.txInfo.confirmBefore.toLong === htlc2.cltvExpiry.toLong) + assert(publishHtlcTimeoutTx.txInfo.tx == claimHtlcTimeoutTx) + assert(publishHtlcTimeoutTx.txInfo.confirmBefore.toLong == htlc2.cltvExpiry.toLong) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === closingState.claimMainOutputTx.get.tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == closingState.claimMainOutputTx.get.tx.txid) val watchHtlcs = alice2blockchain.expectMsgType[WatchOutputSpent] :: alice2blockchain.expectMsgType[WatchOutputSpent] :: Nil - watchHtlcs.foreach(ws => assert(ws.txId === bobCommitTx.txid)) - assert(watchHtlcs.map(_.outputIndex).toSet === Set(claimHtlcSuccessTx, claimHtlcTimeoutTx).map(_.txIn.head.outPoint.index)) + watchHtlcs.foreach(ws => assert(ws.txId == bobCommitTx.txid)) + assert(watchHtlcs.map(_.outputIndex).toSet == Set(claimHtlcSuccessTx, claimHtlcTimeoutTx).map(_.txIn.head.outPoint.index)) alice2blockchain.expectNoMessage(100 millis) alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, bobCommitTx) alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, closingState.claimMainOutputTx.get.tx) alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, claimHtlcSuccessTx) alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, claimHtlcTimeoutTx) - assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc === htlc2) + assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]].htlc == htlc2) awaitCond(alice.stateName == CLOSED) alice2blockchain.expectNoMessage(100 millis) alice2relayer.expectNoMessage(100 millis) @@ -996,17 +996,17 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // the commit tx hasn't been confirmed yet, so we watch the funding output first alice2blockchain.expectMsgType[WatchFundingSpent] // then we should re-publish unconfirmed transactions - closingState.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimMain.tx)) - claimHtlcTimeoutTxs.foreach(claimHtlcTimeout => assert(alice2blockchain.expectMsgType[PublishReplaceableTx].txInfo.tx === claimHtlcTimeout.tx)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) - closingState.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.tx.txid)) - claimHtlcTimeoutTxs.foreach(claimHtlcTimeout => assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex === claimHtlcTimeout.input.outPoint.index)) + closingState.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimMain.tx)) + claimHtlcTimeoutTxs.foreach(claimHtlcTimeout => assert(alice2blockchain.expectMsgType[PublishReplaceableTx].txInfo.tx == claimHtlcTimeout.tx)) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) + closingState.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.tx.txid)) + claimHtlcTimeoutTxs.foreach(claimHtlcTimeout => assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex == claimHtlcTimeout.input.outPoint.index)) } private def testFutureRemoteCommitTxConfirmed(f: FixtureParam, channelFeatures: ChannelFeatures): Transaction = { import f._ val oldStateData = alice.stateData - assert(oldStateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures === channelFeatures) + assert(oldStateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures == channelFeatures) // This HTLC will be fulfilled. val (ra1, htlca1) = addHtlc(25000000 msat, alice, bob, alice2bob, bob2alice) // These 2 HTLCs should timeout on-chain, but since alice lost data, she won't be able to claim them. @@ -1035,14 +1035,14 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with bob2alice.forward(alice) // ... and ask bob to publish its current commitment val error = alice2bob.expectMsgType[Error] - assert(new String(error.data.toArray) === PleasePublishYourCommitment(channelId(alice)).getMessage) + assert(new String(error.data.toArray) == PleasePublishYourCommitment(channelId(alice)).getMessage) // alice now waits for bob to publish its commitment awaitCond(alice.stateName == WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT) // bob is nice and publishes its commitment val bobCommitTx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx channelFeatures.commitmentFormat match { - case _: AnchorOutputsCommitmentFormat => assert(bobCommitTx.txOut.length === 6) // two main outputs + two anchors + 2 HTLCs - case DefaultCommitmentFormat => assert(bobCommitTx.txOut.length === 4) // two main outputs + 2 HTLCs + case _: AnchorOutputsCommitmentFormat => assert(bobCommitTx.txOut.length == 6) // two main outputs + two anchors + 2 HTLCs + case DefaultCommitmentFormat => assert(bobCommitTx.txOut.length == 4) // two main outputs + 2 HTLCs } alice ! WatchFundingSpentTriggered(bobCommitTx) bobCommitTx @@ -1052,19 +1052,19 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val bobCommitTx = testFutureRemoteCommitTxConfirmed(f, ChannelFeatures()) val txPublished = txListener.expectMsgType[TransactionPublished] - assert(txPublished.tx === bobCommitTx) + assert(txPublished.tx == bobCommitTx) assert(txPublished.miningFee > 0.sat) // alice is funder, she pays the fee for the remote commit // alice is able to claim its main output val claimMainTx = alice2blockchain.expectMsgType[PublishFinalTx].tx Transaction.correctlySpends(claimMainTx, bobCommitTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].futureRemoteCommitPublished.isDefined) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMainTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMainTx.txid) alice2blockchain.expectNoMessage(250 millis) // alice ignores the htlc-timeout // actual test starts here alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, bobCommitTx) - assert(txListener.expectMsgType[TransactionConfirmed].tx === bobCommitTx) + assert(txListener.expectMsgType[TransactionConfirmed].tx == bobCommitTx) alice ! WatchTxConfirmedTriggered(BlockHeight(0), 0, claimMainTx) awaitCond(alice.stateName == CLOSED) } @@ -1085,9 +1085,9 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // alice is able to claim its main output val claimMainTx = alice2blockchain.expectMsgType[PublishFinalTx].tx Transaction.correctlySpends(claimMainTx, bobCommitTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].futureRemoteCommitPublished.isDefined) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMainTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMainTx.txid) alice2blockchain.expectNoMessage(250 millis) // alice ignores the htlc-timeout // actual test starts here @@ -1110,8 +1110,8 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // then we should claim our main output val claimMainTx = alice2blockchain.expectMsgType[PublishFinalTx].tx Transaction.correctlySpends(claimMainTx, bobCommitTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobCommitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMainTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobCommitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMainTx.txid) } case class RevokedCloseFixture(bobRevokedTxs: Seq[LocalCommit], htlcsAlice: Seq[(UpdateAddHtlc, ByteVector32)], htlcsBob: Seq[(UpdateAddHtlc, ByteVector32)]) @@ -1122,8 +1122,8 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // Bob's first commit tx doesn't contain any htlc val localCommit1 = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit channelFeatures.commitmentFormat match { - case _: AnchorOutputsCommitmentFormat => assert(localCommit1.commitTxAndRemoteSig.commitTx.tx.txOut.size === 4) // 2 main outputs + 2 anchors - case DefaultCommitmentFormat => assert(localCommit1.commitTxAndRemoteSig.commitTx.tx.txOut.size === 2) // 2 main outputs + case _: AnchorOutputsCommitmentFormat => assert(localCommit1.commitTxAndRemoteSig.commitTx.tx.txOut.size == 4) // 2 main outputs + 2 anchors + case DefaultCommitmentFormat => assert(localCommit1.commitTxAndRemoteSig.commitTx.tx.txOut.size == 2) // 2 main outputs } // Bob's second commit tx contains 1 incoming htlc and 1 outgoing htlc @@ -1138,8 +1138,8 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx.txOut.size == localCommit2.commitTxAndRemoteSig.commitTx.tx.txOut.size) channelFeatures.commitmentFormat match { - case _: AnchorOutputsCommitmentFormat => assert(localCommit2.commitTxAndRemoteSig.commitTx.tx.txOut.size === 6) - case DefaultCommitmentFormat => assert(localCommit2.commitTxAndRemoteSig.commitTx.tx.txOut.size === 4) + case _: AnchorOutputsCommitmentFormat => assert(localCommit2.commitTxAndRemoteSig.commitTx.tx.txOut.size == 6) + case DefaultCommitmentFormat => assert(localCommit2.commitTxAndRemoteSig.commitTx.tx.txOut.size == 4) } // Bob's third commit tx contains 2 incoming htlcs and 2 outgoing htlcs @@ -1154,8 +1154,8 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx.txOut.size == localCommit3.commitTxAndRemoteSig.commitTx.tx.txOut.size) channelFeatures.commitmentFormat match { - case _: AnchorOutputsCommitmentFormat => assert(localCommit3.commitTxAndRemoteSig.commitTx.tx.txOut.size === 8) - case DefaultCommitmentFormat => assert(localCommit3.commitTxAndRemoteSig.commitTx.tx.txOut.size === 6) + case _: AnchorOutputsCommitmentFormat => assert(localCommit3.commitTxAndRemoteSig.commitTx.tx.txOut.size == 8) + case DefaultCommitmentFormat => assert(localCommit3.commitTxAndRemoteSig.commitTx.tx.txOut.size == 6) } // Bob's fourth commit tx doesn't contain any htlc @@ -1168,8 +1168,8 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx.txOut.size == localCommit4.commitTxAndRemoteSig.commitTx.tx.txOut.size) channelFeatures.commitmentFormat match { - case _: AnchorOutputsCommitmentFormat => assert(localCommit4.commitTxAndRemoteSig.commitTx.tx.txOut.size === 4) - case DefaultCommitmentFormat => assert(localCommit4.commitTxAndRemoteSig.commitTx.tx.txOut.size === 2) + case _: AnchorOutputsCommitmentFormat => assert(localCommit4.commitTxAndRemoteSig.commitTx.tx.txOut.size == 4) + case DefaultCommitmentFormat => assert(localCommit4.commitTxAndRemoteSig.commitTx.tx.txOut.size == 2) } RevokedCloseFixture(Seq(localCommit1, localCommit2, localCommit3, localCommit4), Seq(htlcAlice1, htlcAlice2), Seq(htlcBob1, htlcBob2)) @@ -1179,7 +1179,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with import f._ val revokedCloseFixture = prepareRevokedClose(f, channelFeatures) - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures === channelFeatures) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures == channelFeatures) // bob publishes one of his revoked txs val bobRevokedTx = revokedCloseFixture.bobRevokedTxs(1).commitTxAndRemoteSig.commitTx.tx @@ -1188,46 +1188,46 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(alice.stateData.isInstanceOf[DATA_CLOSING]) awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.size == 1) val rvk = alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head - assert(rvk.commitTx === bobRevokedTx) + assert(rvk.commitTx == bobRevokedTx) if (!channelFeatures.paysDirectlyToWallet) { assert(rvk.claimMainOutputTx.nonEmpty) } assert(rvk.mainPenaltyTx.nonEmpty) - assert(rvk.htlcPenaltyTxs.size === 2) + assert(rvk.htlcPenaltyTxs.size == 2) assert(rvk.claimHtlcDelayedPenaltyTxs.isEmpty) val penaltyTxs = rvk.claimMainOutputTx.toList ++ rvk.mainPenaltyTx.toList ++ rvk.htlcPenaltyTxs // alice publishes the penalty txs if (!channelFeatures.paysDirectlyToWallet) { - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === rvk.claimMainOutputTx.get.tx) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == rvk.claimMainOutputTx.get.tx) } - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === rvk.mainPenaltyTx.get.tx) - assert(Set(alice2blockchain.expectMsgType[PublishFinalTx].tx, alice2blockchain.expectMsgType[PublishFinalTx].tx) === rvk.htlcPenaltyTxs.map(_.tx).toSet) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == rvk.mainPenaltyTx.get.tx) + assert(Set(alice2blockchain.expectMsgType[PublishFinalTx].tx, alice2blockchain.expectMsgType[PublishFinalTx].tx) == rvk.htlcPenaltyTxs.map(_.tx).toSet) for (penaltyTx <- penaltyTxs) { Transaction.correctlySpends(penaltyTx.tx, bobRevokedTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) } // alice spends all outpoints of the revoked tx, except her main output when it goes directly to our wallet val spentOutpoints = penaltyTxs.flatMap(_.tx.txIn.map(_.outPoint)).toSet - assert(spentOutpoints.forall(_.txid === bobRevokedTx.txid)) + assert(spentOutpoints.forall(_.txid == bobRevokedTx.txid)) if (channelFeatures.commitmentFormat.isInstanceOf[AnchorOutputsCommitmentFormat]) { - assert(spentOutpoints.size === bobRevokedTx.txOut.size - 2) // we don't claim the anchors + assert(spentOutpoints.size == bobRevokedTx.txOut.size - 2) // we don't claim the anchors } else if (channelFeatures.paysDirectlyToWallet) { - assert(spentOutpoints.size === bobRevokedTx.txOut.size - 1) // we don't claim our main output, it directly goes to our wallet + assert(spentOutpoints.size == bobRevokedTx.txOut.size - 1) // we don't claim our main output, it directly goes to our wallet } else { - assert(spentOutpoints.size === bobRevokedTx.txOut.size) + assert(spentOutpoints.size == bobRevokedTx.txOut.size) } // alice watches confirmation for the outputs only her can claim - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobRevokedTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobRevokedTx.txid) if (!channelFeatures.paysDirectlyToWallet) { - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === rvk.claimMainOutputTx.get.tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == rvk.claimMainOutputTx.get.tx.txid) } // alice watches outputs that can be spent by both parties val watchedOutpoints = Seq(alice2blockchain.expectMsgType[WatchOutputSpent], alice2blockchain.expectMsgType[WatchOutputSpent], alice2blockchain.expectMsgType[WatchOutputSpent]).map(_.outputIndex).toSet - assert(watchedOutpoints === (rvk.mainPenaltyTx.get :: rvk.htlcPenaltyTxs).map(_.input.outPoint.index).toSet) + assert(watchedOutpoints == (rvk.mainPenaltyTx.get :: rvk.htlcPenaltyTxs).map(_.input.outPoint.index).toSet) alice2blockchain.expectNoMessage(1 second) (bobRevokedTx, rvk) @@ -1238,20 +1238,20 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val (bobRevokedTx, rvk) = setupFundingSpentRevokedTx(f, channelFeatures) val txPublished = txListener.expectMsgType[TransactionPublished] - assert(txPublished.tx === bobRevokedTx) + assert(txPublished.tx == bobRevokedTx) assert(txPublished.miningFee > 0.sat) // alice is funder, she pays the fee for the revoked commit // once all txs are confirmed, alice can move to the closed state alice ! WatchTxConfirmedTriggered(BlockHeight(100), 3, bobRevokedTx) - assert(txListener.expectMsgType[TransactionConfirmed].tx === bobRevokedTx) + assert(txListener.expectMsgType[TransactionConfirmed].tx == bobRevokedTx) alice ! WatchTxConfirmedTriggered(BlockHeight(110), 1, rvk.mainPenaltyTx.get.tx) if (!channelFeatures.paysDirectlyToWallet) { alice ! WatchTxConfirmedTriggered(BlockHeight(110), 2, rvk.claimMainOutputTx.get.tx) } alice ! WatchTxConfirmedTriggered(BlockHeight(115), 0, rvk.htlcPenaltyTxs(0).tx) - assert(alice.stateName === CLOSING) + assert(alice.stateName == CLOSING) alice ! WatchTxConfirmedTriggered(BlockHeight(115), 2, rvk.htlcPenaltyTxs(1).tx) - awaitCond(alice.stateName === CLOSED) + awaitCond(alice.stateName == CLOSED) } test("recv WatchFundingSpentTriggered (one revoked tx)") { f => @@ -1273,13 +1273,13 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with test("recv WatchFundingSpentTriggered (multiple revoked tx)") { f => import f._ val revokedCloseFixture = prepareRevokedClose(f, ChannelFeatures()) - assert(revokedCloseFixture.bobRevokedTxs.map(_.commitTxAndRemoteSig.commitTx.tx.txid).toSet.size === revokedCloseFixture.bobRevokedTxs.size) // all commit txs are distinct + assert(revokedCloseFixture.bobRevokedTxs.map(_.commitTxAndRemoteSig.commitTx.tx.txid).toSet.size == revokedCloseFixture.bobRevokedTxs.size) // all commit txs are distinct def broadcastBobRevokedTx(revokedTx: Transaction, htlcCount: Int, revokedCount: Int): RevokedCommitPublished = { alice ! WatchFundingSpentTriggered(revokedTx) awaitCond(alice.stateData.isInstanceOf[DATA_CLOSING]) awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.size == revokedCount) - assert(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.last.commitTx === revokedTx) + assert(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.last.commitTx == revokedTx) // alice publishes penalty txs val claimMain = alice2blockchain.expectMsgType[PublishFinalTx].tx @@ -1288,13 +1288,13 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with (claimMain +: mainPenalty +: htlcPenaltyTxs).foreach(tx => Transaction.correctlySpends(tx, revokedTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS)) // alice watches confirmation for the outputs only her can claim - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === revokedTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == revokedTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.txid) // alice watches outputs that can be spent by both parties - assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex === mainPenalty.txIn.head.outPoint.index) + assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex == mainPenalty.txIn.head.outPoint.index) val htlcOutpoints = (1 to htlcCount).map(_ => alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex).toSet - assert(htlcOutpoints === htlcPenaltyTxs.flatMap(_.txIn.map(_.outPoint.index)).toSet) + assert(htlcOutpoints == htlcPenaltyTxs.flatMap(_.txIn.map(_.outPoint.index)).toSet) alice2blockchain.expectNoMessage(1 second) alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.last @@ -1313,9 +1313,9 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice ! WatchTxConfirmedTriggered(BlockHeight(100), 2, rvk2.claimMainOutputTx.get.tx) alice ! WatchTxConfirmedTriggered(BlockHeight(100), 3, rvk2.commitTx) alice ! WatchTxConfirmedTriggered(BlockHeight(115), 0, rvk2.htlcPenaltyTxs(0).tx) - assert(alice.stateName === CLOSING) + assert(alice.stateName == CLOSING) alice ! WatchTxConfirmedTriggered(BlockHeight(115), 2, rvk2.htlcPenaltyTxs(1).tx) - awaitCond(alice.stateName === CLOSED) + awaitCond(alice.stateName == CLOSED) } def testInputRestoredRevokedTx(f: FixtureParam, channelFeatures: ChannelFeatures): Unit = { @@ -1333,13 +1333,13 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with // the commit tx hasn't been confirmed yet, so we watch the funding output first alice2blockchain.expectMsgType[WatchFundingSpent] // then we should re-publish unconfirmed transactions - rvk.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimMain.tx)) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === rvk.mainPenaltyTx.get.tx) - rvk.htlcPenaltyTxs.foreach(htlcPenalty => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === htlcPenalty.tx)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobRevokedTx.txid) - rvk.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === claimMain.tx.txid)) - assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex === rvk.mainPenaltyTx.get.input.outPoint.index) - rvk.htlcPenaltyTxs.foreach(htlcPenalty => assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex === htlcPenalty.input.outPoint.index)) + rvk.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimMain.tx)) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == rvk.mainPenaltyTx.get.tx) + rvk.htlcPenaltyTxs.foreach(htlcPenalty => assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == htlcPenalty.tx)) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobRevokedTx.txid) + rvk.claimMainOutputTx.foreach(claimMain => assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == claimMain.tx.txid)) + assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex == rvk.mainPenaltyTx.get.input.outPoint.index) + rvk.htlcPenaltyTxs.foreach(htlcPenalty => assert(alice2blockchain.expectMsgType[WatchOutputSpent].outputIndex == htlcPenalty.input.outPoint.index)) } test("recv INPUT_RESTORED (one revoked tx)") { f => @@ -1357,7 +1357,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with def testOutputSpentRevokedTx(f: FixtureParam, channelFeatures: ChannelFeatures): Unit = { import f._ val revokedCloseFixture = prepareRevokedClose(f, channelFeatures) - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures === channelFeatures) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures == channelFeatures) val commitmentFormat = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.commitmentFormat // bob publishes one of his revoked txs @@ -1367,22 +1367,22 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(alice.stateData.isInstanceOf[DATA_CLOSING]) awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.size == 1) val rvk = alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head - assert(rvk.commitTx === bobRevokedCommit.commitTxAndRemoteSig.commitTx.tx) + assert(rvk.commitTx == bobRevokedCommit.commitTxAndRemoteSig.commitTx.tx) if (channelFeatures.paysDirectlyToWallet) { assert(rvk.claimMainOutputTx.isEmpty) } else { assert(rvk.claimMainOutputTx.nonEmpty) } assert(rvk.mainPenaltyTx.nonEmpty) - assert(rvk.htlcPenaltyTxs.size === 4) + assert(rvk.htlcPenaltyTxs.size == 4) assert(rvk.claimHtlcDelayedPenaltyTxs.isEmpty) // alice publishes the penalty txs and watches outputs val claimTxsCount = if (channelFeatures.paysDirectlyToWallet) 5 else 6 // 2 main outputs and 4 htlcs (1 to claimTxsCount).foreach(_ => alice2blockchain.expectMsgType[PublishTx]) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === rvk.commitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == rvk.commitTx.txid) if (!channelFeatures.paysDirectlyToWallet) { - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === rvk.claimMainOutputTx.get.tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == rvk.claimMainOutputTx.get.tx.txid) } (1 to 5).foreach(_ => alice2blockchain.expectMsgType[WatchOutputSpent]) // main output penalty and 4 htlc penalties alice2blockchain.expectNoMessage(1 second) @@ -1392,7 +1392,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val (failedHtlc, _) = revokedCloseFixture.htlcsBob.last val bobHtlcSuccessTx1 = bobRevokedCommit.htlcTxsAndRemoteSigs.collectFirst { case HtlcTxAndRemoteSig(txInfo: HtlcSuccessTx, _) if txInfo.htlcId == fulfilledHtlc.id => - assert(fulfilledHtlc.paymentHash === txInfo.paymentHash) + assert(fulfilledHtlc.paymentHash == txInfo.paymentHash) Transactions.addSigs(txInfo, ByteVector64.Zeroes, ByteVector64.Zeroes, preimage, commitmentFormat) }.get val bobHtlcTimeoutTx = bobRevokedCommit.htlcTxsAndRemoteSigs.collectFirst { @@ -1400,29 +1400,29 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Transactions.addSigs(txInfo, ByteVector64.Zeroes, ByteVector64.Zeroes, commitmentFormat) }.get val bobOutpoints = Seq(bobHtlcSuccessTx1, bobHtlcTimeoutTx).map(_.input.outPoint).toSet - assert(bobOutpoints.size === 2) + assert(bobOutpoints.size == 2) // alice reacts by publishing penalty txs that spend bob's htlc transactions alice ! WatchOutputSpentTriggered(bobHtlcSuccessTx1.tx) awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head.claimHtlcDelayedPenaltyTxs.size == 1) val claimHtlcSuccessPenalty1 = alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head.claimHtlcDelayedPenaltyTxs.last Transaction.correctlySpends(claimHtlcSuccessPenalty1.tx, bobHtlcSuccessTx1.tx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobHtlcSuccessTx1.tx.txid) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimHtlcSuccessPenalty1.tx) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobHtlcSuccessTx1.tx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimHtlcSuccessPenalty1.tx) val watchSpent1 = alice2blockchain.expectMsgType[WatchOutputSpent] - assert(watchSpent1.txId === bobHtlcSuccessTx1.tx.txid) - assert(watchSpent1.outputIndex === claimHtlcSuccessPenalty1.input.outPoint.index) + assert(watchSpent1.txId == bobHtlcSuccessTx1.tx.txid) + assert(watchSpent1.outputIndex == claimHtlcSuccessPenalty1.input.outPoint.index) alice2blockchain.expectNoMessage(1 second) alice ! WatchOutputSpentTriggered(bobHtlcTimeoutTx.tx) awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head.claimHtlcDelayedPenaltyTxs.size == 2) val claimHtlcTimeoutPenalty = alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head.claimHtlcDelayedPenaltyTxs.last Transaction.correctlySpends(claimHtlcTimeoutPenalty.tx, bobHtlcTimeoutTx.tx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobHtlcTimeoutTx.tx.txid) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimHtlcTimeoutPenalty.tx) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobHtlcTimeoutTx.tx.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimHtlcTimeoutPenalty.tx) val watchSpent2 = alice2blockchain.expectMsgType[WatchOutputSpent] - assert(watchSpent2.txId === bobHtlcTimeoutTx.tx.txid) - assert(watchSpent2.outputIndex === claimHtlcTimeoutPenalty.input.outPoint.index) + assert(watchSpent2.txId == bobHtlcTimeoutTx.tx.txid) + assert(watchSpent2.outputIndex == claimHtlcTimeoutPenalty.input.outPoint.index) alice2blockchain.expectNoMessage(1 second) // bob RBFs his htlc-success with a different transaction @@ -1433,16 +1433,16 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val claimHtlcSuccessPenalty2 = alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head.claimHtlcDelayedPenaltyTxs.last assert(claimHtlcSuccessPenalty1.tx.txid != claimHtlcSuccessPenalty2.tx.txid) Transaction.correctlySpends(claimHtlcSuccessPenalty2.tx, bobHtlcSuccessTx2 :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobHtlcSuccessTx2.txid) - assert(alice2blockchain.expectMsgType[PublishFinalTx].tx === claimHtlcSuccessPenalty2.tx) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobHtlcSuccessTx2.txid) + assert(alice2blockchain.expectMsgType[PublishFinalTx].tx == claimHtlcSuccessPenalty2.tx) val watchSpent3 = alice2blockchain.expectMsgType[WatchOutputSpent] - assert(watchSpent3.txId === bobHtlcSuccessTx2.txid) - assert(watchSpent3.outputIndex === claimHtlcSuccessPenalty2.input.outPoint.index) + assert(watchSpent3.txId == bobHtlcSuccessTx2.txid) + assert(watchSpent3.outputIndex == claimHtlcSuccessPenalty2.input.outPoint.index) alice2blockchain.expectNoMessage(1 second) // transactions confirm: alice can move to the closed state val remainingHtlcPenaltyTxs = rvk.htlcPenaltyTxs.filterNot(htlcPenalty => bobOutpoints.contains(htlcPenalty.input.outPoint)) - assert(remainingHtlcPenaltyTxs.size === 2) + assert(remainingHtlcPenaltyTxs.size == 2) alice ! WatchTxConfirmedTriggered(BlockHeight(100), 3, rvk.commitTx) alice ! WatchTxConfirmedTriggered(BlockHeight(110), 0, rvk.mainPenaltyTx.get.tx) if (!channelFeatures.paysDirectlyToWallet) { @@ -1452,11 +1452,11 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice ! WatchTxConfirmedTriggered(BlockHeight(115), 2, remainingHtlcPenaltyTxs.last.tx) alice ! WatchTxConfirmedTriggered(BlockHeight(115), 0, bobHtlcTimeoutTx.tx) alice ! WatchTxConfirmedTriggered(BlockHeight(115), 1, bobHtlcSuccessTx2) - assert(alice.stateName === CLOSING) + assert(alice.stateName == CLOSING) alice ! WatchTxConfirmedTriggered(BlockHeight(120), 0, claimHtlcTimeoutPenalty.tx) alice ! WatchTxConfirmedTriggered(BlockHeight(121), 0, claimHtlcSuccessPenalty2.tx) - awaitCond(alice.stateName === CLOSED) + awaitCond(alice.stateName == CLOSED) } test("recv WatchOutputSpentTriggered (one revoked tx, counterparty published htlc-success tx)") { f => @@ -1484,17 +1484,17 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val commitmentFormat = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.commitmentFormat alice ! WatchFundingSpentTriggered(bobRevokedCommit.commitTxAndRemoteSig.commitTx.tx) awaitCond(alice.stateData.isInstanceOf[DATA_CLOSING]) - assert(alice.stateData.asInstanceOf[DATA_CLOSING].commitments.commitmentFormat === ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) + assert(alice.stateData.asInstanceOf[DATA_CLOSING].commitments.commitmentFormat == ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.size == 1) val rvk = alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head - assert(rvk.commitTx === bobRevokedCommit.commitTxAndRemoteSig.commitTx.tx) - assert(rvk.htlcPenaltyTxs.size === 4) + assert(rvk.commitTx == bobRevokedCommit.commitTxAndRemoteSig.commitTx.tx) + assert(rvk.htlcPenaltyTxs.size == 4) assert(rvk.claimHtlcDelayedPenaltyTxs.isEmpty) // alice publishes the penalty txs and watches outputs (1 to 6).foreach(_ => alice2blockchain.expectMsgType[PublishTx]) // 2 main outputs and 4 htlcs - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === rvk.commitTx.txid) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === rvk.claimMainOutputTx.get.tx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == rvk.commitTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == rvk.claimMainOutputTx.get.tx.txid) (1 to 5).foreach(_ => alice2blockchain.expectMsgType[WatchOutputSpent]) // main output penalty and 4 htlc penalties alice2blockchain.expectNoMessage(1 second) @@ -1503,12 +1503,12 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val bobHtlcTxs = bobRevokedCommit.htlcTxsAndRemoteSigs.collect { case HtlcTxAndRemoteSig(txInfo: HtlcSuccessTx, _) => val preimage = revokedCloseFixture.htlcsAlice.collectFirst { case (add, preimage) if add.id == txInfo.htlcId => preimage }.get - assert(Crypto.sha256(preimage) === txInfo.paymentHash) + assert(Crypto.sha256(preimage) == txInfo.paymentHash) Transactions.addSigs(txInfo, ByteVector64.Zeroes, ByteVector64.Zeroes, preimage, commitmentFormat) case HtlcTxAndRemoteSig(txInfo: HtlcTimeoutTx, _) => Transactions.addSigs(txInfo, ByteVector64.Zeroes, ByteVector64.Zeroes, commitmentFormat) } - assert(bobHtlcTxs.map(_.input.outPoint).size === 4) + assert(bobHtlcTxs.map(_.input.outPoint).size == 4) val bobHtlcTx = Transaction( 2, Seq( @@ -1533,34 +1533,34 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head.claimHtlcDelayedPenaltyTxs.size == 4) val claimHtlcDelayedPenaltyTxs = alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head.claimHtlcDelayedPenaltyTxs val spentOutpoints = Set(OutPoint(bobHtlcTx, 1), OutPoint(bobHtlcTx, 2), OutPoint(bobHtlcTx, 3), OutPoint(bobHtlcTx, 4)) - assert(claimHtlcDelayedPenaltyTxs.map(_.input.outPoint).toSet === spentOutpoints) + assert(claimHtlcDelayedPenaltyTxs.map(_.input.outPoint).toSet == spentOutpoints) claimHtlcDelayedPenaltyTxs.foreach(claimHtlcPenalty => Transaction.correctlySpends(claimHtlcPenalty.tx, bobHtlcTx :: Nil, ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS)) - assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId === bobHtlcTx.txid) + assert(alice2blockchain.expectMsgType[WatchTxConfirmed].txId == bobHtlcTx.txid) val publishedPenaltyTxs = Set( alice2blockchain.expectMsgType[PublishFinalTx], alice2blockchain.expectMsgType[PublishFinalTx], alice2blockchain.expectMsgType[PublishFinalTx], alice2blockchain.expectMsgType[PublishFinalTx] ) - assert(publishedPenaltyTxs.map(_.tx) === claimHtlcDelayedPenaltyTxs.map(_.tx).toSet) + assert(publishedPenaltyTxs.map(_.tx) == claimHtlcDelayedPenaltyTxs.map(_.tx).toSet) val watchedOutpoints = Seq( alice2blockchain.expectMsgType[WatchOutputSpent], alice2blockchain.expectMsgType[WatchOutputSpent], alice2blockchain.expectMsgType[WatchOutputSpent], alice2blockchain.expectMsgType[WatchOutputSpent] ).map(w => OutPoint(w.txId.reverse, w.outputIndex)).toSet - assert(watchedOutpoints === spentOutpoints) + assert(watchedOutpoints == spentOutpoints) alice2blockchain.expectNoMessage(1 second) } private def testRevokedTxConfirmed(f: FixtureParam, channelFeatures: ChannelFeatures): Unit = { import f._ - assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures === channelFeatures) + assert(alice.stateData.asInstanceOf[DATA_NORMAL].commitments.channelFeatures == channelFeatures) val initOutputCount = channelFeatures.commitmentFormat match { case _: AnchorOutputsCommitmentFormat => 4 case DefaultCommitmentFormat => 2 } - assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx.txOut.size === initOutputCount) + assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx.txOut.size == initOutputCount) // bob's second commit tx contains 2 incoming htlcs val (bobRevokedTx, htlcs1) = { @@ -1568,7 +1568,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val (_, htlc2) = addHtlc(20000000 msat, alice, bob, alice2bob, bob2alice) crossSign(alice, bob, alice2bob, bob2alice) val bobCommitTx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx - assert(bobCommitTx.txOut.size === initOutputCount + 2) + assert(bobCommitTx.txOut.size == initOutputCount + 2) (bobCommitTx, Seq(htlc1, htlc2)) } @@ -1578,18 +1578,18 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with val (_, htlc4) = addHtlc(18000000 msat, alice, bob, alice2bob, bob2alice) failHtlc(htlcs1.head.id, bob, alice, bob2alice, alice2bob) crossSign(bob, alice, bob2alice, alice2bob) - assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx.txOut.size === initOutputCount + 3) + assert(bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.commitTxAndRemoteSig.commitTx.tx.txOut.size == initOutputCount + 3) Seq(htlc3, htlc4) } // alice's first htlc has been failed - assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.Fail]].htlc === htlcs1.head) + assert(alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.Fail]].htlc == htlcs1.head) alice2relayer.expectNoMessage(1 second) // bob publishes one of his revoked txs which quickly confirms alice ! WatchFundingSpentTriggered(bobRevokedTx) alice ! WatchTxConfirmedTriggered(BlockHeight(100), 1, bobRevokedTx) - awaitCond(alice.stateName === CLOSING) + awaitCond(alice.stateName == CLOSING) // alice should fail all pending htlcs val htlcFails = Seq( @@ -1597,7 +1597,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]], alice2relayer.expectMsgType[RES_ADD_SETTLED[Origin, HtlcResult.OnChainFail]] ).map(_.htlc).toSet - assert(htlcFails === Set(htlcs1(1), htlcs2(0), htlcs2(1))) + assert(htlcFails == Set(htlcs1(1), htlcs2(0), htlcs2(1))) alice2relayer.expectNoMessage(1 second) } @@ -1625,7 +1625,7 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with alice ! ChannelReestablish(channelId(bob), 42, 42, PrivateKey(ByteVector32.Zeroes), bobCurrentPerCommitmentPoint) val error = alice2bob.expectMsgType[Error] - assert(new String(error.data.toArray) === FundingTxSpent(channelId(alice), initialState.spendingTxs.head).getMessage) + assert(new String(error.data.toArray) == FundingTxSpent(channelId(alice), initialState.spendingTxs.head).getMessage) } test("recv CMD_CLOSE") { f => diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/ChaCha20Poly1305Spec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/ChaCha20Poly1305Spec.scala index 84da3119e0..de613699fe 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/ChaCha20Poly1305Spec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/ChaCha20Poly1305Spec.scala @@ -26,7 +26,7 @@ class ChaCha20Poly1305Spec extends AnyFunSuite { val key: ByteVector = hex"85d6be7857556d337f4452fe42d506a80103808afb0db2fd4abff6af4149f51b" val data: ByteVector = ByteVector.view("Cryptographic Forum Research Group".getBytes("UTF-8")) val mac = Poly1305.mac(key, data) - assert(mac === hex"a8061dc1305136c6c22b8baf0c0127a9") + assert(mac == hex"a8061dc1305136c6c22b8baf0c0127a9") } test("Poly1305 #2") { @@ -34,7 +34,7 @@ class ChaCha20Poly1305Spec extends AnyFunSuite { val key: ByteVector = ByteVector.view("this is 32-byte key for Poly1305".getBytes()) val data: ByteVector = ByteVector.view("Hello world!".getBytes("UTF-8")) val mac = Poly1305.mac(key, data) - assert(mac === hex"a6f745008f81c916a20dcc74eef2b2f0") + assert(mac == hex"a6f745008f81c916a20dcc74eef2b2f0") } test("Chacha20Poly1305 IETF RFC7539 tests") { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/RandomSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/RandomSpec.scala index 4e6b357f86..a5f5d240d1 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/RandomSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/RandomSpec.scala @@ -28,7 +28,7 @@ class RandomSpec extends AnyFunSuiteLike { test("random long generation") { for (rng <- Seq(new WeakRandom(), new StrongRandom())) { val randomNumbers = (1 to 1000).map(_ => rng.nextLong()) - assert(randomNumbers.toSet.size === 1000) + assert(randomNumbers.toSet.size == 1000) val entropy = randomNumbers.foldLeft(0.0) { case (current, next) => current + entropyScore(next) } / 1000 assert(entropy >= 0.98) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/ShaChainSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/ShaChainSpec.scala index 90b84d9347..c4ad17b189 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/ShaChainSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/ShaChainSpec.scala @@ -78,7 +78,7 @@ class ShaChainSpec extends AnyFunSuite { test("generate and receive hashes") { val result: List[ByteVector32] = (for (i <- 0 until 50) yield ShaChain.shaChainFromSeed(seed, 0xFFFFFFFFFFFFFFFFL - i)).toList - assert(result === expected) + assert(result == expected) var receiver = ShaChain.empty for (i <- 0 until 1000) { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/SphinxSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/SphinxSpec.scala index 637983a906..b8a9aeb54a 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/SphinxSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/SphinxSpec.scala @@ -93,7 +93,7 @@ class SphinxSpec extends AnyFunSuite { ) for ((expected, payload) <- testCases) { - assert(peekPayloadLength(payload) === expected) + assert(peekPayloadLength(payload) == expected) } } @@ -110,7 +110,7 @@ class SphinxSpec extends AnyFunSuite { ) for ((expected, packet) <- testCases) { - assert(packet.isLastPacket === expected) + assert(packet.isLastPacket == expected) } } @@ -129,7 +129,7 @@ class SphinxSpec extends AnyFunSuite { for ((packet, expected) <- badOnions zip expected) { val Left(onionErr) = peel(privKeys.head, associatedData, packet) - assert(onionErr === expected) + assert(onionErr == expected) } } @@ -244,22 +244,22 @@ class SphinxSpec extends AnyFunSuite { val expected = DecryptedFailurePacket(publicKeys.head, InvalidOnionKey(ByteVector32.One)) val packet1 = FailurePacket.create(sharedSecrets.head, expected.failureMessage) - assert(packet1.length === FailurePacket.PacketLength) + assert(packet1.length == FailurePacket.PacketLength) val Success(decrypted1) = FailurePacket.decrypt(packet1, Seq(0).map(i => (sharedSecrets(i), publicKeys(i)))) - assert(decrypted1 === expected) + assert(decrypted1 == expected) val packet2 = FailurePacket.wrap(packet1, sharedSecrets(1)) - assert(packet2.length === FailurePacket.PacketLength) + assert(packet2.length == FailurePacket.PacketLength) val Success(decrypted2) = FailurePacket.decrypt(packet2, Seq(1, 0).map(i => (sharedSecrets(i), publicKeys(i)))) - assert(decrypted2 === expected) + assert(decrypted2 == expected) val packet3 = FailurePacket.wrap(packet2, sharedSecrets(2)) - assert(packet3.length === FailurePacket.PacketLength) + assert(packet3.length == FailurePacket.PacketLength) val Success(decrypted3) = FailurePacket.decrypt(packet3, Seq(2, 1, 0).map(i => (sharedSecrets(i), publicKeys(i)))) - assert(decrypted3 === expected) + assert(decrypted3 == expected) } test("decrypt invalid failure message") { @@ -304,24 +304,24 @@ class SphinxSpec extends AnyFunSuite { // node #4 want to reply with an error message val error = FailurePacket.create(sharedSecret4, TemporaryNodeFailure) - assert(error === hex"a5e6bd0c74cb347f10cce367f949098f2457d14c046fd8a22cb96efb30b0fdcda8cb9168b50f2fd45edd73c1b0c8b33002df376801ff58aaa94000bf8a86f92620f343baef38a580102395ae3abf9128d1047a0736ff9b83d456740ebbb4aeb3aa9737f18fb4afb4aa074fb26c4d702f42968888550a3bded8c05247e045b866baef0499f079fdaeef6538f31d44deafffdfd3afa2fb4ca9082b8f1c465371a9894dd8c243fb4847e004f5256b3e90e2edde4c9fb3082ddfe4d1e734cacd96ef0706bf63c9984e22dc98851bcccd1c3494351feb458c9c6af41c0044bea3c47552b1d992ae542b17a2d0bba1a096c78d169034ecb55b6e3a7263c26017f033031228833c1daefc0dedb8cf7c3e37c9c37ebfe42f3225c326e8bcfd338804c145b16e34e4") + assert(error == hex"a5e6bd0c74cb347f10cce367f949098f2457d14c046fd8a22cb96efb30b0fdcda8cb9168b50f2fd45edd73c1b0c8b33002df376801ff58aaa94000bf8a86f92620f343baef38a580102395ae3abf9128d1047a0736ff9b83d456740ebbb4aeb3aa9737f18fb4afb4aa074fb26c4d702f42968888550a3bded8c05247e045b866baef0499f079fdaeef6538f31d44deafffdfd3afa2fb4ca9082b8f1c465371a9894dd8c243fb4847e004f5256b3e90e2edde4c9fb3082ddfe4d1e734cacd96ef0706bf63c9984e22dc98851bcccd1c3494351feb458c9c6af41c0044bea3c47552b1d992ae542b17a2d0bba1a096c78d169034ecb55b6e3a7263c26017f033031228833c1daefc0dedb8cf7c3e37c9c37ebfe42f3225c326e8bcfd338804c145b16e34e4") // error sent back to 3, 2, 1 and 0 val error1 = FailurePacket.wrap(error, sharedSecret3) - assert(error1 === hex"c49a1ce81680f78f5f2000cda36268de34a3f0a0662f55b4e837c83a8773c22aa081bab1616a0011585323930fa5b9fae0c85770a2279ff59ec427ad1bbff9001c0cd1497004bd2a0f68b50704cf6d6a4bf3c8b6a0833399a24b3456961ba00736785112594f65b6b2d44d9f5ea4e49b5e1ec2af978cbe31c67114440ac51a62081df0ed46d4a3df295da0b0fe25c0115019f03f15ec86fabb4c852f83449e812f141a9395b3f70b766ebbd4ec2fae2b6955bd8f32684c15abfe8fd3a6261e52650e8807a92158d9f1463261a925e4bfba44bd20b166d532f0017185c3a6ac7957adefe45559e3072c8dc35abeba835a8cb01a71a15c736911126f27d46a36168ca5ef7dccd4e2886212602b181463e0dd30185c96348f9743a02aca8ec27c0b90dca270") + assert(error1 == hex"c49a1ce81680f78f5f2000cda36268de34a3f0a0662f55b4e837c83a8773c22aa081bab1616a0011585323930fa5b9fae0c85770a2279ff59ec427ad1bbff9001c0cd1497004bd2a0f68b50704cf6d6a4bf3c8b6a0833399a24b3456961ba00736785112594f65b6b2d44d9f5ea4e49b5e1ec2af978cbe31c67114440ac51a62081df0ed46d4a3df295da0b0fe25c0115019f03f15ec86fabb4c852f83449e812f141a9395b3f70b766ebbd4ec2fae2b6955bd8f32684c15abfe8fd3a6261e52650e8807a92158d9f1463261a925e4bfba44bd20b166d532f0017185c3a6ac7957adefe45559e3072c8dc35abeba835a8cb01a71a15c736911126f27d46a36168ca5ef7dccd4e2886212602b181463e0dd30185c96348f9743a02aca8ec27c0b90dca270") val error2 = FailurePacket.wrap(error1, sharedSecret2) - assert(error2 === hex"a5d3e8634cfe78b2307d87c6d90be6fe7855b4f2cc9b1dfb19e92e4b79103f61ff9ac25f412ddfb7466e74f81b3e545563cdd8f5524dae873de61d7bdfccd496af2584930d2b566b4f8d3881f8c043df92224f38cf094cfc09d92655989531524593ec6d6caec1863bdfaa79229b5020acc034cd6deeea1021c50586947b9b8e6faa83b81fbfa6133c0af5d6b07c017f7158fa94f0d206baf12dda6b68f785b773b360fd0497e16cc402d779c8d48d0fa6315536ef0660f3f4e1865f5b38ea49c7da4fd959de4e83ff3ab686f059a45c65ba2af4a6a79166aa0f496bf04d06987b6d2ea205bdb0d347718b9aeff5b61dfff344993a275b79717cd815b6ad4c0beb568c4ac9c36ff1c315ec1119a1993c4b61e6eaa0375e0aaf738ac691abd3263bf937e3") + assert(error2 == hex"a5d3e8634cfe78b2307d87c6d90be6fe7855b4f2cc9b1dfb19e92e4b79103f61ff9ac25f412ddfb7466e74f81b3e545563cdd8f5524dae873de61d7bdfccd496af2584930d2b566b4f8d3881f8c043df92224f38cf094cfc09d92655989531524593ec6d6caec1863bdfaa79229b5020acc034cd6deeea1021c50586947b9b8e6faa83b81fbfa6133c0af5d6b07c017f7158fa94f0d206baf12dda6b68f785b773b360fd0497e16cc402d779c8d48d0fa6315536ef0660f3f4e1865f5b38ea49c7da4fd959de4e83ff3ab686f059a45c65ba2af4a6a79166aa0f496bf04d06987b6d2ea205bdb0d347718b9aeff5b61dfff344993a275b79717cd815b6ad4c0beb568c4ac9c36ff1c315ec1119a1993c4b61e6eaa0375e0aaf738ac691abd3263bf937e3") val error3 = FailurePacket.wrap(error2, sharedSecret1) - assert(error3 === hex"aac3200c4968f56b21f53e5e374e3a2383ad2b1b6501bbcc45abc31e59b26881b7dfadbb56ec8dae8857add94e6702fb4c3a4de22e2e669e1ed926b04447fc73034bb730f4932acd62727b75348a648a1128744657ca6a4e713b9b646c3ca66cac02cdab44dd3439890ef3aaf61708714f7375349b8da541b2548d452d84de7084bb95b3ac2345201d624d31f4d52078aa0fa05a88b4e20202bd2b86ac5b52919ea305a8949de95e935eed0319cf3cf19ebea61d76ba92532497fcdc9411d06bcd4275094d0a4a3c5d3a945e43305a5a9256e333e1f64dbca5fcd4e03a39b9012d197506e06f29339dfee3331995b21615337ae060233d39befea925cc262873e0530408e6990f1cbd233a150ef7b004ff6166c70c68d9f8c853c1abca640b8660db2921") + assert(error3 == hex"aac3200c4968f56b21f53e5e374e3a2383ad2b1b6501bbcc45abc31e59b26881b7dfadbb56ec8dae8857add94e6702fb4c3a4de22e2e669e1ed926b04447fc73034bb730f4932acd62727b75348a648a1128744657ca6a4e713b9b646c3ca66cac02cdab44dd3439890ef3aaf61708714f7375349b8da541b2548d452d84de7084bb95b3ac2345201d624d31f4d52078aa0fa05a88b4e20202bd2b86ac5b52919ea305a8949de95e935eed0319cf3cf19ebea61d76ba92532497fcdc9411d06bcd4275094d0a4a3c5d3a945e43305a5a9256e333e1f64dbca5fcd4e03a39b9012d197506e06f29339dfee3331995b21615337ae060233d39befea925cc262873e0530408e6990f1cbd233a150ef7b004ff6166c70c68d9f8c853c1abca640b8660db2921") val error4 = FailurePacket.wrap(error3, sharedSecret0) - assert(error4 === hex"9c5add3963fc7f6ed7f148623c84134b5647e1306419dbe2174e523fa9e2fbed3a06a19f899145610741c83ad40b7712aefaddec8c6baf7325d92ea4ca4d1df8bce517f7e54554608bf2bd8071a4f52a7a2f7ffbb1413edad81eeea5785aa9d990f2865dc23b4bc3c301a94eec4eabebca66be5cf638f693ec256aec514620cc28ee4a94bd9565bc4d4962b9d3641d4278fb319ed2b84de5b665f307a2db0f7fbb757366067d88c50f7e829138fde4f78d39b5b5802f1b92a8a820865af5cc79f9f30bc3f461c66af95d13e5e1f0381c184572a91dee1c849048a647a1158cf884064deddbf1b0b88dfe2f791428d0ba0f6fb2f04e14081f69165ae66d9297c118f0907705c9c4954a199bae0bb96fad763d690e7daa6cfda59ba7f2c8d11448b604d12d") + assert(error4 == hex"9c5add3963fc7f6ed7f148623c84134b5647e1306419dbe2174e523fa9e2fbed3a06a19f899145610741c83ad40b7712aefaddec8c6baf7325d92ea4ca4d1df8bce517f7e54554608bf2bd8071a4f52a7a2f7ffbb1413edad81eeea5785aa9d990f2865dc23b4bc3c301a94eec4eabebca66be5cf638f693ec256aec514620cc28ee4a94bd9565bc4d4962b9d3641d4278fb319ed2b84de5b665f307a2db0f7fbb757366067d88c50f7e829138fde4f78d39b5b5802f1b92a8a820865af5cc79f9f30bc3f461c66af95d13e5e1f0381c184572a91dee1c849048a647a1158cf884064deddbf1b0b88dfe2f791428d0ba0f6fb2f04e14081f69165ae66d9297c118f0907705c9c4954a199bae0bb96fad763d690e7daa6cfda59ba7f2c8d11448b604d12d") // origin parses error packet and can see that it comes from node #4 val Success(DecryptedFailurePacket(pubkey, failure)) = FailurePacket.decrypt(error4, sharedSecrets) - assert(pubkey === publicKeys(4)) - assert(failure === TemporaryNodeFailure) + assert(pubkey == publicKeys(4)) + assert(failure == TemporaryNodeFailure) } } @@ -335,7 +335,7 @@ class SphinxSpec extends AnyFunSuite { for (error <- errors) { val wrapped = FailurePacket.wrap(error, sharedSecret) - assert(wrapped.length === FailurePacket.PacketLength) + assert(wrapped.length == FailurePacket.PacketLength) } } @@ -367,34 +367,34 @@ class SphinxSpec extends AnyFunSuite { // origin parses error packet and can see that it comes from node #2 val Success(DecryptedFailurePacket(pubkey, failure)) = FailurePacket.decrypt(error2, sharedSecrets) - assert(pubkey === publicKeys(2)) - assert(failure === InvalidRealm) + assert(pubkey == publicKeys(2)) + assert(failure == InvalidRealm) } } test("create blinded route (reference test vector)") { val sessionKey = PrivateKey(hex"0101010101010101010101010101010101010101010101010101010101010101") val blindedRoute = RouteBlinding.create(sessionKey, publicKeys, routeBlindingPayloads) - assert(blindedRoute.introductionNode.publicKey === publicKeys(0)) - assert(blindedRoute.introductionNodeId === publicKeys(0)) - assert(blindedRoute.introductionNode.blindedPublicKey === PublicKey(hex"02ec68ed555f5d18b12fe0e2208563c3566032967cf11dc29b20c345449f9a50a2")) - assert(blindedRoute.introductionNode.blindingEphemeralKey === PublicKey(hex"031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f")) - assert(blindedRoute.introductionNode.encryptedPayload === hex"af4fbf67bd52520bdfab6a88cd4e7f22ffad08d8b153b17ff303f93fdb4712") - assert(blindedRoute.blindedNodeIds === Seq( + assert(blindedRoute.introductionNode.publicKey == publicKeys(0)) + assert(blindedRoute.introductionNodeId == publicKeys(0)) + assert(blindedRoute.introductionNode.blindedPublicKey == PublicKey(hex"02ec68ed555f5d18b12fe0e2208563c3566032967cf11dc29b20c345449f9a50a2")) + assert(blindedRoute.introductionNode.blindingEphemeralKey == PublicKey(hex"031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f")) + assert(blindedRoute.introductionNode.encryptedPayload == hex"af4fbf67bd52520bdfab6a88cd4e7f22ffad08d8b153b17ff303f93fdb4712") + assert(blindedRoute.blindedNodeIds == Seq( PublicKey(hex"02ec68ed555f5d18b12fe0e2208563c3566032967cf11dc29b20c345449f9a50a2"), PublicKey(hex"022b09d77fb3374ee3ed9d2153e15e9962944ad1690327cbb0a9acb7d90f168763"), PublicKey(hex"03d9f889364dc5a173460a2a6cc565b4ca78931792115dd6ef82c0e18ced837372"), PublicKey(hex"03bfddd2253b42fe12edd37f9071a3883830ed61a4bc347eeac63421629cf032b5"), PublicKey(hex"03a8588bc4a0a2f0d2fb8d5c0f8d062fb4d78bfba24a85d0ddeb4fd35dd3b34110"), )) - assert(blindedRoute.subsequentNodes.map(_.blindedPublicKey) === Seq( + assert(blindedRoute.subsequentNodes.map(_.blindedPublicKey) == Seq( PublicKey(hex"022b09d77fb3374ee3ed9d2153e15e9962944ad1690327cbb0a9acb7d90f168763"), PublicKey(hex"03d9f889364dc5a173460a2a6cc565b4ca78931792115dd6ef82c0e18ced837372"), PublicKey(hex"03bfddd2253b42fe12edd37f9071a3883830ed61a4bc347eeac63421629cf032b5"), PublicKey(hex"03a8588bc4a0a2f0d2fb8d5c0f8d062fb4d78bfba24a85d0ddeb4fd35dd3b34110"), )) - assert(blindedRoute.encryptedPayloads === blindedRoute.introductionNode.encryptedPayload +: blindedRoute.subsequentNodes.map(_.encryptedPayload)) - assert(blindedRoute.subsequentNodes.map(_.encryptedPayload) === Seq( + assert(blindedRoute.encryptedPayloads == blindedRoute.introductionNode.encryptedPayload +: blindedRoute.subsequentNodes.map(_.encryptedPayload)) + assert(blindedRoute.subsequentNodes.map(_.encryptedPayload) == Seq( hex"146c9694ead7de2a54fc43e8bb927bfc377dda7ed5a2e36b327b739e368aa602e43e07e14bfb81d66e1e295f848b6f15ee6483005abb830f4ef08a9da6", hex"8ad7d5d448f15208417a1840f82274101b3c254c24b1b49fd676fd0c4293c9aa66ed51da52579e934a869f016f213044d1b13b63bf586e9c9832106b59", hex"52a45a884542d180e76fe84fc13e71a01f65d943ff89aed29b94644a91b037b9143cfda8f1ff25ba61c37108a5ae57d9ddc5ab688ee8b2f9f6bd94522c", @@ -403,31 +403,31 @@ class SphinxSpec extends AnyFunSuite { // The introduction point can decrypt its encrypted payload and obtain the next ephemeral public key. val Success((payload0, ephKey1)) = RouteBlinding.decryptPayload(privKeys(0), blindedRoute.introductionNode.blindingEphemeralKey, blindedRoute.encryptedPayloads(0)) - assert(payload0 === routeBlindingPayloads(0)) - assert(ephKey1 === PublicKey(hex"035cb4c003d58e16cc9207270b3596c2be3309eca64c36b208c946bbb599bfcad0")) + assert(payload0 == routeBlindingPayloads(0)) + assert(ephKey1 == PublicKey(hex"035cb4c003d58e16cc9207270b3596c2be3309eca64c36b208c946bbb599bfcad0")) // The next node can derive the private key used to unwrap the onion and decrypt its encrypted payload. - assert(RouteBlinding.derivePrivateKey(privKeys(1), ephKey1).publicKey === blindedRoute.blindedNodeIds(1)) + assert(RouteBlinding.derivePrivateKey(privKeys(1), ephKey1).publicKey == blindedRoute.blindedNodeIds(1)) val Success((payload1, ephKey2)) = RouteBlinding.decryptPayload(privKeys(1), ephKey1, blindedRoute.encryptedPayloads(1)) - assert(payload1 === routeBlindingPayloads(1)) - assert(ephKey2 === PublicKey(hex"02e105bc01a7af07074a1b0b1d9a112a1d89c6cd87cc4e2b6ba3a824731d9508bd")) + assert(payload1 == routeBlindingPayloads(1)) + assert(ephKey2 == PublicKey(hex"02e105bc01a7af07074a1b0b1d9a112a1d89c6cd87cc4e2b6ba3a824731d9508bd")) // The next node can derive the private key used to unwrap the onion and decrypt its encrypted payload. - assert(RouteBlinding.derivePrivateKey(privKeys(2), ephKey2).publicKey === blindedRoute.blindedNodeIds(2)) + assert(RouteBlinding.derivePrivateKey(privKeys(2), ephKey2).publicKey == blindedRoute.blindedNodeIds(2)) val Success((payload2, ephKey3)) = RouteBlinding.decryptPayload(privKeys(2), ephKey2, blindedRoute.encryptedPayloads(2)) - assert(payload2 === routeBlindingPayloads(2)) - assert(ephKey3 === PublicKey(hex"0349164db5398925ef234002e62d2834da115b8eafc73436fab98ed12266e797cc")) + assert(payload2 == routeBlindingPayloads(2)) + assert(ephKey3 == PublicKey(hex"0349164db5398925ef234002e62d2834da115b8eafc73436fab98ed12266e797cc")) // The next node can derive the private key used to unwrap the onion and decrypt its encrypted payload. - assert(RouteBlinding.derivePrivateKey(privKeys(3), ephKey3).publicKey === blindedRoute.blindedNodeIds(3)) + assert(RouteBlinding.derivePrivateKey(privKeys(3), ephKey3).publicKey == blindedRoute.blindedNodeIds(3)) val Success((payload3, ephKey4)) = RouteBlinding.decryptPayload(privKeys(3), ephKey3, blindedRoute.encryptedPayloads(3)) - assert(payload3 === routeBlindingPayloads(3)) - assert(ephKey4 === PublicKey(hex"020a6d1951916adcac22125063f62c35b3686f36e5db2f77073f3d35b19c7a118a")) + assert(payload3 == routeBlindingPayloads(3)) + assert(ephKey4 == PublicKey(hex"020a6d1951916adcac22125063f62c35b3686f36e5db2f77073f3d35b19c7a118a")) // The last node can derive the private key used to unwrap the onion and decrypt its encrypted payload. - assert(RouteBlinding.derivePrivateKey(privKeys(4), ephKey4).publicKey === blindedRoute.blindedNodeIds(4)) + assert(RouteBlinding.derivePrivateKey(privKeys(4), ephKey4).publicKey == blindedRoute.blindedNodeIds(4)) val Success((payload4, _)) = RouteBlinding.decryptPayload(privKeys(4), ephKey4, blindedRoute.encryptedPayloads(4)) - assert(payload4 === routeBlindingPayloads(4)) + assert(payload4 == routeBlindingPayloads(4)) } test("concatenate blinded routes (reference test vector)") { @@ -440,7 +440,7 @@ class SphinxSpec extends AnyFunSuite { hex"010f000000000000000000000000000000 061000112233445566778899aabbccddeeff" ) val blindedRoute = RouteBlinding.create(sessionKey, publicKeys.drop(2), payloads) - assert(blindedRoute.blindingKey === PublicKey(hex"031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f")) + assert(blindedRoute.blindingKey == PublicKey(hex"031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f")) (blindedRoute.blindingKey, blindedRoute, payloads) } // The sender also wants to use route blinding to reach the introduction point. @@ -454,15 +454,15 @@ class SphinxSpec extends AnyFunSuite { (RouteBlinding.create(sessionKey, publicKeys.take(2), payloads), payloads) } val blindedRoute = BlindedRoute(publicKeys(0), blindedRouteStart.blindingKey, blindedRouteStart.blindedNodes ++ blindedRouteEnd.blindedNodes) - assert(blindedRoute.blindingKey === PublicKey(hex"024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d0766")) - assert(blindedRoute.blindedNodeIds === Seq( + assert(blindedRoute.blindingKey == PublicKey(hex"024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d0766")) + assert(blindedRoute.blindedNodeIds == Seq( PublicKey(hex"0303176d13958a8a59d59517a6223e12cf291ba5f65c8011efcdca0a52c3850abc"), PublicKey(hex"03adbdd3c0fb69641e96de2d5ac923ffc0910d3ed4dfe2314609fae61a71df4da2"), PublicKey(hex"021026e6369e42b7f6d723c0c56a3e0b4d67111f07685bd03e9fa6d93ac6bb6dbe"), PublicKey(hex"02ba3db3fe7f1ed28c4d82f28cf358373cbf3241a16aba265b1b6fb26f094c0c7f"), PublicKey(hex"0379d4ca14cb19e2f7bcb217d36267e3d03b027bc4228923967f5b2e32cbb763c1"), )) - assert(blindedRoute.encryptedPayloads === Seq( + assert(blindedRoute.encryptedPayloads == Seq( hex"31da0d438752ed0f19ccd970a386ead7155fd187becd4e1770d561dffdb03d3568dac746dde98725f146582cb040207e8b6c070e28d707564a4dd9fb53f9274ad69d09add393b509a2fa42df5055d7c8aeda5881d5aa", hex"d9dfa92f898dc8e37b73c944aa4205f225337b2edde67623e775c79e2bcf395dc205004aa07fdc65712afa5c2687aff9bb3d5e6af7c89cc94f23f962a27844ce7629773f9413ebcf131dbc35818410df207f29b013b0", hex"30015dcdcbce70bdcd0125be8ccd541b101d95bcb049ccfc737f91c98cc139cb6f16354ec5a38e77eca769c2245ac4467524d6", @@ -472,35 +472,35 @@ class SphinxSpec extends AnyFunSuite { // The introduction point can decrypt its encrypted payload and obtain the next ephemeral public key. val Success((payload0, ephKey1)) = RouteBlinding.decryptPayload(privKeys(0), blindedRoute.blindingKey, blindedRoute.encryptedPayloads(0)) - assert(payload0 === payloadsStart(0)) - assert(ephKey1 === PublicKey(hex"02be4b436dbc6cfa43d7d5652bc630ffdaf0dac93e6682db7950828506055ad1a7")) + assert(payload0 == payloadsStart(0)) + assert(ephKey1 == PublicKey(hex"02be4b436dbc6cfa43d7d5652bc630ffdaf0dac93e6682db7950828506055ad1a7")) // The next node can derive the private key used to unwrap the onion and decrypt its encrypted payload. - assert(RouteBlinding.derivePrivateKey(privKeys(1), ephKey1).publicKey === blindedRoute.blindedNodeIds(1)) + assert(RouteBlinding.derivePrivateKey(privKeys(1), ephKey1).publicKey == blindedRoute.blindedNodeIds(1)) val Success((payload1, ephKey2)) = RouteBlinding.decryptPayload(privKeys(1), ephKey1, blindedRoute.encryptedPayloads(1)) - assert(payload1 === payloadsStart(1)) - assert(ephKey2 === PublicKey(hex"03fb82254d740754efddc3318674f4e26cefcb8dec42a3910c08c64d19f25e50b7")) + assert(payload1 == payloadsStart(1)) + assert(ephKey2 == PublicKey(hex"03fb82254d740754efddc3318674f4e26cefcb8dec42a3910c08c64d19f25e50b7")) // NB: this node finds a blinding override and will transmit that instead of ephKey2 to the next node. assert(payload1.containsSlice(blindingOverride.value)) // The next node must be given the blinding override to derive the private key used to unwrap the onion and decrypt its encrypted payload. assert(RouteBlinding.decryptPayload(privKeys(2), ephKey2, blindedRoute.encryptedPayloads(2)).isFailure) - assert(RouteBlinding.derivePrivateKey(privKeys(2), blindingOverride).publicKey === blindedRoute.blindedNodeIds(2)) + assert(RouteBlinding.derivePrivateKey(privKeys(2), blindingOverride).publicKey == blindedRoute.blindedNodeIds(2)) val Success((payload2, ephKey3)) = RouteBlinding.decryptPayload(privKeys(2), blindingOverride, blindedRoute.encryptedPayloads(2)) - assert(payload2 === payloadsEnd(0)) - assert(ephKey3 === PublicKey(hex"03932f4ab7605e8c046b5677becd4d61fdfdc8b9d10f1e9c3080ced0d64fd76931")) + assert(payload2 == payloadsEnd(0)) + assert(ephKey3 == PublicKey(hex"03932f4ab7605e8c046b5677becd4d61fdfdc8b9d10f1e9c3080ced0d64fd76931")) // The next node can derive the private key used to unwrap the onion and decrypt its encrypted payload. - assert(RouteBlinding.derivePrivateKey(privKeys(3), ephKey3).publicKey === blindedRoute.blindedNodeIds(3)) + assert(RouteBlinding.derivePrivateKey(privKeys(3), ephKey3).publicKey == blindedRoute.blindedNodeIds(3)) val Success((payload3, ephKey4)) = RouteBlinding.decryptPayload(privKeys(3), ephKey3, blindedRoute.encryptedPayloads(3)) - assert(payload3 === payloadsEnd(1)) - assert(ephKey4 === PublicKey(hex"037bceb365470d24f8204c622e1b7959c6beeb774c634640de6c8401079159fc58")) + assert(payload3 == payloadsEnd(1)) + assert(ephKey4 == PublicKey(hex"037bceb365470d24f8204c622e1b7959c6beeb774c634640de6c8401079159fc58")) // The last node can derive the private key used to unwrap the onion and decrypt its encrypted payload. - assert(RouteBlinding.derivePrivateKey(privKeys(4), ephKey4).publicKey === blindedRoute.blindedNodeIds(4)) + assert(RouteBlinding.derivePrivateKey(privKeys(4), ephKey4).publicKey == blindedRoute.blindedNodeIds(4)) val Success((payload4, ephKey5)) = RouteBlinding.decryptPayload(privKeys(4), ephKey4, blindedRoute.encryptedPayloads(4)) - assert(payload4 === payloadsEnd(2)) - assert(ephKey5 === PublicKey(hex"0339ddfa85a2155fb27e94742885fad85696e54920aa148cb86e00bcb8ee346bd4")) + assert(payload4 == payloadsEnd(2)) + assert(ephKey5 == PublicKey(hex"0339ddfa85a2155fb27e94742885fad85696e54920aa148cb86e00bcb8ee346bd4")) } test("invalid blinded route") { @@ -523,7 +523,7 @@ class SphinxSpec extends AnyFunSuite { // The sender obtains this information (e.g. from a Bolt11 invoice) and prepends two normal hops to reach the introduction node. val nodeIds = publicKeys.take(2) ++ Seq(blindedRoute.introductionNodeId) ++ blindedRoute.subsequentNodes.map(_.blindedPublicKey) - assert(blindedRoute.encryptedPayloads === Seq( + assert(blindedRoute.encryptedPayloads == Seq( hex"36285ee1c0b289eeedf05c9ab66a7b669d92bd3729082c1c42e443d2775b3be7de74b1c64e0cebd0e3a8cddeff2e9acb1ddb62cbb73166723cae905938", hex"14cd98e3f4f29cc7af8624250c5bd14fb5a69be8235748909e754ef43b09b1b424b1bba062d801f8648f28fb1101b9a56dcb1f69d5e1ba7fe584f6a6be", hex"fe7862b65ac8e1c2a319ba558513d97dc237132b22ce4f7439983545e37164d792dc6925a3c7cde855ac824871bd455f2859298456da3ade87d884080d", @@ -552,11 +552,11 @@ class SphinxSpec extends AnyFunSuite { // However it contains a blinding point and encrypted data, which it can decrypt to discover the next node. val Right(DecryptedPacket(payload2, nextPacket2, sharedSecret2)) = peel(privKeys(2), associatedData, nextPacket1) val tlvs2 = PaymentOnionCodecs.tlvPerHopPayloadCodec.decode(payload2.bits).require.value - assert(tlvs2.get[OnionPaymentPayloadTlv.BlindingPoint].map(_.publicKey) === Some(blindingEphemeralKey0)) + assert(tlvs2.get[OnionPaymentPayloadTlv.BlindingPoint].map(_.publicKey) == Some(blindingEphemeralKey0)) assert(tlvs2.get[OnionPaymentPayloadTlv.EncryptedRecipientData].nonEmpty) val Success((recipientTlvs2, blindingEphemeralKey1)) = RouteBlindingEncryptedDataCodecs.decode(privKeys(2), blindingEphemeralKey0, tlvs2.get[OnionPaymentPayloadTlv.EncryptedRecipientData].get.data) - assert(recipientTlvs2.get[RouteBlindingEncryptedDataTlv.OutgoingChannelId].map(_.shortChannelId) === Some(ShortChannelId(1105))) - assert(recipientTlvs2.get[RouteBlindingEncryptedDataTlv.OutgoingNodeId].map(_.nodeId) === Some(publicKeys(3))) + assert(recipientTlvs2.get[RouteBlindingEncryptedDataTlv.OutgoingChannelId].map(_.shortChannelId) == Some(ShortChannelId(1105))) + assert(recipientTlvs2.get[RouteBlindingEncryptedDataTlv.OutgoingNodeId].map(_.nodeId) == Some(publicKeys(3))) // The fourth hop is a blinded hop. // It receives the blinding key from the previous node (e.g. in a tlv field in update_add_htlc) which it can use to @@ -567,7 +567,7 @@ class SphinxSpec extends AnyFunSuite { val tlvs3 = PaymentOnionCodecs.tlvPerHopPayloadCodec.decode(payload3.bits).require.value assert(tlvs3.get[OnionPaymentPayloadTlv.EncryptedRecipientData].nonEmpty) val Success((recipientTlvs3, blindingEphemeralKey2)) = RouteBlindingEncryptedDataCodecs.decode(privKeys(3), blindingEphemeralKey1, tlvs3.get[OnionPaymentPayloadTlv.EncryptedRecipientData].get.data) - assert(recipientTlvs3.get[RouteBlindingEncryptedDataTlv.OutgoingNodeId].map(_.nodeId) === Some(publicKeys(4))) + assert(recipientTlvs3.get[RouteBlindingEncryptedDataTlv.OutgoingNodeId].map(_.nodeId) == Some(publicKeys(4))) // The fifth hop is the blinded recipient. // It receives the blinding key from the previous node (e.g. in a tlv field in update_add_htlc) which it can use to @@ -577,7 +577,7 @@ class SphinxSpec extends AnyFunSuite { val tlvs4 = PaymentOnionCodecs.tlvPerHopPayloadCodec.decode(payload4.bits).require.value assert(tlvs4.get[OnionPaymentPayloadTlv.EncryptedRecipientData].nonEmpty) val Success((recipientTlvs4, _)) = RouteBlindingEncryptedDataCodecs.decode(privKeys(4), blindingEphemeralKey2, tlvs4.get[OnionPaymentPayloadTlv.EncryptedRecipientData].get.data) - assert(recipientTlvs4.get[RouteBlindingEncryptedDataTlv.PathId].map(_.data) === associatedData.map(_.bytes)) + assert(recipientTlvs4.get[RouteBlindingEncryptedDataTlv.PathId].map(_.data) == associatedData.map(_.bytes)) assert(Seq(payload0, payload1, payload2, payload3, payload4) == payloads) assert(Seq(sharedSecret0, sharedSecret1, sharedSecret2, sharedSecret3, sharedSecret4) == sharedSecrets.map(_._1)) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/TransportHandlerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/TransportHandlerSpec.scala index 2e915fdd4a..bc7d35797c 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/TransportHandlerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/TransportHandlerSpec.scala @@ -187,12 +187,12 @@ class TransportHandlerSpec extends TestKitBaseClass with AnyFunSuiteLike with Be } val ciphertexts = loop(Encryptor(enc), 1002) - assert(ciphertexts(0) === hex"cf2b30ddf0cf3f80e7c35a6e6730b59fe802473180f396d88a8fb0db8cbcf25d2f214cf9ea1d95") - assert(ciphertexts(1) === hex"72887022101f0b6753e0c7de21657d35a4cb2a1f5cde2650528bbc8f837d0f0d7ad833b1a256a1") - assert(ciphertexts(500) === hex"178cb9d7387190fa34db9c2d50027d21793c9bc2d40b1e14dcf30ebeeeb220f48364f7a4c68bf8") - assert(ciphertexts(501) === hex"1b186c57d44eb6de4c057c49940d79bb838a145cb528d6e8fd26dbe50a60ca2c104b56b60e45bd") - assert(ciphertexts(1000) === hex"4a2f3cc3b5e78ddb83dcb426d9863d9d9a723b0337c89dd0b005d89f8d3c05c52b76b29b740f09") - assert(ciphertexts(1001) === hex"2ecd8c8a5629d0d02ab457a0fdd0f7b90a192cd46be5ecb6ca570bfc5e268338b1a16cf4ef2d36") + assert(ciphertexts(0) == hex"cf2b30ddf0cf3f80e7c35a6e6730b59fe802473180f396d88a8fb0db8cbcf25d2f214cf9ea1d95") + assert(ciphertexts(1) == hex"72887022101f0b6753e0c7de21657d35a4cb2a1f5cde2650528bbc8f837d0f0d7ad833b1a256a1") + assert(ciphertexts(500) == hex"178cb9d7387190fa34db9c2d50027d21793c9bc2d40b1e14dcf30ebeeeb220f48364f7a4c68bf8") + assert(ciphertexts(501) == hex"1b186c57d44eb6de4c057c49940d79bb838a145cb528d6e8fd26dbe50a60ca2c104b56b60e45bd") + assert(ciphertexts(1000) == hex"4a2f3cc3b5e78ddb83dcb426d9863d9d9a723b0337c89dd0b005d89f8d3c05c52b76b29b740f09") + assert(ciphertexts(1001) == hex"2ecd8c8a5629d0d02ab457a0fdd0f7b90a192cd46be5ecb6ca570bfc5e268338b1a16cf4ef2d36") } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/keymanager/LocalNodeKeyManagerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/keymanager/LocalNodeKeyManagerSpec.scala index d3277cff65..3b33f54809 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/crypto/keymanager/LocalNodeKeyManagerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/crypto/keymanager/LocalNodeKeyManagerSpec.scala @@ -69,7 +69,7 @@ class LocalNodeKeyManagerSpec extends AnyFunSuite { val (signature, recid) = testKeyManager.signDigest(digest) val recoveredPubkey = Crypto.recoverPublicKey(signature, digest, recid) - assert(recoveredPubkey === testKeyManager.nodeId) + assert(recoveredPubkey == testKeyManager.nodeId) assert(Crypto.verifySignature(digest, signature, testKeyManager.nodeId)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/AuditDbSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/AuditDbSpec.scala index 738242a9c7..b3316ab38e 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/AuditDbSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/AuditDbSpec.scala @@ -100,12 +100,12 @@ class AuditDbSpec extends AnyFunSuite { db.add(e11) db.add(e12) - assert(db.listSent(from = TimestampMilli(0L), to = TimestampMilli.now() + 15.minute).toSet === Set(e1, e5, e6)) - assert(db.listSent(from = TimestampMilli(100000L), to = TimestampMilli.now() + 1.minute).toList === List(e1)) - assert(db.listReceived(from = TimestampMilli(0L), to = TimestampMilli.now() + 1.minute).toList === List(e2)) - assert(db.listRelayed(from = TimestampMilli(0L), to = TimestampMilli.now() + 1.minute).toList === List(e3, e10, e11, e12)) - assert(db.listNetworkFees(from = TimestampMilli(0L), to = TimestampMilli.now() + 1.minute).size === 1) - assert(db.listNetworkFees(from = TimestampMilli(0L), to = TimestampMilli.now() + 1.minute).head.txType === "mutual") + assert(db.listSent(from = TimestampMilli(0L), to = TimestampMilli.now() + 15.minute).toSet == Set(e1, e5, e6)) + assert(db.listSent(from = TimestampMilli(100000L), to = TimestampMilli.now() + 1.minute).toList == List(e1)) + assert(db.listReceived(from = TimestampMilli(0L), to = TimestampMilli.now() + 1.minute).toList == List(e2)) + assert(db.listRelayed(from = TimestampMilli(0L), to = TimestampMilli.now() + 1.minute).toList == List(e3, e10, e11, e12)) + assert(db.listNetworkFees(from = TimestampMilli(0L), to = TimestampMilli.now() + 1.minute).size == 1) + assert(db.listNetworkFees(from = TimestampMilli(0L), to = TimestampMilli.now() + 1.minute).head.txType == "mutual") } } @@ -147,7 +147,7 @@ class AuditDbSpec extends AnyFunSuite { db.add(TransactionConfirmed(c4, n4, Transaction(0, Seq.empty, Seq(TxOut(2500 sat, hex"ffffff")), 0))) // doesn't match a published tx // NB: we only count a relay fee for the outgoing channel, no the incoming one. - assert(db.stats(0 unixms, TimestampMilli.now() + 1.milli).toSet === Set( + assert(db.stats(0 unixms, TimestampMilli.now() + 1.milli).toSet == Set( Stats(channelId = c1, direction = "IN", avgPaymentAmount = 0 sat, paymentCount = 0, relayFee = 0 sat, networkFee = 0 sat), Stats(channelId = c1, direction = "OUT", avgPaymentAmount = 42 sat, paymentCount = 3, relayFee = 4 sat, networkFee = 0 sat), Stats(channelId = c2, direction = "IN", avgPaymentAmount = 0 sat, paymentCount = 0, relayFee = 0 sat, networkFee = 500 sat), @@ -248,7 +248,7 @@ class AuditDbSpec extends AnyFunSuite { targetVersion = SqliteAuditDb.CURRENT_VERSION, postCheck = connection => { // existing rows in the 'sent' table will use id=00000000-0000-0000-0000-000000000000 as default - assert(dbs.audit.listSent(0 unixms, TimestampMilli.now() + 1.minute) === Seq(ps.copy(id = ZERO_UUID, parts = Seq(ps.parts.head.copy(id = ZERO_UUID))))) + assert(dbs.audit.listSent(0 unixms, TimestampMilli.now() + 1.minute) == Seq(ps.copy(id = ZERO_UUID, parts = Seq(ps.parts.head.copy(id = ZERO_UUID))))) val postMigrationDb = new SqliteAuditDb(connection) @@ -262,7 +262,7 @@ class AuditDbSpec extends AnyFunSuite { // the old record will have the UNKNOWN_UUID but the new ones will have their actual id val expected = Seq(ps.copy(id = ZERO_UUID, parts = Seq(ps.parts.head.copy(id = ZERO_UUID))), ps1) - assert(postMigrationDb.listSent(0 unixms, TimestampMilli.now() + 1.minute) === expected) + assert(postMigrationDb.listSent(0 unixms, TimestampMilli.now() + 1.minute) == expected) } ) } @@ -380,11 +380,11 @@ class AuditDbSpec extends AnyFunSuite { using(connection.createStatement()) { statement => assert(getVersion(statement, "audit").contains(SqliteAuditDb.CURRENT_VERSION)) } - assert(migratedDb.listSent(50 unixms, 150 unixms).toSet === Set( + assert(migratedDb.listSent(50 unixms, 150 unixms).toSet == Set( ps1.copy(id = pp1.id, recipientAmount = pp1.amount, parts = pp1 :: Nil), ps1.copy(id = pp2.id, recipientAmount = pp2.amount, parts = pp2 :: Nil) )) - assert(migratedDb.listRelayed(100 unixms, 120 unixms) === Seq(relayed1, relayed2)) + assert(migratedDb.listRelayed(100 unixms, 120 unixms) == Seq(relayed1, relayed2)) val postMigrationDb = new SqliteAuditDb(connection) using(connection.createStatement()) { statement => @@ -396,9 +396,9 @@ class AuditDbSpec extends AnyFunSuite { )) val relayed3 = TrampolinePaymentRelayed(randomBytes32(), Seq(PaymentRelayed.Part(450 msat, randomBytes32()), PaymentRelayed.Part(500 msat, randomBytes32())), Seq(PaymentRelayed.Part(800 msat, randomBytes32())), randomKey().publicKey, 700 msat, 150 unixms) postMigrationDb.add(ps2) - assert(postMigrationDb.listSent(155 unixms, 200 unixms) === Seq(ps2)) + assert(postMigrationDb.listSent(155 unixms, 200 unixms) == Seq(ps2)) postMigrationDb.add(relayed3) - assert(postMigrationDb.listRelayed(100 unixms, 160 unixms) === Seq(relayed1, relayed2, relayed3)) + assert(postMigrationDb.listRelayed(100 unixms, 160 unixms) == Seq(relayed1, relayed2, relayed3)) } ) } @@ -479,7 +479,7 @@ class AuditDbSpec extends AnyFunSuite { postCheck = connection => { val migratedDb = dbs.audit - assert(migratedDb.listRelayed(100 unixms, 120 unixms) === Seq(relayed1, relayed2)) + assert(migratedDb.listRelayed(100 unixms, 120 unixms) == Seq(relayed1, relayed2)) val postMigrationDb = new PgAuditDb()(dbs.datasource) using(connection.createStatement()) { statement => @@ -487,7 +487,7 @@ class AuditDbSpec extends AnyFunSuite { } val relayed3 = TrampolinePaymentRelayed(randomBytes32(), Seq(PaymentRelayed.Part(450 msat, randomBytes32()), PaymentRelayed.Part(500 msat, randomBytes32())), Seq(PaymentRelayed.Part(800 msat, randomBytes32())), randomKey().publicKey, 700 msat, 150 unixms) postMigrationDb.add(relayed3) - assert(postMigrationDb.listRelayed(100 unixms, 160 unixms) === Seq(relayed1, relayed2, relayed3)) + assert(postMigrationDb.listRelayed(100 unixms, 160 unixms) == Seq(relayed1, relayed2, relayed3)) } ) case dbs: TestSqliteDatabases => @@ -562,7 +562,7 @@ class AuditDbSpec extends AnyFunSuite { using(connection.createStatement()) { statement => assert(getVersion(statement, "audit").contains(SqliteAuditDb.CURRENT_VERSION)) } - assert(migratedDb.listRelayed(100 unixms, 120 unixms) === Seq(relayed1, relayed2)) + assert(migratedDb.listRelayed(100 unixms, 120 unixms) == Seq(relayed1, relayed2)) val postMigrationDb = new SqliteAuditDb(connection) using(connection.createStatement()) { statement => @@ -570,7 +570,7 @@ class AuditDbSpec extends AnyFunSuite { } val relayed3 = TrampolinePaymentRelayed(randomBytes32(), Seq(PaymentRelayed.Part(450 msat, randomBytes32()), PaymentRelayed.Part(500 msat, randomBytes32())), Seq(PaymentRelayed.Part(800 msat, randomBytes32())), randomKey().publicKey, 700 msat, 150 unixms) postMigrationDb.add(relayed3) - assert(postMigrationDb.listRelayed(100 unixms, 160 unixms) === Seq(relayed1, relayed2, relayed3)) + assert(postMigrationDb.listRelayed(100 unixms, 160 unixms) == Seq(relayed1, relayed2, relayed3)) } ) } @@ -640,7 +640,7 @@ class AuditDbSpec extends AnyFunSuite { postCheck = connection => { val migratedDb = dbs.audit using(connection.createStatement()) { statement => assert(getVersion(statement, "audit").contains(PgAuditDb.CURRENT_VERSION)) } - assert(migratedDb.listNetworkFees(0 unixms, 700 unixms) === networkFees) + assert(migratedDb.listNetworkFees(0 unixms, 700 unixms) == networkFees) } ) case dbs: TestSqliteDatabases => @@ -698,7 +698,7 @@ class AuditDbSpec extends AnyFunSuite { postCheck = connection => { val migratedDb = dbs.audit using(connection.createStatement()) { statement => assert(getVersion(statement, "audit").contains(SqliteAuditDb.CURRENT_VERSION)) } - assert(migratedDb.listNetworkFees(0 unixms, 700 unixms) === networkFees) + assert(migratedDb.listNetworkFees(0 unixms, 700 unixms) == networkFees) } ) } @@ -744,7 +744,7 @@ class AuditDbSpec extends AnyFunSuite { statement.executeUpdate() } - assert(db.listRelayed(0 unixms, 40 unixms) === Nil) + assert(db.listRelayed(0 unixms, 40 unixms) == Nil) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/ChannelsDbSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/ChannelsDbSpec.scala index 871adad0d6..5d4c5dede7 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/ChannelsDbSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/ChannelsDbSpec.scala @@ -70,16 +70,16 @@ class ChannelsDbSpec extends AnyFunSuite { intercept[SQLException](db.addHtlcInfo(channel1.channelId, commitNumber, paymentHash1, cltvExpiry1)) // no related channel - assert(db.listLocalChannels().toSet === Set.empty) + assert(db.listLocalChannels().toSet == Set.empty) db.addOrUpdateChannel(channel1) db.addOrUpdateChannel(channel1) - assert(db.listLocalChannels() === List(channel1)) + assert(db.listLocalChannels() == List(channel1)) db.addOrUpdateChannel(channel2a) - assert(db.listLocalChannels() === List(channel1, channel2a)) + assert(db.listLocalChannels() == List(channel1, channel2a)) assert(db.getChannel(channel1.channelId).contains(channel1)) assert(db.getChannel(channel2a.channelId).contains(channel2a)) db.addOrUpdateChannel(channel2b) - assert(db.listLocalChannels() === List(channel1, channel2b)) + assert(db.listLocalChannels() == List(channel1, channel2b)) assert(db.getChannel(channel2b.channelId).contains(channel2b)) assert(db.listHtlcInfos(channel1.channelId, commitNumber).toList == Nil) @@ -90,11 +90,11 @@ class ChannelsDbSpec extends AnyFunSuite { db.removeChannel(channel1.channelId) assert(db.getChannel(channel1.channelId).isEmpty) - assert(db.listLocalChannels() === List(channel2b)) + assert(db.listLocalChannels() == List(channel2b)) assert(db.listHtlcInfos(channel1.channelId, commitNumber).toList == Nil) db.removeChannel(channel2b.channelId) assert(db.getChannel(channel2b.channelId).isEmpty) - assert(db.listLocalChannels() === Nil) + assert(db.listLocalChannels() == Nil) } } @@ -195,11 +195,11 @@ class ChannelsDbSpec extends AnyFunSuite { using(sqlite.createStatement()) { statement => assert(getVersion(statement, "channels").contains(targetVersion)) } - assert(db.listLocalChannels().size === testCases.size) + assert(db.listLocalChannels().size == testCases.size) for (testCase <- testCases) { db.updateChannelMeta(testCase.channelId, ChannelEvent.EventType.Created) // this call must not fail for (commitmentNumber <- testCase.commitmentNumbers) { - assert(db.listHtlcInfos(testCase.channelId, commitmentNumber).size === testCase.commitmentNumbers.count(_ == commitmentNumber)) + assert(db.listHtlcInfos(testCase.channelId, commitmentNumber).size == testCase.commitmentNumbers.count(_ == commitmentNumber)) } } } @@ -207,11 +207,11 @@ class ChannelsDbSpec extends AnyFunSuite { test("migrate channel database v2 -> current") { def postCheck(channelsDb: ChannelsDb): Unit = { - assert(channelsDb.listLocalChannels().size === testCases.filterNot(_.isClosed).size) + assert(channelsDb.listLocalChannels().size == testCases.filterNot(_.isClosed).size) for (testCase <- testCases.filterNot(_.isClosed)) { channelsDb.updateChannelMeta(testCase.channelId, ChannelEvent.EventType.Created) // this call must not fail for (commitmentNumber <- testCase.commitmentNumbers) { - assert(channelsDb.listHtlcInfos(testCase.channelId, commitmentNumber).size === testCase.commitmentNumbers.count(_ == commitmentNumber)) + assert(channelsDb.listHtlcInfos(testCase.channelId, commitmentNumber).size == testCase.commitmentNumbers.count(_ == commitmentNumber)) } } } @@ -320,13 +320,13 @@ class ChannelsDbSpec extends AnyFunSuite { dbName = PgChannelsDb.DB_NAME, targetVersion = PgChannelsDb.CURRENT_VERSION, postCheck = connection => { - assert(dbs.channels.listLocalChannels().size === testCases.filterNot(_.isClosed).size) + assert(dbs.channels.listLocalChannels().size == testCases.filterNot(_.isClosed).size) testCases.foreach { testCase => - assert(getPgTimestamp(connection, testCase.channelId, "created_timestamp") === testCase.createdTimestamp) - assert(getPgTimestamp(connection, testCase.channelId, "last_payment_sent_timestamp") === testCase.lastPaymentSentTimestamp) - assert(getPgTimestamp(connection, testCase.channelId, "last_payment_received_timestamp") === testCase.lastPaymentReceivedTimestamp) - assert(getPgTimestamp(connection, testCase.channelId, "last_connected_timestamp") === testCase.lastConnectedTimestamp) - assert(getPgTimestamp(connection, testCase.channelId, "closed_timestamp") === testCase.closedTimestamp) + assert(getPgTimestamp(connection, testCase.channelId, "created_timestamp") == testCase.createdTimestamp) + assert(getPgTimestamp(connection, testCase.channelId, "last_payment_sent_timestamp") == testCase.lastPaymentSentTimestamp) + assert(getPgTimestamp(connection, testCase.channelId, "last_payment_received_timestamp") == testCase.lastPaymentReceivedTimestamp) + assert(getPgTimestamp(connection, testCase.channelId, "last_connected_timestamp") == testCase.lastConnectedTimestamp) + assert(getPgTimestamp(connection, testCase.channelId, "closed_timestamp") == testCase.closedTimestamp) } } ) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/DualDatabasesSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/DualDatabasesSpec.scala index a9ae922f23..a4b81d94ea 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/DualDatabasesSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/DualDatabasesSpec.scala @@ -25,7 +25,7 @@ class DualDatabasesSpec extends TestKitBaseClass with AnyFunSuiteLike { db.channels.addOrUpdateChannel(ChannelCodecsSpec.normal) assert(db.primary.channels.listLocalChannels().nonEmpty) - awaitCond(db.primary.channels.listLocalChannels() === db.secondary.channels.listLocalChannels()) + awaitCond(db.primary.channels.listLocalChannels() == db.secondary.channels.listLocalChannels()) } test("postgres primary") { @@ -33,7 +33,7 @@ class DualDatabasesSpec extends TestKitBaseClass with AnyFunSuiteLike { db.channels.addOrUpdateChannel(ChannelCodecsSpec.normal) assert(db.primary.channels.listLocalChannels().nonEmpty) - awaitCond(db.primary.channels.listLocalChannels() === db.secondary.channels.listLocalChannels()) + awaitCond(db.primary.channels.listLocalChannels() == db.secondary.channels.listLocalChannels()) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/NetworkDbSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/NetworkDbSpec.scala index bdc551e04b..a1e39298f9 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/NetworkDbSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/NetworkDbSpec.scala @@ -60,17 +60,17 @@ class NetworkDbSpec extends AnyFunSuite { val node_3 = Announcements.makeNodeAnnouncement(randomKey(), "node-charlie", Color(100.toByte, 200.toByte, 300.toByte), NodeAddress.fromParts("192.168.1.42", 42000).get :: Nil, Features(VariableLengthOnion -> Optional)) val node_4 = Announcements.makeNodeAnnouncement(randomKey(), "node-charlie", Color(100.toByte, 200.toByte, 300.toByte), Tor2("aaaqeayeaudaocaj", 42000) :: Nil, Features.empty) - assert(db.listNodes().toSet === Set.empty) + assert(db.listNodes().toSet == Set.empty) db.addNode(node_1) db.addNode(node_1) // duplicate is ignored - assert(db.getNode(node_1.nodeId) === Some(node_1)) - assert(db.listNodes().size === 1) + assert(db.getNode(node_1.nodeId) == Some(node_1)) + assert(db.listNodes().size == 1) db.addNode(node_2) db.addNode(node_3) db.addNode(node_4) - assert(db.listNodes().toSet === Set(node_1, node_2, node_3, node_4)) + assert(db.listNodes().toSet == Set(node_1, node_2, node_3, node_4)) db.removeNode(node_2.nodeId) - assert(db.listNodes().toSet === Set(node_1, node_3, node_4)) + assert(db.listNodes().toSet == Set(node_1, node_3, node_4)) db.updateNode(node_1) assert(node_4.addresses == List(Tor2("aaaqeayeaudaocaj", 42000))) @@ -84,7 +84,7 @@ class NetworkDbSpec extends AnyFunSuite { val c = Announcements.makeChannelAnnouncement(Block.RegtestGenesisBlock.hash, ShortChannelId(42), randomKey().publicKey, randomKey().publicKey, randomKey().publicKey, randomKey().publicKey, sig, sig, sig, sig) val txid = ByteVector32.fromValidHex("0001" * 16) db.addChannel(c, txid, Satoshi(42)) - assert(db.listChannels() === SortedMap(c.shortChannelId -> PublicChannel(c, txid, Satoshi(42), None, None, None))) + assert(db.listChannels() == SortedMap(c.shortChannelId -> PublicChannel(c, txid, Satoshi(42), None, None, None))) } } @@ -113,18 +113,18 @@ class NetworkDbSpec extends AnyFunSuite { val txid_3 = randomBytes32() val capacity = 10000 sat - assert(db.listChannels().toSet === Set.empty) + assert(db.listChannels().toSet == Set.empty) db.addChannel(channel_1, txid_1, capacity) db.addChannel(channel_1, txid_1, capacity) // duplicate is ignored - assert(db.listChannels().size === 1) + assert(db.listChannels().size == 1) db.addChannel(channel_2, txid_2, capacity) db.addChannel(channel_3, txid_3, capacity) - assert(db.listChannels() === SortedMap( + assert(db.listChannels() == SortedMap( channel_1.shortChannelId -> PublicChannel(channel_1, txid_1, capacity, None, None, None), channel_2.shortChannelId -> PublicChannel(channel_2, txid_2, capacity, None, None, None), channel_3.shortChannelId -> PublicChannel(channel_3, txid_3, capacity, None, None, None))) db.removeChannel(channel_2.shortChannelId) - assert(db.listChannels() === SortedMap( + assert(db.listChannels() == SortedMap( channel_1.shortChannelId -> PublicChannel(channel_1, txid_1, capacity, None, None, None), channel_3.shortChannelId -> PublicChannel(channel_3, txid_3, capacity, None, None, None))) @@ -136,11 +136,11 @@ class NetworkDbSpec extends AnyFunSuite { db.updateChannel(channel_update_1) // duplicate is ignored db.updateChannel(channel_update_2) db.updateChannel(channel_update_3) - assert(db.listChannels() === SortedMap( + assert(db.listChannels() == SortedMap( channel_1.shortChannelId -> PublicChannel(channel_1, txid_1, capacity, Some(channel_update_1), Some(channel_update_2), None), channel_3.shortChannelId -> PublicChannel(channel_3, txid_3, capacity, Some(channel_update_3), None, None))) db.removeChannel(channel_3.shortChannelId) - assert(db.listChannels() === SortedMap( + assert(db.listChannels() == SortedMap( channel_1.shortChannelId -> PublicChannel(channel_1, txid_1, capacity, Some(channel_update_1), Some(channel_update_2), None))) } @@ -210,11 +210,11 @@ class NetworkDbSpec extends AnyFunSuite { val txid = randomBytes32() channels.foreach(ca => db.addChannel(ca, txid, capacity)) updates.foreach(u => db.updateChannel(u)) - assert(db.listChannels().keySet === channels.map(_.shortChannelId).toSet) + assert(db.listChannels().keySet == channels.map(_.shortChannelId).toSet) val toDelete = channels.map(_.shortChannelId).take(1 + Random.nextInt(2500)) db.removeChannels(toDelete) - assert(db.listChannels().keySet === (channels.map(_.shortChannelId).toSet -- toDelete)) + assert(db.listChannels().keySet == (channels.map(_.shortChannelId).toSet -- toDelete)) } } @@ -279,9 +279,9 @@ class NetworkDbSpec extends AnyFunSuite { dbName = SqliteNetworkDb.DB_NAME, targetVersion = SqliteNetworkDb.CURRENT_VERSION, postCheck = _ => { - assert(dbs.network.listNodes().toSet === nodeTestCases.map(_.node).toSet) + assert(dbs.network.listNodes().toSet == nodeTestCases.map(_.node).toSet) // NB: channel updates are not migrated - assert(dbs.network.listChannels().values.toSet === channelTestCases.map(tc => PublicChannel(tc.channel, tc.txid, tc.capacity, None, None, None)).toSet) + assert(dbs.network.listChannels().values.toSet == channelTestCases.map(tc => PublicChannel(tc.channel, tc.txid, tc.capacity, None, None, None)).toSet) } ) } @@ -319,9 +319,9 @@ class NetworkDbSpec extends AnyFunSuite { dbName = PgNetworkDb.DB_NAME, targetVersion = PgNetworkDb.CURRENT_VERSION, postCheck = _ => { - assert(dbs.network.listNodes().toSet === nodeTestCases.map(_.node).toSet) + assert(dbs.network.listNodes().toSet == nodeTestCases.map(_.node).toSet) // NB: channel updates are not migrated - assert(dbs.network.listChannels().values.toSet === channelTestCases.map(tc => PublicChannel(tc.channel, tc.txid, tc.capacity, tc.update_1_opt, tc.update_2_opt, None)).toSet) + assert(dbs.network.listChannels().values.toSet == channelTestCases.map(tc => PublicChannel(tc.channel, tc.txid, tc.capacity, tc.update_1_opt, tc.update_2_opt, None)).toSet) } ) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/PaymentsDbSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/PaymentsDbSpec.scala index 7e3a93b85a..9a0511430a 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/PaymentsDbSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/PaymentsDbSpec.scala @@ -85,8 +85,8 @@ class PaymentsDbSpec extends AnyFunSuite { db.addIncomingPayment(i1, preimage1) db.receiveIncomingPayment(i1.paymentHash, 550 msat, 1100 unixms) - assert(db.listIncomingPayments(1 unixms, 1500 unixms) === Seq(pr1)) - assert(db.listOutgoingPayments(1 unixms, 1500 unixms) === Seq(ps1)) + assert(db.listIncomingPayments(1 unixms, 1500 unixms) == Seq(pr1)) + assert(db.listOutgoingPayments(1 unixms, 1500 unixms) == Seq(ps1)) } ) @@ -184,9 +184,9 @@ class PaymentsDbSpec extends AnyFunSuite { postCheck = _ => { val db = dbs.db.payments - assert(db.getIncomingPayment(i1.paymentHash) === Some(pr1)) - assert(db.getIncomingPayment(i2.paymentHash) === Some(pr2)) - assert(db.listOutgoingPayments(1 unixms, 2000 unixms) === Seq(ps1, ps2, ps3)) + assert(db.getIncomingPayment(i1.paymentHash) == Some(pr1)) + assert(db.getIncomingPayment(i2.paymentHash) == Some(pr2)) + assert(db.listOutgoingPayments(1 unixms, 2000 unixms) == Seq(ps1, ps2, ps3)) val i3 = Bolt11Invoice(Block.TestnetGenesisBlock.hash, Some(561 msat), paymentHash3, alicePriv, Left("invoice #3"), CltvExpiryDelta(18), expirySeconds = Some(30)) val pr3 = IncomingPayment(i3, preimage3, PaymentType.Standard, i3.createdAt.toTimestampMilli, IncomingPaymentStatus.Pending) @@ -201,9 +201,9 @@ class PaymentsDbSpec extends AnyFunSuite { db.addOutgoingPayment(ps6.copy(status = OutgoingPaymentStatus.Pending)) db.updateOutgoingPayment(PaymentFailed(ps6.id, ps6.paymentHash, Nil, 1300 unixms)) - assert(db.listOutgoingPayments(1 unixms, 2000 unixms) === Seq(ps1, ps2, ps3, ps4, ps5, ps6)) - assert(db.listIncomingPayments(1 unixms, TimestampMilli.now()) === Seq(pr1, pr2, pr3)) - assert(db.listExpiredIncomingPayments(1 unixms, 2000 unixms) === Seq(pr2)) + assert(db.listOutgoingPayments(1 unixms, 2000 unixms) == Seq(ps1, ps2, ps3, ps4, ps5, ps6)) + assert(db.listIncomingPayments(1 unixms, TimestampMilli.now()) == Seq(pr1, pr2, pr3)) + assert(db.listExpiredIncomingPayments(1 unixms, 2000 unixms) == Seq(pr2)) }) } @@ -284,8 +284,8 @@ class PaymentsDbSpec extends AnyFunSuite { targetVersion = SqlitePaymentsDb.CURRENT_VERSION, postCheck = _ => { val db = dbs.db.payments - assert(db.getOutgoingPayment(id1) === Some(ps1)) - assert(db.listOutgoingPayments(parentId) === Seq(ps2, ps3)) + assert(db.getOutgoingPayment(id1) == Some(ps1)) + assert(db.listOutgoingPayments(parentId) == Seq(ps2, ps3)) } ) } @@ -378,18 +378,18 @@ class PaymentsDbSpec extends AnyFunSuite { postCheck = _ => { val db = dbs.db.payments - assert(db.getIncomingPayment(i1.paymentHash) === Some(pr1)) - assert(db.getIncomingPayment(i2.paymentHash) === Some(pr2)) - assert(db.listIncomingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2100-12-31T23:59:59.00Z").toEpochMilli)) === Seq(pr2, pr1)) - assert(db.listIncomingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2020-12-31T23:59:59.00Z").toEpochMilli)) === Seq(pr2)) - assert(db.listIncomingPayments(TimestampMilli(Instant.parse("2010-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2011-12-31T23:59:59.00Z").toEpochMilli)) === Seq.empty) - assert(db.listExpiredIncomingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2100-12-31T23:59:59.00Z").toEpochMilli)) === Seq(pr2)) - assert(db.listExpiredIncomingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2020-12-31T23:59:59.00Z").toEpochMilli)) === Seq(pr2)) - assert(db.listExpiredIncomingPayments(TimestampMilli(Instant.parse("2010-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2011-12-31T23:59:59.00Z").toEpochMilli)) === Seq.empty) - - assert(db.listOutgoingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2021-12-31T23:59:59.00Z").toEpochMilli)) === Seq(ps2, ps1, ps3)) - assert(db.listOutgoingPayments(TimestampMilli(Instant.parse("2010-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2021-01-15T23:59:59.00Z").toEpochMilli)) === Seq(ps2, ps1)) - assert(db.listOutgoingPayments(TimestampMilli(Instant.parse("2010-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2011-12-31T23:59:59.00Z").toEpochMilli)) === Seq.empty) + assert(db.getIncomingPayment(i1.paymentHash) == Some(pr1)) + assert(db.getIncomingPayment(i2.paymentHash) == Some(pr2)) + assert(db.listIncomingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2100-12-31T23:59:59.00Z").toEpochMilli)) == Seq(pr2, pr1)) + assert(db.listIncomingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2020-12-31T23:59:59.00Z").toEpochMilli)) == Seq(pr2)) + assert(db.listIncomingPayments(TimestampMilli(Instant.parse("2010-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2011-12-31T23:59:59.00Z").toEpochMilli)) == Seq.empty) + assert(db.listExpiredIncomingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2100-12-31T23:59:59.00Z").toEpochMilli)) == Seq(pr2)) + assert(db.listExpiredIncomingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2020-12-31T23:59:59.00Z").toEpochMilli)) == Seq(pr2)) + assert(db.listExpiredIncomingPayments(TimestampMilli(Instant.parse("2010-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2011-12-31T23:59:59.00Z").toEpochMilli)) == Seq.empty) + + assert(db.listOutgoingPayments(TimestampMilli(Instant.parse("2020-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2021-12-31T23:59:59.00Z").toEpochMilli)) == Seq(ps2, ps1, ps3)) + assert(db.listOutgoingPayments(TimestampMilli(Instant.parse("2010-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2021-01-15T23:59:59.00Z").toEpochMilli)) == Seq(ps2, ps1)) + assert(db.listOutgoingPayments(TimestampMilli(Instant.parse("2010-01-01T00:00:00.00Z").toEpochMilli), TimestampMilli(Instant.parse("2011-12-31T23:59:59.00Z").toEpochMilli)) == Seq.empty) } ) } @@ -427,29 +427,29 @@ class PaymentsDbSpec extends AnyFunSuite { db.addIncomingPayment(paidInvoice1, payment1.paymentPreimage) db.addIncomingPayment(paidInvoice2, payment2.paymentPreimage) - assert(db.getIncomingPayment(pendingInvoice1.paymentHash) === Some(pendingPayment1)) - assert(db.getIncomingPayment(expiredInvoice2.paymentHash) === Some(expiredPayment2)) - assert(db.getIncomingPayment(paidInvoice1.paymentHash) === Some(payment1.copy(status = IncomingPaymentStatus.Pending))) + assert(db.getIncomingPayment(pendingInvoice1.paymentHash) == Some(pendingPayment1)) + assert(db.getIncomingPayment(expiredInvoice2.paymentHash) == Some(expiredPayment2)) + assert(db.getIncomingPayment(paidInvoice1.paymentHash) == Some(payment1.copy(status = IncomingPaymentStatus.Pending))) val now = TimestampMilli.now() - assert(db.listIncomingPayments(0 unixms, now) === Seq(expiredPayment1, expiredPayment2, pendingPayment1, pendingPayment2, payment1.copy(status = IncomingPaymentStatus.Pending), payment2.copy(status = IncomingPaymentStatus.Pending))) - assert(db.listExpiredIncomingPayments(0 unixms, now) === Seq(expiredPayment1, expiredPayment2)) - assert(db.listReceivedIncomingPayments(0 unixms, now) === Nil) - assert(db.listPendingIncomingPayments(0 unixms, now) === Seq(pendingPayment1, pendingPayment2, payment1.copy(status = IncomingPaymentStatus.Pending), payment2.copy(status = IncomingPaymentStatus.Pending))) + assert(db.listIncomingPayments(0 unixms, now) == Seq(expiredPayment1, expiredPayment2, pendingPayment1, pendingPayment2, payment1.copy(status = IncomingPaymentStatus.Pending), payment2.copy(status = IncomingPaymentStatus.Pending))) + assert(db.listExpiredIncomingPayments(0 unixms, now) == Seq(expiredPayment1, expiredPayment2)) + assert(db.listReceivedIncomingPayments(0 unixms, now) == Nil) + assert(db.listPendingIncomingPayments(0 unixms, now) == Seq(pendingPayment1, pendingPayment2, payment1.copy(status = IncomingPaymentStatus.Pending), payment2.copy(status = IncomingPaymentStatus.Pending))) db.receiveIncomingPayment(paidInvoice1.paymentHash, 461 msat, receivedAt1) db.receiveIncomingPayment(paidInvoice1.paymentHash, 100 msat, receivedAt2) // adding another payment to this invoice should sum db.receiveIncomingPayment(paidInvoice2.paymentHash, 1111 msat, receivedAt2) - assert(db.getIncomingPayment(paidInvoice1.paymentHash) === Some(payment1)) + assert(db.getIncomingPayment(paidInvoice1.paymentHash) == Some(payment1)) - assert(db.listIncomingPayments(0 unixms, now) === Seq(expiredPayment1, expiredPayment2, pendingPayment1, pendingPayment2, payment1, payment2)) - assert(db.listIncomingPayments(now - 60.seconds, now) === Seq(pendingPayment1, pendingPayment2, payment1, payment2)) - assert(db.listPendingIncomingPayments(0 unixms, now) === Seq(pendingPayment1, pendingPayment2)) - assert(db.listReceivedIncomingPayments(0 unixms, now) === Seq(payment1, payment2)) + assert(db.listIncomingPayments(0 unixms, now) == Seq(expiredPayment1, expiredPayment2, pendingPayment1, pendingPayment2, payment1, payment2)) + assert(db.listIncomingPayments(now - 60.seconds, now) == Seq(pendingPayment1, pendingPayment2, payment1, payment2)) + assert(db.listPendingIncomingPayments(0 unixms, now) == Seq(pendingPayment1, pendingPayment2)) + assert(db.listReceivedIncomingPayments(0 unixms, now) == Seq(payment1, payment2)) assert(db.removeIncomingPayment(paidInvoice1.paymentHash).isFailure) - db.removeIncomingPayment(paidInvoice1.paymentHash).failed.foreach(e => assert(e.getMessage === "Cannot remove a received incoming payment")) + db.removeIncomingPayment(paidInvoice1.paymentHash).failed.foreach(e => assert(e.getMessage == "Cannot remove a received incoming payment")) assert(db.removeIncomingPayment(pendingPayment1.invoice.paymentHash).isSuccess) assert(db.removeIncomingPayment(pendingPayment1.invoice.paymentHash).isSuccess) // idempotent assert(db.removeIncomingPayment(expiredPayment1.invoice.paymentHash).isSuccess) @@ -476,12 +476,12 @@ class PaymentsDbSpec extends AnyFunSuite { assert(db.listOutgoingPayments(1 unixms, 300 unixms).toList == Seq(s1, s2)) assert(db.listOutgoingPayments(1 unixms, 150 unixms).toList == Seq(s1)) assert(db.listOutgoingPayments(150 unixms, 250 unixms).toList == Seq(s2)) - assert(db.getOutgoingPayment(s1.id) === Some(s1)) - assert(db.getOutgoingPayment(UUID.randomUUID()) === None) - assert(db.listOutgoingPayments(s2.paymentHash) === Seq(s1, s2)) - assert(db.listOutgoingPayments(s1.id) === Nil) - assert(db.listOutgoingPayments(parentId) === Seq(s1, s2)) - assert(db.listOutgoingPayments(ByteVector32.Zeroes) === Nil) + assert(db.getOutgoingPayment(s1.id) == Some(s1)) + assert(db.getOutgoingPayment(UUID.randomUUID()) == None) + assert(db.listOutgoingPayments(s2.paymentHash) == Seq(s1, s2)) + assert(db.listOutgoingPayments(s1.id) == Nil) + assert(db.listOutgoingPayments(parentId) == Seq(s1, s2)) + assert(db.listOutgoingPayments(ByteVector32.Zeroes) == Nil) val s3 = s2.copy(id = UUID.randomUUID(), amount = 789 msat, createdAt = 300 unixms) val s4 = s2.copy(id = UUID.randomUUID(), paymentType = PaymentType.Standard, createdAt = 301 unixms) @@ -490,10 +490,10 @@ class PaymentsDbSpec extends AnyFunSuite { db.updateOutgoingPayment(PaymentFailed(s3.id, s3.paymentHash, Nil, 310 unixms)) val ss3 = s3.copy(status = OutgoingPaymentStatus.Failed(Nil, 310 unixms)) - assert(db.getOutgoingPayment(s3.id) === Some(ss3)) + assert(db.getOutgoingPayment(s3.id) == Some(ss3)) db.updateOutgoingPayment(PaymentFailed(s4.id, s4.paymentHash, Seq(LocalFailure(s4.amount, Seq(hop_ab), new RuntimeException("woops")), RemoteFailure(s4.amount, Seq(hop_ab, hop_bc), Sphinx.DecryptedFailurePacket(carol, UnknownNextPeer))), 320 unixms)) val ss4 = s4.copy(status = OutgoingPaymentStatus.Failed(Seq(FailureSummary(FailureType.LOCAL, "woops", List(HopSummary(alice, bob, Some(ShortChannelId(42)))), Some(alice)), FailureSummary(FailureType.REMOTE, "processing node does not know the next peer in the route", List(HopSummary(alice, bob, Some(ShortChannelId(42))), HopSummary(bob, carol, None)), Some(carol))), 320 unixms)) - assert(db.getOutgoingPayment(s4.id) === Some(ss4)) + assert(db.getOutgoingPayment(s4.id) == Some(ss4)) // can't update again once it's in a final state assertThrows[IllegalArgumentException](db.updateOutgoingPayment(PaymentSent(parentId, s3.paymentHash, preimage1, s3.recipientAmount, s3.recipientNodeId, Seq(PaymentSent.PartialPayment(s3.id, s3.amount, 42 msat, randomBytes32(), None))))) @@ -505,9 +505,9 @@ class PaymentsDbSpec extends AnyFunSuite { val ss1 = s1.copy(status = OutgoingPaymentStatus.Succeeded(preimage1, 15 msat, Nil, 400 unixms)) val ss2 = s2.copy(status = OutgoingPaymentStatus.Succeeded(preimage1, 20 msat, Seq(HopSummary(alice, bob, Some(ShortChannelId(42))), HopSummary(bob, carol, None)), 410 unixms)) db.updateOutgoingPayment(paymentSent) - assert(db.getOutgoingPayment(s1.id) === Some(ss1)) - assert(db.getOutgoingPayment(s2.id) === Some(ss2)) - assert(db.listOutgoingPayments(parentId) === Seq(ss1, ss2, ss3, ss4)) + assert(db.getOutgoingPayment(s1.id) == Some(ss1)) + assert(db.getOutgoingPayment(s2.id) == Some(ss2)) + assert(db.listOutgoingPayments(parentId) == Seq(ss1, ss2, ss3, ss4)) // can't update again once it's in a final state assertThrows[IllegalArgumentException](db.updateOutgoingPayment(PaymentFailed(s1.id, s1.paymentHash, Nil))) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/PeersDbSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/PeersDbSpec.scala index 1b0661b71f..848b946f04 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/PeersDbSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/PeersDbSpec.scala @@ -56,20 +56,20 @@ class PeersDbSpec extends AnyFunSuite { val peer_2 = TestCase(randomKey().publicKey, Tor2("z4zif3fy7fe7bpg3", 4231)) val peer_3 = TestCase(randomKey().publicKey, Tor3("mrl2d3ilhctt2vw4qzvmz3etzjvpnc6dczliq5chrxetthgbuczuggyd", 4231)) - assert(db.listPeers().toSet === Set.empty) + assert(db.listPeers().toSet == Set.empty) db.addOrUpdatePeer(peer_1.nodeId, peer_1.nodeAddress) - assert(db.getPeer(peer_1.nodeId) === Some(peer_1.nodeAddress)) - assert(db.getPeer(peer_2.nodeId) === None) + assert(db.getPeer(peer_1.nodeId) == Some(peer_1.nodeAddress)) + assert(db.getPeer(peer_2.nodeId) == None) db.addOrUpdatePeer(peer_1.nodeId, peer_1.nodeAddress) // duplicate is ignored - assert(db.listPeers().size === 1) + assert(db.listPeers().size == 1) db.addOrUpdatePeer(peer_2.nodeId, peer_2.nodeAddress) db.addOrUpdatePeer(peer_3.nodeId, peer_3.nodeAddress) - assert(db.listPeers().map(p => TestCase(p._1, p._2)).toSet === Set(peer_1, peer_2, peer_3)) + assert(db.listPeers().map(p => TestCase(p._1, p._2)).toSet == Set(peer_1, peer_2, peer_3)) db.removePeer(peer_2.nodeId) - assert(db.listPeers().map(p => TestCase(p._1, p._2)).toSet === Set(peer_1, peer_3)) + assert(db.listPeers().map(p => TestCase(p._1, p._2)).toSet == Set(peer_1, peer_3)) db.addOrUpdatePeer(peer_1_bis.nodeId, peer_1_bis.nodeAddress) - assert(db.getPeer(peer_1.nodeId) === Some(peer_1_bis.nodeAddress)) - assert(db.listPeers().map(p => TestCase(p._1, p._2)).toSet === Set(peer_1_bis, peer_3)) + assert(db.getPeer(peer_1.nodeId) == Some(peer_1_bis.nodeAddress)) + assert(db.listPeers().map(p => TestCase(p._1, p._2)).toSet == Set(peer_1_bis, peer_3)) } } @@ -93,17 +93,17 @@ class PeersDbSpec extends AnyFunSuite { val a = randomKey().publicKey val b = randomKey().publicKey - assert(db.getRelayFees(a) === None) - assert(db.getRelayFees(b) === None) + assert(db.getRelayFees(a) == None) + assert(db.getRelayFees(b) == None) db.addOrUpdateRelayFees(a, RelayFees(1 msat, 123)) - assert(db.getRelayFees(a) === Some(RelayFees(1 msat, 123))) - assert(db.getRelayFees(b) === None) + assert(db.getRelayFees(a) == Some(RelayFees(1 msat, 123))) + assert(db.getRelayFees(b) == None) db.addOrUpdateRelayFees(a, RelayFees(2 msat, 456)) - assert(db.getRelayFees(a) === Some(RelayFees(2 msat, 456))) - assert(db.getRelayFees(b) === None) + assert(db.getRelayFees(a) == Some(RelayFees(2 msat, 456))) + assert(db.getRelayFees(b) == None) db.addOrUpdateRelayFees(b, RelayFees(3 msat, 789)) - assert(db.getRelayFees(a) === Some(RelayFees(2 msat, 456))) - assert(db.getRelayFees(b) === Some(RelayFees(3 msat, 789))) + assert(db.getRelayFees(a) == Some(RelayFees(2 msat, 456))) + assert(db.getRelayFees(b) == Some(RelayFees(3 msat, 789))) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/PendingCommandsDbSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/PendingCommandsDbSpec.scala index e69551879f..d2ec57a89f 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/PendingCommandsDbSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/PendingCommandsDbSpec.scala @@ -59,7 +59,7 @@ class PendingCommandsDbSpec extends AnyFunSuite { val msg3 = CMD_FAIL_HTLC(3, Left(randomBytes32())) val msg4 = CMD_FAIL_MALFORMED_HTLC(4, randomBytes32(), FailureMessageCodecs.BADONION) - assert(db.listSettlementCommands(channelId1).toSet === Set.empty) + assert(db.listSettlementCommands(channelId1).toSet == Set.empty) db.addSettlementCommand(channelId1, msg0) db.addSettlementCommand(channelId1, msg0) // duplicate db.addSettlementCommand(channelId1, msg1) @@ -68,11 +68,11 @@ class PendingCommandsDbSpec extends AnyFunSuite { db.addSettlementCommand(channelId1, msg4) db.addSettlementCommand(channelId2, msg0) // same messages but for different channel db.addSettlementCommand(channelId2, msg1) - assert(db.listSettlementCommands(channelId1).toSet === Set(msg0, msg1, msg2, msg3, msg4)) - assert(db.listSettlementCommands(channelId2).toSet === Set(msg0, msg1)) - assert(db.listSettlementCommands().toSet === Set((channelId1, msg0), (channelId1, msg1), (channelId1, msg2), (channelId1, msg3), (channelId1, msg4), (channelId2, msg0), (channelId2, msg1))) + assert(db.listSettlementCommands(channelId1).toSet == Set(msg0, msg1, msg2, msg3, msg4)) + assert(db.listSettlementCommands(channelId2).toSet == Set(msg0, msg1)) + assert(db.listSettlementCommands().toSet == Set((channelId1, msg0), (channelId1, msg1), (channelId1, msg2), (channelId1, msg3), (channelId1, msg4), (channelId2, msg0), (channelId2, msg1))) db.removeSettlementCommand(channelId1, msg1.id) - assert(db.listSettlementCommands().toSet === Set((channelId1, msg0), (channelId1, msg2), (channelId1, msg3), (channelId1, msg4), (channelId2, msg0), (channelId2, msg1))) + assert(db.listSettlementCommands().toSet == Set((channelId1, msg0), (channelId1, msg2), (channelId1, msg3), (channelId1, msg4), (channelId2, msg0), (channelId2, msg1))) } } @@ -98,7 +98,7 @@ class PendingCommandsDbSpec extends AnyFunSuite { dbName = PgPendingCommandsDb.DB_NAME, targetVersion = PgPendingCommandsDb.CURRENT_VERSION, postCheck = _ => - assert(dbs.pendingCommands.listSettlementCommands().toSet === testCases.map(tc => tc.channelId -> tc.cmd)) + assert(dbs.pendingCommands.listSettlementCommands().toSet == testCases.map(tc => tc.channelId -> tc.cmd)) ) case dbs: TestSqliteDatabases => migrationCheck( @@ -120,7 +120,7 @@ class PendingCommandsDbSpec extends AnyFunSuite { dbName = SqlitePendingCommandsDb.DB_NAME, targetVersion = SqlitePendingCommandsDb.CURRENT_VERSION, postCheck = _ => - assert(dbs.pendingCommands.listSettlementCommands().toSet === testCases.map(tc => tc.channelId -> tc.cmd)) + assert(dbs.pendingCommands.listSettlementCommands().toSet == testCases.map(tc => tc.channelId -> tc.cmd)) ) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/PgUtilsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/PgUtilsSpec.scala index a11283f4a9..a7f8b7f39b 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/PgUtilsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/PgUtilsSpec.scala @@ -38,7 +38,7 @@ class PgUtilsSpec extends TestKitBaseClass with AnyFunSuiteLike with Eventually intercept[LockFailureHandler.LockException] { // this will fail because the database is already locked for a different instance id Databases.postgres(config, UUID.randomUUID(), datadir, None, LockFailureHandler.logAndThrow) - }.lockFailure === LockFailure.AlreadyLocked(instanceId1)) + }.lockFailure == LockFailure.AlreadyLocked(instanceId1)) // we can renew the lease at will db1.obtainExclusiveLock() @@ -49,7 +49,7 @@ class PgUtilsSpec extends TestKitBaseClass with AnyFunSuiteLike with Eventually intercept[LockFailureHandler.LockException] { // this will fail because the database is already locked for a different instance id Databases.postgres(config, UUID.randomUUID(), datadir, None, LockFailureHandler.logAndThrow) - }.lockFailure === LockFailure.AlreadyLocked(instanceId1)) + }.lockFailure == LockFailure.AlreadyLocked(instanceId1)) // we close the first connection db1.dataSource.close() @@ -69,7 +69,7 @@ class PgUtilsSpec extends TestKitBaseClass with AnyFunSuiteLike with Eventually assert(intercept[LockFailureHandler.LockException] { // this will fail because even if we have acquired the table lock, the previous lease still hasn't expired Databases.postgres(config, UUID.randomUUID(), datadir, None, LockFailureHandler.logAndThrow) - }.lockFailure === LockFailure.AlreadyLocked(instanceId2)) + }.lockFailure == LockFailure.AlreadyLocked(instanceId2)) pg.close() } @@ -261,7 +261,7 @@ class PgUtilsSpec extends TestKitBaseClass with AnyFunSuiteLike with Eventually using(pg.getPostgresDatabase.getConnection.createStatement()) { statement => val rs = statement.executeQuery("SELECT bar FROM foo") - assert(rs.map(_.getInt("bar")).toSet === Set(10, 20, 30)) + assert(rs.map(_.getInt("bar")).toSet == Set(10, 20, 30)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/SqliteFeeratesDbSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/SqliteFeeratesDbSpec.scala index 284fec4100..a5dae743d7 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/SqliteFeeratesDbSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/SqliteFeeratesDbSpec.scala @@ -86,9 +86,9 @@ class SqliteFeeratesDbSpec extends AnyFunSuite { } // When migrating, we simply copy the estimate for blocks 144 to blocks 1008. - assert(migratedDb.getFeerates() === Some(feerate.copy(blocks_1008 = feerate.blocks_144, mempoolMinFee = feerate.blocks_144))) + assert(migratedDb.getFeerates() == Some(feerate.copy(blocks_1008 = feerate.blocks_144, mempoolMinFee = feerate.blocks_144))) migratedDb.addOrUpdateFeerates(feerate) - assert(migratedDb.getFeerates() === Some(feerate)) + assert(migratedDb.getFeerates() == Some(feerate)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/db/SqliteUtilsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/db/SqliteUtilsSpec.scala index 93ed45f2e2..6af0aea6b0 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/db/SqliteUtilsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/db/SqliteUtilsSpec.scala @@ -40,9 +40,9 @@ class SqliteUtilsSpec extends AnyFunSuite { using(conn.createStatement()) { statement => val results = statement.executeQuery("SELECT * FROM utils_test ORDER BY id") assert(results.next()) - assert(results.getLong("id") === 1) + assert(results.getLong("id") == 1) assert(results.next()) - assert(results.getLong("id") === 2) + assert(results.getLong("id") == 2) assert(!results.next()) } @@ -54,9 +54,9 @@ class SqliteUtilsSpec extends AnyFunSuite { using(conn.createStatement()) { statement => val results = statement.executeQuery("SELECT * FROM utils_test ORDER BY id") assert(results.next()) - assert(results.getLong("id") === 1) + assert(results.getLong("id") == 1) assert(results.next()) - assert(results.getLong("id") === 2) + assert(results.getLong("id") == 2) assert(!results.next()) } @@ -68,13 +68,13 @@ class SqliteUtilsSpec extends AnyFunSuite { using(conn.createStatement()) { statement => val results = statement.executeQuery("SELECT * FROM utils_test ORDER BY id") assert(results.next()) - assert(results.getLong("id") === 1) + assert(results.getLong("id") == 1) assert(results.next()) - assert(results.getLong("id") === 2) + assert(results.getLong("id") == 2) assert(results.next()) - assert(results.getLong("id") === 3) + assert(results.getLong("id") == 3) assert(results.next()) - assert(results.getLong("id") === 4) + assert(results.getLong("id") == 4) assert(!results.next()) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/ChannelIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/ChannelIntegrationSpec.scala index c04f621937..c778b391ab 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/ChannelIntegrationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/ChannelIntegrationSpec.scala @@ -154,11 +154,11 @@ abstract class ChannelIntegrationSpec extends IntegrationSpec { // now that we have the channel id, we retrieve channels default final addresses sender.send(nodes("C").register, Register.Forward(sender.ref, htlc.channelId, CMD_GET_CHANNEL_DATA(ActorRef.noSender))) val dataC = sender.expectMsgType[RES_GET_CHANNEL_DATA[DATA_NORMAL]].data - assert(dataC.commitments.commitmentFormat === commitmentFormat) + assert(dataC.commitments.commitmentFormat == commitmentFormat) val finalAddressC = scriptPubKeyToAddress(dataC.commitments.localParams.defaultFinalScriptPubKey) sender.send(nodes("F").register, Register.Forward(sender.ref, htlc.channelId, CMD_GET_CHANNEL_DATA(ActorRef.noSender))) val dataF = sender.expectMsgType[RES_GET_CHANNEL_DATA[DATA_NORMAL]].data - assert(dataF.commitments.commitmentFormat === commitmentFormat) + assert(dataF.commitments.commitmentFormat == commitmentFormat) val finalAddressF = scriptPubKeyToAddress(dataF.commitments.localParams.defaultFinalScriptPubKey) ForceCloseFixture(sender, paymentSender, stateListenerC, stateListenerF, paymentId, htlc, preimage, minerAddress, finalAddressC, finalAddressF) } @@ -259,16 +259,16 @@ abstract class ChannelIntegrationSpec extends IntegrationSpec { // we generate a few blocks to get the commit tx confirmed generateBlocks(3, Some(minerAddress)) // we wait until the htlc-timeout has been broadcast - assert(localCommit.htlcTxs.size === 1) + assert(localCommit.htlcTxs.size == 1) waitForOutputSpent(localCommit.htlcTxs.keys.head, bitcoinClient, sender) // we generate more blocks for the htlc-timeout to reach enough confirmations generateBlocks(3, Some(minerAddress)) // this will fail the htlc val failed = paymentSender.expectMsgType[PaymentFailed](max = 60 seconds) assert(failed.id == paymentId) - assert(failed.paymentHash === htlc.paymentHash) + assert(failed.paymentHash == htlc.paymentHash) assert(failed.failures.nonEmpty) - assert(failed.failures.head.asInstanceOf[RemoteFailure].e === DecryptedFailurePacket(nodes("C").nodeParams.nodeId, PermanentChannelFailure)) + 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 @@ -311,16 +311,16 @@ abstract class ChannelIntegrationSpec extends IntegrationSpec { generateBlocks((htlc.cltvExpiry.blockHeight - getBlockHeight()).toInt, Some(minerAddress)) // we wait until the claim-htlc-timeout has been broadcast val bitcoinClient = new BitcoinCoreClient(bitcoinrpcclient) - assert(remoteCommit.claimHtlcTxs.size === 1) + assert(remoteCommit.claimHtlcTxs.size == 1) waitForOutputSpent(remoteCommit.claimHtlcTxs.keys.head, bitcoinClient, sender) // and we generate blocks for the claim-htlc-timeout to reach enough confirmations generateBlocks(3, Some(minerAddress)) // this will fail the htlc val failed = paymentSender.expectMsgType[PaymentFailed](max = 60 seconds) assert(failed.id == paymentId) - assert(failed.paymentHash === htlc.paymentHash) + assert(failed.paymentHash == htlc.paymentHash) assert(failed.failures.nonEmpty) - assert(failed.failures.head.asInstanceOf[RemoteFailure].e === DecryptedFailurePacket(nodes("C").nodeParams.nodeId, PermanentChannelFailure)) + 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 @@ -391,17 +391,17 @@ abstract class ChannelIntegrationSpec extends IntegrationSpec { forwardHandlerC.forward(buffer.ref) val commitmentsF = sigListener.expectMsgType[ChannelSignatureReceived].commitments sigListener.expectNoMessage(1 second) - assert(commitmentsF.commitmentFormat === commitmentFormat) + assert(commitmentsF.commitmentFormat == commitmentFormat) // in this commitment, both parties should have a main output, there are four pending htlcs and anchor outputs if applicable val localCommitF = commitmentsF.localCommit commitmentFormat match { - case Transactions.DefaultCommitmentFormat => assert(localCommitF.commitTxAndRemoteSig.commitTx.tx.txOut.size === 6) - case _: Transactions.AnchorOutputsCommitmentFormat => assert(localCommitF.commitTxAndRemoteSig.commitTx.tx.txOut.size === 8) + case Transactions.DefaultCommitmentFormat => assert(localCommitF.commitTxAndRemoteSig.commitTx.tx.txOut.size == 6) + case _: Transactions.AnchorOutputsCommitmentFormat => assert(localCommitF.commitTxAndRemoteSig.commitTx.tx.txOut.size == 8) } val htlcTimeoutTxs = localCommitF.htlcTxsAndRemoteSigs.collect { case h@HtlcTxAndRemoteSig(_: Transactions.HtlcTimeoutTx, _) => h } val htlcSuccessTxs = localCommitF.htlcTxsAndRemoteSigs.collect { case h@HtlcTxAndRemoteSig(_: Transactions.HtlcSuccessTx, _) => h } - assert(htlcTimeoutTxs.size === 2) - assert(htlcSuccessTxs.size === 2) + assert(htlcTimeoutTxs.size == 2) + assert(htlcSuccessTxs.size == 2) // we fulfill htlcs to get the preimages buffer.expectMsgType[IncomingPaymentPacket.FinalPacket] buffer.forward(paymentHandlerF) @@ -570,14 +570,14 @@ class StandardChannelIntegrationSpec extends ChannelIntegrationSpec { val bitcoinClient = new BitcoinCoreClient(bitcoinrpcclient) awaitCond({ bitcoinClient.getMempool().pipeTo(sender.ref) - sender.expectMsgType[Seq[Transaction]].exists(_.txIn.head.outPoint.txid === fundingOutpoint.txid) + sender.expectMsgType[Seq[Transaction]].exists(_.txIn.head.outPoint.txid == fundingOutpoint.txid) }, max = 20 seconds, interval = 1 second) generateBlocks(3) awaitCond(stateListener.expectMsgType[ChannelStateChanged](max = 60 seconds).currentState == CLOSED, max = 60 seconds) bitcoinClient.lookForSpendingTx(None, fundingOutpoint.txid, fundingOutpoint.index.toInt).pipeTo(sender.ref) val closingTx = sender.expectMsgType[Transaction] - assert(closingTx.txOut.map(_.publicKeyScript).toSet === Set(finalPubKeyScriptC, finalPubKeyScriptF)) + assert(closingTx.txOut.map(_.publicKeyScript).toSet == Set(finalPubKeyScriptC, finalPubKeyScriptF)) awaitAnnouncements(1) } @@ -645,7 +645,7 @@ abstract class AnchorChannelIntegrationSpec extends ChannelIntegrationSpec { val stateEvent = eventListener.expectMsgType[ChannelStateChanged](max = 60 seconds) if (stateEvent.currentState == NORMAL) { assert(stateEvent.commitments_opt.nonEmpty) - assert(stateEvent.commitments_opt.get.asInstanceOf[Commitments].channelType === expectedChannelType) + assert(stateEvent.commitments_opt.get.asInstanceOf[Commitments].channelType == expectedChannelType) count = count + 1 } } @@ -669,7 +669,7 @@ abstract class AnchorChannelIntegrationSpec extends ChannelIntegrationSpec { sender.send(nodes("F").register, Register.Forward(sender.ref, channelId, CMD_GET_CHANNEL_DATA(ActorRef.noSender))) val initialStateDataF = sender.expectMsgType[RES_GET_CHANNEL_DATA[DATA_NORMAL]].data - assert(initialStateDataF.commitments.channelType === expectedChannelType) + assert(initialStateDataF.commitments.channelType == expectedChannelType) val initialCommitmentIndex = initialStateDataF.commitments.localCommit.index // the 'to remote' address is a simple script spending to the remote payment basepoint with a 1-block CSV delay @@ -688,7 +688,7 @@ abstract class AnchorChannelIntegrationSpec extends ChannelIntegrationSpec { val paymentId = sender.expectMsgType[UUID] val ps = sender.expectMsgType[PaymentSent](60 seconds) assert(ps.id == paymentId) - assert(Crypto.sha256(ps.paymentPreimage) === invoice.paymentHash) + assert(Crypto.sha256(ps.paymentPreimage) == invoice.paymentHash) // we make sure the htlc has been removed from F's commitment before we force-close awaitCond({ @@ -734,7 +734,7 @@ abstract class AnchorChannelIntegrationSpec extends ChannelIntegrationSpec { val mainOutputC = OutPoint(commitTx, commitTx.txOut.indexWhere(_.publicKeyScript == toRemoteOutC.publicKeyScript)) awaitCond({ bitcoinClient.getMempool().pipeTo(sender.ref) - sender.expectMsgType[Seq[Transaction]].exists(_.txIn.head.outPoint === mainOutputC) + sender.expectMsgType[Seq[Transaction]].exists(_.txIn.head.outPoint == mainOutputC) }, max = 20 seconds, interval = 1 second) // get the claim-remote-output confirmed, then the channel can go to the CLOSED state diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/MessageIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/MessageIntegrationSpec.scala index 39cb766b86..836470bf9b 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/MessageIntegrationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/MessageIntegrationSpec.scala @@ -86,7 +86,7 @@ class MessageIntegrationSpec extends IntegrationSpec { val res = probe.expectMsgType[SendOnionMessageResponse] assert(res.failureMessage.isEmpty) assert(res.response.nonEmpty) - assert(res.response.get.unknownTlvs("29") === hex"ab") + assert(res.response.get.unknownTlvs("29") == hex"ab") } test("reply timeout") { @@ -138,7 +138,7 @@ class MessageIntegrationSpec extends IntegrationSpec { assert(probe.expectMsgType[SendOnionMessageResponse].sent) val r = eventListener.expectMsgType[OnionMessages.ReceiveMessage](max = 60 seconds) - assert(r.finalPayload.records.unknown.toSet === Set(GenericTlv(UInt64(113), hex"010203"), GenericTlv(UInt64(117), hex"0102"))) + assert(r.finalPayload.records.unknown.toSet == Set(GenericTlv(UInt64(113), hex"010203"), GenericTlv(UInt64(117), hex"0102"))) } test("relay with channels-only and missing channel") { @@ -231,7 +231,7 @@ class MessageIntegrationSpec extends IntegrationSpec { assert(probe.expectMsgType[SendOnionMessageResponse].sent) val r = eventListener.expectMsgType[OnionMessages.ReceiveMessage](max = 60 seconds) - assert(r.finalPayload.records.unknown.toSet === Set(GenericTlv(UInt64(113), hex"010203"), GenericTlv(UInt64(117), hex"0102"))) + assert(r.finalPayload.records.unknown.toSet == Set(GenericTlv(UInt64(113), hex"010203"), GenericTlv(UInt64(117), hex"0102"))) } test("channel relay with no-relay") { @@ -266,10 +266,10 @@ class MessageIntegrationSpec extends IntegrationSpec { val probe = TestProbe() probe.send(nodes("B").register, Symbol("channels")) val channelsB = probe.expectMsgType[Map[ByteVector32, ActorRef]] - assert(channelsB.size === 3) + assert(channelsB.size == 3) probe.send(nodes("D").register, Symbol("channels")) val channelsD = probe.expectMsgType[Map[ByteVector32, ActorRef]] - assert(channelsD.size === 3) + assert(channelsD.size == 3) channelsB.foreach { case (channelId, channel) => if (!channelsD.contains(channelId)) { @@ -307,8 +307,8 @@ class MessageIntegrationSpec extends IntegrationSpec { assert(probe.expectMsgType[SendOnionMessageResponse].sent) val r = eventListener.expectMsgType[OnionMessages.ReceiveMessage](max = 60 seconds) - assert(r.pathId === None) - assert(r.finalPayload.records.unknown.toSet === Set(GenericTlv(UInt64(115), hex""))) + assert(r.pathId == None) + assert(r.finalPayload.records.unknown.toSet == Set(GenericTlv(UInt64(115), hex""))) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/PaymentIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/PaymentIntegrationSpec.scala index ff3b80b4b0..976dfcbbef 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/PaymentIntegrationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/PaymentIntegrationSpec.scala @@ -153,7 +153,7 @@ class PaymentIntegrationSpec extends IntegrationSpec { val routingState = sender.expectMsgType[Router.RoutingState] val publicChannels = routingState.channels.filter(pc => Set(pc.ann.nodeId1, pc.ann.nodeId2).contains(nodeId)) assert(publicChannels.nonEmpty) - publicChannels.foreach(pc => assert(pc.meta_opt.map(m => m.balance1 > 0.msat || m.balance2 > 0.msat) === Some(true), pc)) + publicChannels.foreach(pc => assert(pc.meta_opt.map(m => m.balance1 > 0.msat || m.balance2 > 0.msat) == Some(true), pc)) } test("send an HTLC A->D") { @@ -171,7 +171,7 @@ class PaymentIntegrationSpec extends IntegrationSpec { val paymentId = sender.expectMsgType[UUID] val ps = sender.expectMsgType[PaymentSent] assert(ps.id == paymentId) - assert(Crypto.sha256(ps.paymentPreimage) === invoice.paymentHash) + assert(Crypto.sha256(ps.paymentPreimage) == invoice.paymentHash) eventListener.expectMsg(PaymentMetadataReceived(invoice.paymentHash, invoice.paymentMetadata.get)) } @@ -199,7 +199,7 @@ class PaymentIntegrationSpec extends IntegrationSpec { val paymentId = sender.expectMsgType[UUID] val ps = sender.expectMsgType[PaymentSent] assert(ps.id == paymentId) - assert(Crypto.sha256(ps.paymentPreimage) === invoice.paymentHash) + assert(Crypto.sha256(ps.paymentPreimage) == invoice.paymentHash) def updateFor(n: PublicKey, pc: PublicChannel): Option[ChannelUpdate] = if (n == pc.ann.nodeId1) pc.update_1_opt else if (n == pc.ann.nodeId2) pc.update_2_opt else throw new IllegalArgumentException("this node is unrelated to this channel") @@ -252,9 +252,9 @@ class PaymentIntegrationSpec extends IntegrationSpec { val paymentId = sender.expectMsgType[UUID] val failed = sender.expectMsgType[PaymentFailed] assert(failed.id == paymentId) - assert(failed.paymentHash === invoice.paymentHash) - assert(failed.failures.size === 1) - assert(failed.failures.head.asInstanceOf[RemoteFailure].e === DecryptedFailurePacket(nodes("D").nodeParams.nodeId, IncorrectOrUnknownPaymentDetails(amount, getBlockHeight()))) + assert(failed.paymentHash == invoice.paymentHash) + assert(failed.failures.size == 1) + assert(failed.failures.head.asInstanceOf[RemoteFailure].e == DecryptedFailurePacket(nodes("D").nodeParams.nodeId, IncorrectOrUnknownPaymentDetails(amount, getBlockHeight()))) } test("send an HTLC A->D with a lower amount than requested") { @@ -272,9 +272,9 @@ class PaymentIntegrationSpec extends IntegrationSpec { val paymentId = sender.expectMsgType[UUID] val failed = sender.expectMsgType[PaymentFailed] assert(failed.id == paymentId) - assert(failed.paymentHash === invoice.paymentHash) - assert(failed.failures.size === 1) - assert(failed.failures.head.asInstanceOf[RemoteFailure].e === DecryptedFailurePacket(nodes("D").nodeParams.nodeId, IncorrectOrUnknownPaymentDetails(100000000 msat, getBlockHeight()))) + assert(failed.paymentHash == invoice.paymentHash) + assert(failed.failures.size == 1) + assert(failed.failures.head.asInstanceOf[RemoteFailure].e == DecryptedFailurePacket(nodes("D").nodeParams.nodeId, IncorrectOrUnknownPaymentDetails(100000000 msat, getBlockHeight()))) } test("send an HTLC A->D with too much overpayment") { @@ -292,9 +292,9 @@ class PaymentIntegrationSpec extends IntegrationSpec { val paymentId = sender.expectMsgType[UUID] val failed = sender.expectMsgType[PaymentFailed] assert(paymentId == failed.id) - assert(failed.paymentHash === invoice.paymentHash) - assert(failed.failures.size === 1) - assert(failed.failures.head.asInstanceOf[RemoteFailure].e === DecryptedFailurePacket(nodes("D").nodeParams.nodeId, IncorrectOrUnknownPaymentDetails(600000000 msat, getBlockHeight()))) + assert(failed.paymentHash == invoice.paymentHash) + assert(failed.failures.size == 1) + assert(failed.failures.head.asInstanceOf[RemoteFailure].e == DecryptedFailurePacket(nodes("D").nodeParams.nodeId, IncorrectOrUnknownPaymentDetails(600000000 msat, getBlockHeight()))) } test("send an HTLC A->D with a reasonable overpayment") { @@ -350,30 +350,30 @@ class PaymentIntegrationSpec extends IntegrationSpec { sender.send(nodes("B").paymentInitiator, SendPaymentToNode(amount, invoice, maxAttempts = 5, routeParams = integrationTestRouteParams)) val paymentId = sender.expectMsgType[UUID] val paymentSent = sender.expectMsgType[PaymentSent](max = 30 seconds) - assert(paymentSent.id === paymentId, paymentSent) - assert(paymentSent.paymentHash === invoice.paymentHash, paymentSent) + assert(paymentSent.id == paymentId, paymentSent) + assert(paymentSent.paymentHash == invoice.paymentHash, paymentSent) assert(paymentSent.parts.length > 1, paymentSent) - assert(paymentSent.recipientNodeId === nodes("D").nodeParams.nodeId, paymentSent) - assert(paymentSent.recipientAmount === amount, paymentSent) + assert(paymentSent.recipientNodeId == nodes("D").nodeParams.nodeId, paymentSent) + assert(paymentSent.recipientAmount == amount, paymentSent) assert(paymentSent.feesPaid > 0.msat, paymentSent) assert(paymentSent.parts.forall(p => p.id != paymentSent.id), paymentSent) assert(paymentSent.parts.forall(p => p.route.isDefined), paymentSent) val paymentParts = nodes("B").nodeParams.db.payments.listOutgoingPayments(paymentId).filter(_.status.isInstanceOf[OutgoingPaymentStatus.Succeeded]) assert(paymentParts.length == paymentSent.parts.length, paymentParts) - assert(paymentParts.map(_.amount).sum === amount, paymentParts) + assert(paymentParts.map(_.amount).sum == amount, paymentParts) assert(paymentParts.forall(p => p.parentId == paymentId), paymentParts) assert(paymentParts.forall(p => p.parentId != p.id), paymentParts) assert(paymentParts.forall(p => p.status.asInstanceOf[OutgoingPaymentStatus.Succeeded].feesPaid > 0.msat), paymentParts) awaitCond(nodes("B").nodeParams.db.audit.listSent(start, TimestampMilli.now()).nonEmpty) val sent = nodes("B").nodeParams.db.audit.listSent(start, TimestampMilli.now()) - assert(sent.length === 1, sent) - assert(sent.head.copy(parts = sent.head.parts.sortBy(_.timestamp)) === paymentSent.copy(parts = paymentSent.parts.map(_.copy(route = None)).sortBy(_.timestamp)), sent) + assert(sent.length == 1, sent) + assert(sent.head.copy(parts = sent.head.parts.sortBy(_.timestamp)) == paymentSent.copy(parts = paymentSent.parts.map(_.copy(route = None)).sortBy(_.timestamp)), sent) awaitCond(nodes("D").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).exists(_.status.isInstanceOf[IncomingPaymentStatus.Received])) val Some(IncomingPayment(_, _, _, _, IncomingPaymentStatus.Received(receivedAmount, _))) = nodes("D").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) - assert(receivedAmount === amount) + assert(receivedAmount == amount) } // NB: this test may take 20 seconds to complete (multi-part payment timeout). @@ -393,11 +393,11 @@ class PaymentIntegrationSpec extends IntegrationSpec { sender.send(nodes("B").paymentInitiator, SendPaymentToNode(amount, invoice, maxAttempts = 1, routeParams = integrationTestRouteParams)) val paymentId = sender.expectMsgType[UUID] val paymentFailed = sender.expectMsgType[PaymentFailed](max = 30 seconds) - assert(paymentFailed.id === paymentId, paymentFailed) - assert(paymentFailed.paymentHash === invoice.paymentHash, paymentFailed) + assert(paymentFailed.id == paymentId, paymentFailed) + assert(paymentFailed.paymentHash == invoice.paymentHash, paymentFailed) assert(paymentFailed.failures.length > 1, paymentFailed) - assert(nodes("D").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodes("D").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) sender.send(nodes("B").relayer, Relayer.GetOutgoingChannels()) val canSend2 = sender.expectMsgType[Relayer.OutgoingChannels].channels.map(_.commitments.availableBalanceForSend).sum @@ -416,21 +416,21 @@ class PaymentIntegrationSpec extends IntegrationSpec { sender.send(nodes("D").paymentInitiator, SendPaymentToNode(amount, invoice, maxAttempts = 3, routeParams = integrationTestRouteParams)) val paymentId = sender.expectMsgType[UUID] val paymentSent = sender.expectMsgType[PaymentSent](max = 30 seconds) - assert(paymentSent.id === paymentId, paymentSent) - assert(paymentSent.paymentHash === invoice.paymentHash, paymentSent) + assert(paymentSent.id == paymentId, paymentSent) + assert(paymentSent.paymentHash == invoice.paymentHash, paymentSent) assert(paymentSent.parts.length > 1, paymentSent) - assert(paymentSent.recipientAmount === amount, paymentSent) - assert(paymentSent.feesPaid === 0.msat, paymentSent) // no fees when using direct channels + assert(paymentSent.recipientAmount == amount, paymentSent) + assert(paymentSent.feesPaid == 0.msat, paymentSent) // no fees when using direct channels val paymentParts = nodes("D").nodeParams.db.payments.listOutgoingPayments(paymentId).filter(_.status.isInstanceOf[OutgoingPaymentStatus.Succeeded]) - assert(paymentParts.map(_.amount).sum === amount, paymentParts) + assert(paymentParts.map(_.amount).sum == amount, paymentParts) assert(paymentParts.forall(p => p.parentId == paymentId), paymentParts) assert(paymentParts.forall(p => p.parentId != p.id), paymentParts) assert(paymentParts.forall(p => p.status.asInstanceOf[OutgoingPaymentStatus.Succeeded].feesPaid == 0.msat), paymentParts) awaitCond(nodes("C").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).exists(_.status.isInstanceOf[IncomingPaymentStatus.Received])) val Some(IncomingPayment(_, _, _, _, IncomingPaymentStatus.Received(receivedAmount, _))) = nodes("C").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) - assert(receivedAmount === amount) + assert(receivedAmount == amount) } test("send a multi-part payment D->C greater than balance D->C (temporary local failure)") { @@ -448,11 +448,11 @@ class PaymentIntegrationSpec extends IntegrationSpec { sender.send(nodes("D").paymentInitiator, SendPaymentToNode(amount, invoice, maxAttempts = 1, routeParams = integrationTestRouteParams)) val paymentId = sender.expectMsgType[UUID] val paymentFailed = sender.expectMsgType[PaymentFailed](max = 30 seconds) - assert(paymentFailed.id === paymentId, paymentFailed) - assert(paymentFailed.paymentHash === invoice.paymentHash, paymentFailed) + assert(paymentFailed.id == paymentId, paymentFailed) + assert(paymentFailed.paymentHash == invoice.paymentHash, paymentFailed) val incoming = nodes("C").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) - assert(incoming.get.status === IncomingPaymentStatus.Pending, incoming) + assert(incoming.get.status == IncomingPaymentStatus.Pending, incoming) sender.send(nodes("D").relayer, Relayer.GetOutgoingChannels()) val canSend2 = sender.expectMsgType[Relayer.OutgoingChannels].channels.map(_.commitments.availableBalanceForSend).sum @@ -477,16 +477,16 @@ class PaymentIntegrationSpec extends IntegrationSpec { sender.send(nodes("B").paymentInitiator, payment) val paymentId = sender.expectMsgType[UUID] val paymentSent = sender.expectMsgType[PaymentSent](max = 30 seconds) - assert(paymentSent.id === paymentId, paymentSent) - assert(paymentSent.paymentHash === invoice.paymentHash, paymentSent) - assert(paymentSent.recipientNodeId === nodes("F").nodeParams.nodeId, paymentSent) - assert(paymentSent.recipientAmount === amount, paymentSent) - assert(paymentSent.feesPaid === 1210100.msat, paymentSent) - assert(paymentSent.nonTrampolineFees === 0.msat, paymentSent) + assert(paymentSent.id == paymentId, paymentSent) + assert(paymentSent.paymentHash == invoice.paymentHash, paymentSent) + assert(paymentSent.recipientNodeId == nodes("F").nodeParams.nodeId, paymentSent) + assert(paymentSent.recipientAmount == amount, paymentSent) + assert(paymentSent.feesPaid == 1210100.msat, paymentSent) + assert(paymentSent.nonTrampolineFees == 0.msat, paymentSent) awaitCond(nodes("F").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).exists(_.status.isInstanceOf[IncomingPaymentStatus.Received])) val Some(IncomingPayment(_, _, _, _, IncomingPaymentStatus.Received(receivedAmount, _))) = nodes("F").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) - assert(receivedAmount === amount) + assert(receivedAmount == amount) awaitCond({ val relayed = nodes("G").nodeParams.db.audit.listRelayed(start, TimestampMilli.now()).filter(_.paymentHash == invoice.paymentHash) @@ -498,10 +498,10 @@ class PaymentIntegrationSpec extends IntegrationSpec { val outgoingSuccess = nodes("B").nodeParams.db.payments.listOutgoingPayments(paymentId).filter(p => p.status.isInstanceOf[OutgoingPaymentStatus.Succeeded]) outgoingSuccess.collect { case p@OutgoingPayment(_, _, _, _, _, _, _, recipientNodeId, _, _, OutgoingPaymentStatus.Succeeded(_, _, route, _)) => - assert(recipientNodeId === nodes("F").nodeParams.nodeId, p) - assert(route.lastOption === Some(HopSummary(nodes("G").nodeParams.nodeId, nodes("F").nodeParams.nodeId)), p) + assert(recipientNodeId == nodes("F").nodeParams.nodeId, p) + assert(route.lastOption == Some(HopSummary(nodes("G").nodeParams.nodeId, nodes("F").nodeParams.nodeId)), p) } - assert(outgoingSuccess.map(_.amount).sum === amount + 1210100.msat, outgoingSuccess) + assert(outgoingSuccess.map(_.amount).sum == amount + 1210100.msat, outgoingSuccess) } test("send a trampoline payment D->B (via trampoline C)") { @@ -523,15 +523,15 @@ class PaymentIntegrationSpec extends IntegrationSpec { sender.send(nodes("D").paymentInitiator, payment) val paymentId = sender.expectMsgType[UUID] val paymentSent = sender.expectMsgType[PaymentSent](max = 30 seconds) - assert(paymentSent.id === paymentId, paymentSent) - assert(paymentSent.paymentHash === invoice.paymentHash, paymentSent) - assert(paymentSent.recipientAmount === amount, paymentSent) - assert(paymentSent.feesPaid === 750000.msat, paymentSent) - assert(paymentSent.nonTrampolineFees === 0.msat, paymentSent) + assert(paymentSent.id == paymentId, paymentSent) + assert(paymentSent.paymentHash == invoice.paymentHash, paymentSent) + assert(paymentSent.recipientAmount == amount, paymentSent) + assert(paymentSent.feesPaid == 750000.msat, paymentSent) + assert(paymentSent.nonTrampolineFees == 0.msat, paymentSent) awaitCond(nodes("B").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).exists(_.status.isInstanceOf[IncomingPaymentStatus.Received])) val Some(IncomingPayment(_, _, _, _, IncomingPaymentStatus.Received(receivedAmount, _))) = nodes("B").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) - assert(receivedAmount === amount) + assert(receivedAmount == amount) eventListener.expectMsg(PaymentMetadataReceived(invoice.paymentHash, invoice.paymentMetadata.get)) awaitCond({ @@ -544,15 +544,15 @@ class PaymentIntegrationSpec extends IntegrationSpec { val outgoingSuccess = nodes("D").nodeParams.db.payments.listOutgoingPayments(paymentId).filter(p => p.status.isInstanceOf[OutgoingPaymentStatus.Succeeded]) outgoingSuccess.collect { case p@OutgoingPayment(_, _, _, _, _, _, _, recipientNodeId, _, _, OutgoingPaymentStatus.Succeeded(_, _, route, _)) => - assert(recipientNodeId === nodes("B").nodeParams.nodeId, p) - assert(route.lastOption === Some(HopSummary(nodes("C").nodeParams.nodeId, nodes("B").nodeParams.nodeId)), p) + assert(recipientNodeId == nodes("B").nodeParams.nodeId, p) + assert(route.lastOption == Some(HopSummary(nodes("C").nodeParams.nodeId, nodes("B").nodeParams.nodeId)), p) } - assert(outgoingSuccess.map(_.amount).sum === amount + 750000.msat, outgoingSuccess) + assert(outgoingSuccess.map(_.amount).sum == amount + 750000.msat, outgoingSuccess) awaitCond(nodes("D").nodeParams.db.audit.listSent(start, TimestampMilli.now()).nonEmpty) val sent = nodes("D").nodeParams.db.audit.listSent(start, TimestampMilli.now()) - assert(sent.length === 1, sent) - assert(sent.head.copy(parts = sent.head.parts.sortBy(_.timestamp)) === paymentSent.copy(parts = paymentSent.parts.map(_.copy(route = None)).sortBy(_.timestamp)), sent) + assert(sent.length == 1, sent) + assert(sent.head.copy(parts = sent.head.parts.sortBy(_.timestamp)) == paymentSent.copy(parts = paymentSent.parts.map(_.copy(route = None)).sortBy(_.timestamp)), sent) } test("send a trampoline payment F1->A (via trampoline C, non-trampoline recipient)") { @@ -575,14 +575,14 @@ class PaymentIntegrationSpec extends IntegrationSpec { sender.send(nodes("F").paymentInitiator, payment) val paymentId = sender.expectMsgType[UUID] val paymentSent = sender.expectMsgType[PaymentSent](max = 30 seconds) - assert(paymentSent.id === paymentId, paymentSent) - assert(paymentSent.paymentHash === invoice.paymentHash, paymentSent) - assert(paymentSent.recipientAmount === amount, paymentSent) - assert(paymentSent.trampolineFees === 1500000.msat, paymentSent) + assert(paymentSent.id == paymentId, paymentSent) + assert(paymentSent.paymentHash == invoice.paymentHash, paymentSent) + assert(paymentSent.recipientAmount == amount, paymentSent) + assert(paymentSent.trampolineFees == 1500000.msat, paymentSent) awaitCond(nodes("A").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).exists(_.status.isInstanceOf[IncomingPaymentStatus.Received])) val Some(IncomingPayment(_, _, _, _, IncomingPaymentStatus.Received(receivedAmount, _))) = nodes("A").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) - assert(receivedAmount === amount) + assert(receivedAmount == amount) eventListener.expectMsg(PaymentMetadataReceived(invoice.paymentHash, invoice.paymentMetadata.get)) awaitCond({ @@ -595,10 +595,10 @@ class PaymentIntegrationSpec extends IntegrationSpec { val outgoingSuccess = nodes("F").nodeParams.db.payments.listOutgoingPayments(paymentId).filter(p => p.status.isInstanceOf[OutgoingPaymentStatus.Succeeded]) outgoingSuccess.collect { case p@OutgoingPayment(_, _, _, _, _, _, _, recipientNodeId, _, _, OutgoingPaymentStatus.Succeeded(_, _, route, _)) => - assert(recipientNodeId === nodes("A").nodeParams.nodeId, p) - assert(route.lastOption === Some(HopSummary(nodes("C").nodeParams.nodeId, nodes("A").nodeParams.nodeId)), p) + assert(recipientNodeId == nodes("A").nodeParams.nodeId, p) + assert(route.lastOption == Some(HopSummary(nodes("C").nodeParams.nodeId, nodes("A").nodeParams.nodeId)), p) } - assert(outgoingSuccess.map(_.amount).sum === amount + 1500000.msat, outgoingSuccess) + assert(outgoingSuccess.map(_.amount).sum == amount + 1500000.msat, outgoingSuccess) } test("send a trampoline payment B->D (temporary local failure at trampoline)") { @@ -622,10 +622,10 @@ class PaymentIntegrationSpec extends IntegrationSpec { sender.send(nodes("B").paymentInitiator, payment) val paymentId = sender.expectMsgType[UUID] val paymentFailed = sender.expectMsgType[PaymentFailed](max = 30 seconds) - assert(paymentFailed.id === paymentId, paymentFailed) - assert(paymentFailed.paymentHash === invoice.paymentHash, paymentFailed) + assert(paymentFailed.id == paymentId, paymentFailed) + assert(paymentFailed.paymentHash == invoice.paymentHash, paymentFailed) - assert(nodes("D").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodes("D").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) val outgoingPayments = nodes("B").nodeParams.db.payments.listOutgoingPayments(paymentId) assert(outgoingPayments.nonEmpty, outgoingPayments) assert(outgoingPayments.forall(p => p.status.isInstanceOf[OutgoingPaymentStatus.Failed]), outgoingPayments) @@ -643,10 +643,10 @@ class PaymentIntegrationSpec extends IntegrationSpec { sender.send(nodes("A").paymentInitiator, payment) val paymentId = sender.expectMsgType[UUID] val paymentFailed = sender.expectMsgType[PaymentFailed](max = 30 seconds) - assert(paymentFailed.id === paymentId, paymentFailed) - assert(paymentFailed.paymentHash === invoice.paymentHash, paymentFailed) + assert(paymentFailed.id == paymentId, paymentFailed) + assert(paymentFailed.paymentHash == invoice.paymentHash, paymentFailed) - assert(nodes("D").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodes("D").nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) val outgoingPayments = nodes("A").nodeParams.db.payments.listOutgoingPayments(paymentId) assert(outgoingPayments.nonEmpty, outgoingPayments) assert(outgoingPayments.forall(p => p.status.isInstanceOf[OutgoingPaymentStatus.Failed]), outgoingPayments) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/StartupIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/StartupIntegrationSpec.scala index 1aeddcad3f..2d13c8b4c5 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/StartupIntegrationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/StartupIntegrationSpec.scala @@ -41,7 +41,7 @@ class StartupIntegrationSpec extends IntegrationSpec { val thrown = intercept[BitcoinDefaultWalletException] { instantiateEclairNode("C", ConfigFactory.parseMap(Map("eclair.bitcoind.wallet" -> "", "eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig)) } - assert(thrown === BitcoinDefaultWalletException(List(defaultWallet, ""))) + assert(thrown == BitcoinDefaultWalletException(List(defaultWallet, ""))) } test("explicit bitcoind wallet configured and two wallets loaded") { @@ -58,7 +58,7 @@ class StartupIntegrationSpec extends IntegrationSpec { val thrown = intercept[BitcoinWalletNotLoadedException] { instantiateEclairNode("E", ConfigFactory.parseMap(Map("eclair.bitcoind.wallet" -> "notloaded", "eclair.server.port" -> TestUtils.availablePort).asJava).withFallback(withDefaultCommitment).withFallback(commonConfig)) } - assert(thrown === BitcoinWalletNotLoadedException("notloaded", List(defaultWallet, ""))) + assert(thrown == BitcoinWalletNotLoadedException("notloaded", List(defaultWallet, ""))) } test("bitcoind started with wallets disabled") { @@ -66,6 +66,6 @@ class StartupIntegrationSpec extends IntegrationSpec { val thrown = intercept[BitcoinWalletDisabledException] { instantiateEclairNode("F", ConfigFactory.load().getConfig("eclair").withFallback(withDefaultCommitment).withFallback(commonConfig)) } - assert(thrown === BitcoinWalletDisabledException(e = JsonRPCError(Error(-32601, "Method not found")))) + assert(thrown == BitcoinWalletDisabledException(e = JsonRPCError(Error(-32601, "Method not found")))) } } \ No newline at end of file diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala index 97d4528a3e..3316c5cb3d 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/integration/basic/fixtures/MinimalNodeFixture.scala @@ -152,7 +152,7 @@ object MinimalNodeFixture extends Assertions { } def confirmChannel(node1: MinimalNodeFixture, node2: MinimalNodeFixture, channelId: ByteVector32, blockHeight: BlockHeight, txIndex: Int)(implicit system: ActorSystem): ShortChannelId = { - assert(getChannelState(node1, channelId) === WAIT_FOR_FUNDING_CONFIRMED) + assert(getChannelState(node1, channelId) == WAIT_FOR_FUNDING_CONFIRMED) val data1Before = getChannelData(node1, channelId).asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED] val fundingTx = data1Before.fundingTx.get diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/interop/rustytests/RustyTestsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/interop/rustytests/RustyTestsSpec.scala index 2563eaf43e..fa6b642e34 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/interop/rustytests/RustyTestsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/interop/rustytests/RustyTestsSpec.scala @@ -107,15 +107,15 @@ class RustyTestsSpec extends TestKitBaseClass with Matchers with FixtureAnyFunSu TestKit.shutdownActorSystem(system) } - test("01-offer1") { f => assert(f.ref === f.res) } - test("02-offer2") { f => assert(f.ref === f.res) } - test("03-fulfill1") { f => assert(f.ref === f.res) } - // test("04-two-commits-onedir") { f => assert(f.ref === f.res) } DOES NOT PASS : we now automatically sign back when we receive a revocation and have acked changes - // test("05-two-commits-in-flight") { f => assert(f.ref === f.res)} DOES NOT PASS : cannot send two commit in a row (without having first revocation) - test("10-offers-crossover") { f => assert(f.ref === f.res) } - test("11-commits-crossover") { f => assert(f.ref === f.res) } - /*test("13-fee") { f => assert(f.ref === f.res)} - test("14-fee-twice") { f => assert(f.ref === f.res)} - test("15-fee-twice-back-to-back") { f => assert(f.ref === f.res)}*/ + test("01-offer1") { f => assert(f.ref == f.res) } + test("02-offer2") { f => assert(f.ref == f.res) } + test("03-fulfill1") { f => assert(f.ref == f.res) } + // test("04-two-commits-onedir") { f => assert(f.ref == f.res) } DOES NOT PASS : we now automatically sign back when we receive a revocation and have acked changes + // test("05-two-commits-in-flight") { f => assert(f.ref == f.res)} DOES NOT PASS : cannot send two commit in a row (without having first revocation) + test("10-offers-crossover") { f => assert(f.ref == f.res) } + test("11-commits-crossover") { f => assert(f.ref == f.res) } + /*test("13-fee") { f => assert(f.ref == f.res)} + test("14-fee-twice") { f => assert(f.ref == f.res)} + test("15-fee-twice-back-to-back") { f => assert(f.ref == f.res)}*/ } \ No newline at end of file diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/io/MessageRelaySpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/io/MessageRelaySpec.scala index e5104e37a3..202a4fe44f 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/io/MessageRelaySpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/io/MessageRelaySpec.scala @@ -61,9 +61,9 @@ class MessageRelaySpec extends ScalaTestWithActorTestKit(ConfigFactory.load("app relay ! RelayMessage(messageId, switchboard.ref, randomKey().publicKey, bobId, message, RelayAll, None) val connectToNextPeer = switchboard.expectMsgType[Peer.Connect] - assert(connectToNextPeer.nodeId === bobId) + assert(connectToNextPeer.nodeId == bobId) connectToNextPeer.replyTo ! PeerConnection.ConnectionResult.Connected(peerConnection.ref.toClassic, peer.ref.toClassic) - assert(peer.expectMessageType[Peer.RelayOnionMessage].msg === message) + assert(peer.expectMessageType[Peer.RelayOnionMessage].msg == message) } test("relay with existing peer") { f => @@ -74,9 +74,9 @@ class MessageRelaySpec extends ScalaTestWithActorTestKit(ConfigFactory.load("app relay ! RelayMessage(messageId, switchboard.ref, randomKey().publicKey, bobId, message, RelayAll, None) val connectToNextPeer = switchboard.expectMsgType[Peer.Connect] - assert(connectToNextPeer.nodeId === bobId) + assert(connectToNextPeer.nodeId == bobId) connectToNextPeer.replyTo ! PeerConnection.ConnectionResult.AlreadyConnected(peerConnection.ref.toClassic, peer.ref.toClassic) - assert(peer.expectMessageType[Peer.RelayOnionMessage].msg === message) + assert(peer.expectMessageType[Peer.RelayOnionMessage].msg == message) } test("can't open new connection") { f => @@ -87,7 +87,7 @@ class MessageRelaySpec extends ScalaTestWithActorTestKit(ConfigFactory.load("app relay ! RelayMessage(messageId, switchboard.ref, randomKey().publicKey, bobId, message, RelayAll, Some(probe.ref)) val connectToNextPeer = switchboard.expectMsgType[Peer.Connect] - assert(connectToNextPeer.nodeId === bobId) + assert(connectToNextPeer.nodeId == bobId) connectToNextPeer.replyTo ! PeerConnection.ConnectionResult.NoAddressFound probe.expectMessage(ConnectionFailure(messageId, PeerConnection.ConnectionResult.NoAddressFound)) } @@ -101,7 +101,7 @@ class MessageRelaySpec extends ScalaTestWithActorTestKit(ConfigFactory.load("app relay ! RelayMessage(messageId, switchboard.ref, previousNodeId, bobId, message, RelayChannelsOnly, Some(probe.ref)) val getPeerInfo = switchboard.expectMsgType[GetPeerInfo] - assert(getPeerInfo.remoteNodeId === previousNodeId) + assert(getPeerInfo.remoteNodeId == previousNodeId) getPeerInfo.replyTo ! PeerInfo(peer.ref.toClassic, previousNodeId, Peer.CONNECTED, None, 0) probe.expectMessage(AgainstPolicy(messageId, RelayChannelsOnly)) @@ -117,11 +117,11 @@ class MessageRelaySpec extends ScalaTestWithActorTestKit(ConfigFactory.load("app relay ! RelayMessage(messageId, switchboard.ref, previousNodeId, bobId, message, RelayChannelsOnly, Some(probe.ref)) val getPeerInfo1 = switchboard.expectMsgType[GetPeerInfo] - assert(getPeerInfo1.remoteNodeId === previousNodeId) + assert(getPeerInfo1.remoteNodeId == previousNodeId) getPeerInfo1.replyTo ! PeerInfo(peer.ref.toClassic, previousNodeId, Peer.CONNECTED, None, 1) val getPeerInfo2 = switchboard.expectMsgType[GetPeerInfo] - assert(getPeerInfo2.remoteNodeId === bobId) + assert(getPeerInfo2.remoteNodeId == bobId) getPeerInfo2.replyTo ! PeerNotFound(bobId) probe.expectMessage(AgainstPolicy(messageId, RelayChannelsOnly)) @@ -137,14 +137,14 @@ class MessageRelaySpec extends ScalaTestWithActorTestKit(ConfigFactory.load("app relay ! RelayMessage(messageId, switchboard.ref, previousNodeId, bobId, message, RelayChannelsOnly, None) val getPeerInfo1 = switchboard.expectMsgType[GetPeerInfo] - assert(getPeerInfo1.remoteNodeId === previousNodeId) + assert(getPeerInfo1.remoteNodeId == previousNodeId) getPeerInfo1.replyTo ! PeerInfo(TestProbe()(system.classicSystem).ref, previousNodeId, Peer.CONNECTED, None, 1) val getPeerInfo2 = switchboard.expectMsgType[GetPeerInfo] - assert(getPeerInfo2.remoteNodeId === bobId) + assert(getPeerInfo2.remoteNodeId == bobId) getPeerInfo2.replyTo ! PeerInfo(peer.ref.toClassic, bobId, Peer.CONNECTED, None, 2) - assert(peer.expectMessageType[Peer.RelayOnionMessage].msg === message) + assert(peer.expectMessageType[Peer.RelayOnionMessage].msg == message) } test("no relay") { f => diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/io/NodeURISpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/io/NodeURISpec.scala index 2fb1a4ade9..949e24bdad 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/io/NodeURISpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/io/NodeURISpec.scala @@ -48,7 +48,7 @@ class NodeURISpec extends AnyFunSuite { assert(nodeUri.nodeId.toString() == PUBKEY) assert(nodeUri.address.host == testCase.formattedAddr) assert(nodeUri.address.port == testCase.port) - assert(nodeUri.toString === s"$PUBKEY@${testCase.formattedAddr}:${testCase.port}") + assert(nodeUri.toString == s"$PUBKEY@${testCase.formattedAddr}:${testCase.port}") } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerConnectionSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerConnectionSpec.scala index 117d9032c1..6333ae77ab 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerConnectionSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerConnectionSpec.scala @@ -76,7 +76,7 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi probe.send(peerConnection, PeerConnection.InitializeConnection(peer.ref, aliceParams.chainHash, aliceParams.features.initFeatures(), doSync)) transport.expectMsgType[TransportHandler.Listener] val localInit = transport.expectMsgType[protocol.Init] - assert(localInit.networks === List(Block.RegtestGenesisBlock.hash)) + assert(localInit.networks == List(Block.RegtestGenesisBlock.hash)) transport.send(peerConnection, remoteInit) transport.expectMsgType[TransportHandler.ReadAck] if (doSync) { @@ -85,7 +85,7 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi router.expectNoMessage(1 second) } peer.expectMsg(PeerConnection.ConnectionReady(peerConnection, remoteNodeId, address, outgoing = true, localInit, remoteInit)) - assert(peerConnection.stateName === PeerConnection.CONNECTED) + assert(peerConnection.stateName == PeerConnection.CONNECTED) } test("establish connection") { f => @@ -104,7 +104,7 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi probe.send(peerConnection, PeerConnection.InitializeConnection(peer.ref, nodeParams.chainHash, nodeParams.features.initFeatures(), doSync = false)) transport.expectMsgType[TransportHandler.Listener] val localInit = transport.expectMsgType[protocol.Init] - assert(localInit.remoteAddress_opt === Some(fakeIPAddress)) + assert(localInit.remoteAddress_opt == Some(fakeIPAddress)) } test("handle connection closed during authentication") { f => @@ -215,7 +215,7 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi val ping = Ping(42, randomBytes(127)) transport.send(peerConnection, ping) transport.expectMsg(TransportHandler.ReadAck(ping)) - assert(transport.expectMsgType[Pong].data.size === ping.pongLength) + assert(transport.expectMsgType[Pong].data.size == ping.pongLength) } test("send a ping if no message after init") { f => @@ -246,7 +246,7 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi val ping = Ping(Int.MaxValue, randomBytes(127)) transport.send(peerConnection, ping) transport.expectMsg(TransportHandler.ReadAck(ping)) - assert(transport.expectMsgType[Warning].channelId === Peer.CHANNELID_ZERO) + assert(transport.expectMsgType[Warning].channelId == Peer.CHANNELID_ZERO) transport.expectNoMessage() } @@ -376,14 +376,14 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi router.send(peerConnection, GossipDecision.InvalidAnnouncement(channels(0))) // peer will return a connection-wide error, including the hex-encoded representation of the bad message val warn1 = transport.expectMsgType[Warning] - assert(warn1.channelId === Peer.CHANNELID_ZERO) + assert(warn1.channelId == Peer.CHANNELID_ZERO) assert(new String(warn1.data.toArray).startsWith("invalid announcement, couldn't verify channel")) // let's assume that one of the sigs were invalid router.send(peerConnection, GossipDecision.InvalidSignature(channels(0))) // peer will return a connection-wide error, including the hex-encoded representation of the bad message val warn2 = transport.expectMsgType[Warning] - assert(warn2.channelId === Peer.CHANNELID_ZERO) + assert(warn2.channelId == Peer.CHANNELID_ZERO) assert(new String(warn2.data.toArray).startsWith("invalid announcement sig")) } @@ -411,7 +411,7 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi probe watch peerConnection probe.send(peerConnection, message) // The connection is still open for a short while. - assert(peerConnection.stateName === PeerConnection.CONNECTED) + assert(peerConnection.stateName == PeerConnection.CONNECTED) sleep(1 second) probe.expectTerminated(peerConnection, max = Duration.Zero) } @@ -422,7 +422,7 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi val probe = TestProbe() val (_, message) = buildMessage(randomKey(), randomKey(), Nil, Recipient(remoteNodeId, None), Nil) probe.send(peerConnection, message) - assert(peerConnection.stateName === PeerConnection.CONNECTED) + assert(peerConnection.stateName == PeerConnection.CONNECTED) probe.send(peerConnection, FundingLocked(ByteVector32(hex"0000000000000000000000000000000000000000000000000000000000000000"), randomKey().publicKey)) peerConnection.stateData match { case d: PeerConnection.ConnectedData => assert(d.isPersistent) @@ -481,7 +481,7 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi ) for ((address, expected) <- testCases) { val isPublicIP = NodeAddress.isPublicIPAddress(address) - assert(isPublicIP === expected) + assert(isPublicIP == expected) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerSpec.scala index f5387b4c77..e557c5b3e0 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerSpec.scala @@ -55,7 +55,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle case class FakeChannelFactory(channel: TestProbe) extends ChannelFactory { override def spawn(context: ActorContext, remoteNodeId: PublicKey, origin_opt: Option[ActorRef]): ActorRef = { - assert(remoteNodeId === Bob.nodeParams.nodeId) + assert(remoteNodeId == Bob.nodeParams.nodeId) channel.ref } } @@ -94,9 +94,9 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle val probe = TestProbe() probe.send(peer, Peer.GetPeerInfo(Some(probe.ref.toTyped))) val peerInfo = probe.expectMsgType[Peer.PeerInfo] - assert(peerInfo.peer === peer) - assert(peerInfo.nodeId === remoteNodeId) - assert(peerInfo.state === Peer.CONNECTED) + assert(peerInfo.peer == peer) + assert(peerInfo.nodeId == remoteNodeId) + assert(peerInfo.state == Peer.CONNECTED) } test("restore existing channels") { f => @@ -188,7 +188,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle connect(remoteNodeId, peer, peerConnection, switchboard, channels = Set(ChannelCodecsSpec.normal)) probe.send(peer, Peer.GetPeerInfo(Some(probe.ref.toTyped))) - assert(probe.expectMsgType[Peer.PeerInfo].state === Peer.CONNECTED) + assert(probe.expectMsgType[Peer.PeerInfo].state == Peer.CONNECTED) probe.send(peer, Peer.Disconnect(f.remoteNodeId)) probe.expectMsg("disconnecting") @@ -202,11 +202,11 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle awaitCond { probe.send(peer, Peer.GetPeerInfo(None)) - probe.expectMsgType[Peer.PeerInfo].state === Peer.DISCONNECTED + probe.expectMsgType[Peer.PeerInfo].state == Peer.DISCONNECTED } probe.send(peer, Peer.Disconnect(f.remoteNodeId)) - assert(probe.expectMsgType[Status.Failure].cause.getMessage === "not connected") + assert(probe.expectMsgType[Status.Failure].cause.getMessage == "not connected") } test("handle new connection in state CONNECTED") { f => @@ -220,7 +220,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle channel.expectMsg(INPUT_RESTORED(ChannelCodecsSpec.normal)) val (localInit, remoteInit) = { val inputReconnected = channel.expectMsgType[INPUT_RECONNECTED] - assert(inputReconnected.remote === peerConnection1.ref) + assert(inputReconnected.remote == peerConnection1.ref) (inputReconnected.localInit, inputReconnected.remoteInit) } @@ -229,14 +229,14 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle peerConnection1.expectMsg(PeerConnection.Kill(PeerConnection.KillReason.ConnectionReplaced)) channel.expectMsg(INPUT_DISCONNECTED) channel.expectMsg(INPUT_RECONNECTED(peerConnection2.ref, localInit, remoteInit)) - awaitCond(peer.stateData.asInstanceOf[Peer.ConnectedData].peerConnection === peerConnection2.ref) + awaitCond(peer.stateData.asInstanceOf[Peer.ConnectedData].peerConnection == peerConnection2.ref) peerConnection3.send(peer, PeerConnection.ConnectionReady(peerConnection3.ref, remoteNodeId, fakeIPAddress, outgoing = false, localInit, remoteInit)) // peer should kill previous connection peerConnection2.expectMsg(PeerConnection.Kill(PeerConnection.KillReason.ConnectionReplaced)) channel.expectMsg(INPUT_DISCONNECTED) channel.expectMsg(INPUT_RECONNECTED(peerConnection3.ref, localInit, remoteInit)) - awaitCond(peer.stateData.asInstanceOf[Peer.ConnectedData].peerConnection === peerConnection3.ref) + awaitCond(peer.stateData.asInstanceOf[Peer.ConnectedData].peerConnection == peerConnection3.ref) } test("send state transitions to child reconnection actor", Tag("auto_reconnect"), Tag("with_node_announcement")) { f => @@ -275,14 +275,14 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle val open = createOpenChannelMessage() peerConnection.send(peer, open) awaitCond(peer.stateData.channels.nonEmpty) - assert(channel.expectMsgType[INPUT_INIT_FUNDEE].temporaryChannelId === open.temporaryChannelId) + assert(channel.expectMsgType[INPUT_INIT_FUNDEE].temporaryChannelId == open.temporaryChannelId) channel.expectMsg(open) // open_channel messages with the same temporary channel id should simply be ignored peerConnection.send(peer, open.copy(fundingSatoshis = 100000 sat, fundingPubkey = randomKey().publicKey)) channel.expectNoMessage(100 millis) peerConnection.expectNoMessage(100 millis) - assert(peer.stateData.channels.size === 1) + assert(peer.stateData.channels.size == 1) } test("don't spawn a wumbo channel if wumbo feature isn't enabled") { f => @@ -379,7 +379,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle val open = createOpenChannelMessage(TlvStream[OpenChannelTlv](ChannelTlv.ChannelTypeTlv(ChannelTypes.Standard))) peerConnection.send(peer, open) awaitCond(peer.stateData.channels.nonEmpty) - assert(channel.expectMsgType[INPUT_INIT_FUNDEE].channelType === ChannelTypes.Standard) + assert(channel.expectMsgType[INPUT_INIT_FUNDEE].channelType == ChannelTypes.Standard) channel.expectMsg(open) } @@ -391,15 +391,15 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle assert(peer.stateData.channels.isEmpty) probe.send(peer, Peer.OpenChannel(remoteNodeId, 15000 sat, 0 msat, None, None, None, None)) - assert(channel.expectMsgType[INPUT_INIT_FUNDER].channelType === ChannelTypes.StaticRemoteKey) + assert(channel.expectMsgType[INPUT_INIT_FUNDER].channelType == ChannelTypes.StaticRemoteKey) // We can create channels that don't use the features we have enabled. probe.send(peer, Peer.OpenChannel(remoteNodeId, 15000 sat, 0 msat, Some(ChannelTypes.Standard), None, None, None)) - assert(channel.expectMsgType[INPUT_INIT_FUNDER].channelType === ChannelTypes.Standard) + assert(channel.expectMsgType[INPUT_INIT_FUNDER].channelType == ChannelTypes.Standard) // We can create channels that use features that we haven't enabled. probe.send(peer, Peer.OpenChannel(remoteNodeId, 15000 sat, 0 msat, Some(ChannelTypes.AnchorOutputs), None, None, None)) - assert(channel.expectMsgType[INPUT_INIT_FUNDER].channelType === ChannelTypes.AnchorOutputs) + assert(channel.expectMsgType[INPUT_INIT_FUNDER].channelType == ChannelTypes.AnchorOutputs) } test("use correct on-chain fee rates when spawning a channel (anchor outputs)", Tag("anchor_outputs")) { f => @@ -414,10 +414,10 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle feeEstimator.setFeerate(FeeratesPerKw.single(TestConstants.anchorOutputsFeeratePerKw * 2).copy(mempoolMinFee = FeeratePerKw(250 sat))) probe.send(peer, Peer.OpenChannel(remoteNodeId, 15000 sat, 0 msat, None, None, None, None)) val init = channel.expectMsgType[INPUT_INIT_FUNDER] - assert(init.channelType === ChannelTypes.AnchorOutputs) - assert(init.fundingAmount === 15000.sat) - assert(init.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw) - assert(init.fundingTxFeerate === feeEstimator.getFeeratePerKw(nodeParams.onChainFeeConf.feeTargets.fundingBlockTarget)) + assert(init.channelType == ChannelTypes.AnchorOutputs) + assert(init.fundingAmount == 15000.sat) + assert(init.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw) + assert(init.fundingTxFeerate == feeEstimator.getFeeratePerKw(nodeParams.onChainFeeConf.feeTargets.fundingBlockTarget)) } test("use correct on-chain fee rates when spawning a channel (anchor outputs zero fee htlc)", Tag("anchor_outputs_zero_fee_htlc_tx")) { f => @@ -432,10 +432,10 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle feeEstimator.setFeerate(FeeratesPerKw.single(TestConstants.anchorOutputsFeeratePerKw * 2).copy(mempoolMinFee = FeeratePerKw(250 sat))) probe.send(peer, Peer.OpenChannel(remoteNodeId, 15000 sat, 0 msat, None, None, None, None)) val init = channel.expectMsgType[INPUT_INIT_FUNDER] - assert(init.channelType === ChannelTypes.AnchorOutputsZeroFeeHtlcTx) - assert(init.fundingAmount === 15000.sat) - assert(init.commitTxFeerate === TestConstants.anchorOutputsFeeratePerKw) - assert(init.fundingTxFeerate === feeEstimator.getFeeratePerKw(nodeParams.onChainFeeConf.feeTargets.fundingBlockTarget)) + assert(init.channelType == ChannelTypes.AnchorOutputsZeroFeeHtlcTx) + assert(init.fundingAmount == 15000.sat) + assert(init.commitTxFeerate == TestConstants.anchorOutputsFeeratePerKw) + assert(init.fundingTxFeerate == feeEstimator.getFeeratePerKw(nodeParams.onChainFeeConf.feeTargets.fundingBlockTarget)) } test("use correct final script if option_static_remotekey is negotiated", Tag("static_remotekey")) { f => @@ -445,9 +445,9 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle connect(remoteNodeId, peer, peerConnection, switchboard, remoteInit = protocol.Init(Features(StaticRemoteKey -> Mandatory))) probe.send(peer, Peer.OpenChannel(remoteNodeId, 24000 sat, 0 msat, None, None, None, None)) val init = channel.expectMsgType[INPUT_INIT_FUNDER] - assert(init.channelType === ChannelTypes.StaticRemoteKey) + assert(init.channelType == ChannelTypes.StaticRemoteKey) assert(init.localParams.walletStaticPaymentBasepoint.isDefined) - assert(init.localParams.defaultFinalScriptPubKey === Script.write(Script.pay2wpkh(init.localParams.walletStaticPaymentBasepoint.get))) + assert(init.localParams.defaultFinalScriptPubKey == Script.write(Script.pay2wpkh(init.localParams.walletStaticPaymentBasepoint.get))) } test("set origin_opt when spawning a channel") { f => @@ -456,7 +456,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle val probe = TestProbe() val channelFactory = new ChannelFactory { override def spawn(context: ActorContext, remoteNodeId: PublicKey, origin_opt: Option[ActorRef]): ActorRef = { - assert(origin_opt === Some(probe.ref)) + assert(origin_opt == Some(probe.ref)) channel.ref } } @@ -464,8 +464,8 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle connect(remoteNodeId, peer, peerConnection, switchboard) probe.send(peer, Peer.OpenChannel(remoteNodeId, 15000 sat, 100 msat, None, None, None, None)) val init = channel.expectMsgType[INPUT_INIT_FUNDER] - assert(init.fundingAmount === 15000.sat) - assert(init.pushAmount === 100.msat) + assert(init.fundingAmount == 15000.sat) + assert(init.pushAmount == 100.msat) } test("handle final channelId assigned in state DISCONNECTED") { f => @@ -475,13 +475,13 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with Paralle peer ! ConnectionDown(peerConnection.ref) probe.send(peer, Peer.GetPeerInfo(Some(probe.ref.toTyped))) val peerInfo1 = probe.expectMsgType[Peer.PeerInfo] - assert(peerInfo1.state === Peer.DISCONNECTED) - assert(peerInfo1.channels === 1) + assert(peerInfo1.state == Peer.DISCONNECTED) + assert(peerInfo1.channels == 1) peer ! ChannelIdAssigned(probe.ref, remoteNodeId, randomBytes32(), randomBytes32()) probe.send(peer, Peer.GetPeerInfo(Some(probe.ref.toTyped))) val peerInfo2 = probe.expectMsgType[Peer.PeerInfo] - assert(peerInfo2.state === Peer.DISCONNECTED) - assert(peerInfo2.channels === 2) + assert(peerInfo2.state == Peer.DISCONNECTED) + assert(peerInfo2.channels == 2) } test("notify when last channel is closed") { f => diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/io/ReconnectionTaskSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/io/ReconnectionTaskSpec.scala index cd0bd0ca1a..fec76a7a6e 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/io/ReconnectionTaskSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/io/ReconnectionTaskSpec.scala @@ -101,7 +101,7 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike peer.send(reconnectionTask, Peer.Transition(PeerNothingData, PeerDisconnectedData)) val TransitionWithData(ReconnectionTask.IDLE, ReconnectionTask.WAITING, _, _) = monitor.expectMsgType[TransitionWithData] val TransitionWithData(ReconnectionTask.WAITING, ReconnectionTask.CONNECTING, _, connectingData: ReconnectionTask.ConnectingData) = monitor.expectMsgType[TransitionWithData] - assert(connectingData.to === fakeIPAddress) + assert(connectingData.to == fakeIPAddress) val expectedNextReconnectionDelayInterval = (nodeParams.maxReconnectInterval.toSeconds / 2) to nodeParams.maxReconnectInterval.toSeconds assert(expectedNextReconnectionDelayInterval contains connectingData.nextReconnectionDelay.toSeconds) // we only reconnect once } @@ -134,13 +134,13 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val TransitionWithData(ReconnectionTask.WAITING, ReconnectionTask.CONNECTING, _, _) = monitor.expectMsgType[TransitionWithData] val TransitionWithData(ReconnectionTask.CONNECTING, ReconnectionTask.WAITING, _, waitingData1: WaitingData) = monitor.expectMsgType[TransitionWithData](60 seconds) - assert(waitingData1.nextReconnectionDelay === (waitingData0.nextReconnectionDelay * 2)) + assert(waitingData1.nextReconnectionDelay == (waitingData0.nextReconnectionDelay * 2)) probe.send(reconnectionTask, ReconnectionTask.TickReconnect) val TransitionWithData(ReconnectionTask.WAITING, ReconnectionTask.CONNECTING, _, _) = monitor.expectMsgType[TransitionWithData] val TransitionWithData(ReconnectionTask.CONNECTING, ReconnectionTask.WAITING, _, waitingData2: WaitingData) = monitor.expectMsgType[TransitionWithData](60 seconds) - assert(waitingData2.nextReconnectionDelay === (waitingData0.nextReconnectionDelay * 4)) + assert(waitingData2.nextReconnectionDelay == (waitingData0.nextReconnectionDelay * 4)) probe.send(reconnectionTask, ReconnectionTask.TickReconnect) val TransitionWithData(ReconnectionTask.WAITING, ReconnectionTask.CONNECTING, _, _) = monitor.expectMsgType[TransitionWithData] @@ -153,7 +153,7 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike // the auto reconnect kicks off again, but this time we pick up the reconnect delay where we left it val TransitionWithData(ReconnectionTask.IDLE, ReconnectionTask.WAITING, _, waitingData3: WaitingData) = monitor.expectMsgType[TransitionWithData] - assert(waitingData3.nextReconnectionDelay === (waitingData0.nextReconnectionDelay * 8)) + assert(waitingData3.nextReconnectionDelay == (waitingData0.nextReconnectionDelay * 8)) } test("all kind of connection failures should be caught by the reconnection task", Tag("auto_reconnect")) { f => @@ -235,9 +235,9 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { // tor not supported: always return clearnet addresses nodeParams.socksProxy_opt returns None - assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet)) === Some(clearnet)) - assert(ReconnectionTask.selectNodeAddress(nodeParams, List(tor)) === None) - assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet, tor)) === Some(clearnet)) + assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet)) == Some(clearnet)) + assert(ReconnectionTask.selectNodeAddress(nodeParams, List(tor)) == None) + assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet, tor)) == Some(clearnet)) } { @@ -247,9 +247,9 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike socksParams.useForIPv4 returns false socksParams.useForIPv6 returns false nodeParams.socksProxy_opt returns Some(socksParams) - assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet)) === Some(clearnet)) - assert(ReconnectionTask.selectNodeAddress(nodeParams, List(tor)) === Some(tor)) - assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet, tor)) === Some(clearnet)) + assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet)) == Some(clearnet)) + assert(ReconnectionTask.selectNodeAddress(nodeParams, List(tor)) == Some(tor)) + assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet, tor)) == Some(clearnet)) } { @@ -259,9 +259,9 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike socksParams.useForIPv4 returns true socksParams.useForIPv6 returns true nodeParams.socksProxy_opt returns Some(socksParams) - assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet)) === Some(clearnet)) - assert(ReconnectionTask.selectNodeAddress(nodeParams, List(tor)) === Some(tor)) - assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet, tor)) === Some(tor)) + assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet)) == Some(clearnet)) + assert(ReconnectionTask.selectNodeAddress(nodeParams, List(tor)) == Some(tor)) + assert(ReconnectionTask.selectNodeAddress(nodeParams, List(clearnet, tor)) == Some(tor)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/io/SwitchboardSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/io/SwitchboardSpec.scala index c1f87f42c6..c20f33814b 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/io/SwitchboardSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/io/SwitchboardSpec.scala @@ -42,8 +42,8 @@ class SwitchboardSpec extends TestKitBaseClass with AnyFunSuiteLike { probe.expectMsg(remoteNodeId) peer.expectMsg(Peer.Init(Set.empty)) val connect = peer.expectMsgType[Peer.Connect] - assert(connect.nodeId === remoteNodeId) - assert(connect.address_opt === None) + assert(connect.nodeId == remoteNodeId) + assert(connect.address_opt == None) } test("disconnect from peers") { @@ -58,7 +58,7 @@ class SwitchboardSpec extends TestKitBaseClass with AnyFunSuiteLike { val unknownNodeId = randomKey().publicKey probe.send(switchboard, Peer.Disconnect(unknownNodeId)) - assert(probe.expectMsgType[Status.Failure].cause.getMessage === s"peer $unknownNodeId not found") + assert(probe.expectMsgType[Status.Failure].cause.getMessage == s"peer $unknownNodeId not found") probe.send(switchboard, Peer.Disconnect(remoteNodeId)) peer.expectMsg(Peer.Disconnect(remoteNodeId)) } @@ -68,9 +68,9 @@ class SwitchboardSpec extends TestKitBaseClass with AnyFunSuiteLike { val switchboard = TestActorRef(new Switchboard(nodeParams, FakePeerFactory(probe, peer))) switchboard ! PeerConnection.Authenticated(peerConnection.ref, remoteNodeId) val initConnection = peerConnection.expectMsgType[PeerConnection.InitializeConnection] - assert(initConnection.chainHash === nodeParams.chainHash) - assert(initConnection.features === expectedFeatures) - assert(initConnection.doSync === expectedSync) + assert(initConnection.chainHash == nodeParams.chainHash) + assert(initConnection.features == expectedFeatures) + assert(initConnection.doSync == expectedSync) } test("sync if no whitelist is defined and peer has channels") { @@ -90,16 +90,16 @@ class SwitchboardSpec extends TestKitBaseClass with AnyFunSuiteLike { switchboard ! ChannelIdAssigned(TestProbe().ref, remoteNodeId, randomBytes32(), randomBytes32()) switchboard ! PeerConnection.Authenticated(peerConnection.ref, remoteNodeId) val initConnection1 = peerConnection.expectMsgType[PeerConnection.InitializeConnection] - assert(initConnection1.chainHash === nodeParams.chainHash) - assert(initConnection1.features === nodeParams.features.initFeatures()) + assert(initConnection1.chainHash == nodeParams.chainHash) + assert(initConnection1.features == nodeParams.features.initFeatures()) assert(initConnection1.doSync) // We don't have channels with our peer, so we won't trigger a sync when connecting. switchboard ! LastChannelClosed(peer.ref, remoteNodeId) switchboard ! PeerConnection.Authenticated(peerConnection.ref, remoteNodeId) val initConnection2 = peerConnection.expectMsgType[PeerConnection.InitializeConnection] - assert(initConnection2.chainHash === nodeParams.chainHash) - assert(initConnection2.features === nodeParams.features.initFeatures()) + assert(initConnection2.chainHash == nodeParams.chainHash) + assert(initConnection2.features == nodeParams.features.initFeatures()) assert(!initConnection2.doSync) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/message/OnionMessagesSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/message/OnionMessagesSpec.scala index 606572f74f..84f9968245 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/message/OnionMessagesSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/message/OnionMessagesSpec.scala @@ -224,11 +224,11 @@ class OnionMessagesSpec extends AnyFunSuite { val blindingOverride = randomKey() val destination = randomKey() val replyPath = buildRoute(blindingOverride, IntermediateNode(destination.publicKey) :: Nil, Recipient(destination.publicKey, pathId = Some(hex"01234567"))) - assert(replyPath.blindingKey === blindingOverride.publicKey) - assert(replyPath.introductionNodeId === destination.publicKey) + assert(replyPath.blindingKey == blindingOverride.publicKey) + assert(replyPath.introductionNodeId == destination.publicKey) val (nextNodeId, message) = buildMessage(sessionKey, blindingSecret, Nil, BlindedPath(replyPath), Nil) - assert(nextNodeId === destination.publicKey) - assert(message.blindingKey === blindingOverride.publicKey) // blindingSecret was not used as the replyPath was used as is + assert(nextNodeId == destination.publicKey) + assert(message.blindingKey == blindingOverride.publicKey) // blindingSecret was not used as the replyPath was used as is process(destination, message) match { case ReceiveMessage(_, Some(pathId)) if pathId == hex"01234567" => () diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/message/PostmanSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/message/PostmanSpec.scala index 2bd30db61a..66297b5535 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/message/PostmanSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/message/PostmanSpec.scala @@ -62,8 +62,8 @@ class PostmanSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("applicat postman ! SendMessage(recipient, messageExpectingReply, Some(pathId), messageRecipient.ref, 100 millis) val RelayMessage(messageId, _, nextNodeId, message, _, _) = switchboard.expectMessageType[RelayMessage] - assert(nextNodeId === recipient) - assert(message === messageExpectingReply) + assert(nextNodeId == recipient) + assert(message == messageExpectingReply) postman ! SendingStatus(Sent(messageId)) testKit.system.eventStream ! EventStream.Publish(ReceiveMessage(payload, Some(pathId))) testKit.system.eventStream ! EventStream.Publish(ReceiveMessage(payload, Some(pathId))) @@ -84,8 +84,8 @@ class PostmanSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("applicat postman ! SendMessage(recipient, messageExpectingReply, Some(pathId), messageRecipient.ref, 100 millis) val RelayMessage(messageId, _, nextNodeId, message, _, _) = switchboard.expectMessageType[RelayMessage] - assert(nextNodeId === recipient) - assert(message === messageExpectingReply) + assert(nextNodeId == recipient) + assert(message == messageExpectingReply) postman ! SendingStatus(Disconnected(messageId)) messageRecipient.expectMessage(SendingStatus(Disconnected(messageId))) @@ -105,8 +105,8 @@ class PostmanSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("applicat postman ! SendMessage(recipient, messageExpectingReply, Some(pathId), messageRecipient.ref, 1 millis) val RelayMessage(messageId, _, nextNodeId, message, _, _) = switchboard.expectMessageType[RelayMessage] - assert(nextNodeId === recipient) - assert(message === messageExpectingReply) + assert(nextNodeId == recipient) + assert(message == messageExpectingReply) postman ! SendingStatus(Sent(messageId)) messageRecipient.expectMessage(NoReply) @@ -125,8 +125,8 @@ class PostmanSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("applicat postman ! SendMessage(recipient, messageExpectingReply, None, messageRecipient.ref, 100 millis) val RelayMessage(messageId, _, nextNodeId, message, _, _) = switchboard.expectMessageType[RelayMessage] - assert(nextNodeId === recipient) - assert(message === messageExpectingReply) + assert(nextNodeId == recipient) + assert(message == messageExpectingReply) postman ! SendingStatus(Sent(messageId)) messageRecipient.expectMessage(SendingStatus(Sent(messageId))) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala index d68870976a..3c50b23fe9 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala @@ -82,37 +82,37 @@ class Bolt11InvoiceSpec extends AnyFunSuite { } test("check minimal unit is used") { - assert('p' === Amount.unit(1 msat)) - assert('p' === Amount.unit(99 msat)) - assert('n' === Amount.unit(100 msat)) - assert('p' === Amount.unit(101 msat)) - assert('n' === Amount.unit((1 sat).toMilliSatoshi)) - assert('u' === Amount.unit((100 sat).toMilliSatoshi)) - assert('n' === Amount.unit((101 sat).toMilliSatoshi)) - assert('u' === Amount.unit((1155400 sat).toMilliSatoshi)) - assert('m' === Amount.unit((1 millibtc).toMilliSatoshi)) - assert('m' === Amount.unit((10 millibtc).toMilliSatoshi)) - assert('m' === Amount.unit((1 btc).toMilliSatoshi)) + assert('p' == Amount.unit(1 msat)) + assert('p' == Amount.unit(99 msat)) + assert('n' == Amount.unit(100 msat)) + assert('p' == Amount.unit(101 msat)) + assert('n' == Amount.unit((1 sat).toMilliSatoshi)) + assert('u' == Amount.unit((100 sat).toMilliSatoshi)) + assert('n' == Amount.unit((101 sat).toMilliSatoshi)) + assert('u' == Amount.unit((1155400 sat).toMilliSatoshi)) + assert('m' == Amount.unit((1 millibtc).toMilliSatoshi)) + assert('m' == Amount.unit((10 millibtc).toMilliSatoshi)) + assert('m' == Amount.unit((1 btc).toMilliSatoshi)) } test("decode empty amount") { - assert(Amount.decode("") === Success(None)) - assert(Amount.decode("0") === Success(None)) - assert(Amount.decode("0p") === Success(None)) - assert(Amount.decode("0n") === Success(None)) - assert(Amount.decode("0u") === Success(None)) - assert(Amount.decode("0m") === Success(None)) + assert(Amount.decode("") == Success(None)) + assert(Amount.decode("0") == Success(None)) + assert(Amount.decode("0p") == Success(None)) + assert(Amount.decode("0n") == Success(None)) + assert(Amount.decode("0u") == Success(None)) + assert(Amount.decode("0m") == Success(None)) } test("check that we can still decode non-minimal amount encoding") { - assert(Amount.decode("1000u") === Success(Some(100000000 msat))) - assert(Amount.decode("1000000n") === Success(Some(100000000 msat))) - assert(Amount.decode("1000000000p") === Success(Some(100000000 msat))) + assert(Amount.decode("1000u") == Success(Some(100000000 msat))) + assert(Amount.decode("1000000n") == Success(Some(100000000 msat))) + assert(Amount.decode("1000000000p") == Success(Some(100000000 msat))) } test("data string -> bitvector") { - assert(string2Bits("p") === bin"00001") - assert(string2Bits("pz") === bin"0000100010") + assert(string2Bits("p") == bin"00001") + assert(string2Bits("pz") == bin"0000100010") } test("minimal length long, left-padded to be multiple of 5") { @@ -136,13 +136,13 @@ class Bolt11InvoiceSpec extends AnyFunSuite { assert(invoice.prefix == "lnbc") assert(invoice.amount_opt.isEmpty) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.paymentSecret.map(_.bytes) === Some(hex"1111111111111111111111111111111111111111111111111111111111111111")) - assert(invoice.features === Features(Features.VariableLengthOnion -> Mandatory, Features.PaymentSecret -> Mandatory)) + assert(invoice.paymentSecret.map(_.bytes) == Some(hex"1111111111111111111111111111111111111111111111111111111111111111")) + assert(invoice.features == Features(Features.VariableLengthOnion -> Mandatory, Features.PaymentSecret -> Mandatory)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Left("Please consider supporting this project")) - assert(invoice.fallbackAddress() === None) - assert(invoice.tags.size === 4) + assert(invoice.fallbackAddress() == None) + assert(invoice.tags.size == 4) assert(invoice.sign(priv).toString == ref) } @@ -150,14 +150,14 @@ class Bolt11InvoiceSpec extends AnyFunSuite { val ref = "lnbc2500u1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpu9qrsgquk0rl77nj30yxdy8j9vdx85fkpmdla2087ne0xh8nhedh8w27kyke0lp53ut353s06fv3qfegext0eh0ymjpf39tuven09sam30g4vgpfna3rh" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lnbc") - assert(invoice.amount_opt === Some(250000000 msat)) + assert(invoice.amount_opt == Some(250000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(Features.VariableLengthOnion -> Mandatory, Features.PaymentSecret -> Mandatory)) + assert(invoice.features == Features(Features.VariableLengthOnion -> Mandatory, Features.PaymentSecret -> Mandatory)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Left("1 cup coffee")) - assert(invoice.fallbackAddress() === None) - assert(invoice.tags.size === 5) + assert(invoice.fallbackAddress() == None) + assert(invoice.tags.size == 5) assert(invoice.sign(priv).toString == ref) } @@ -165,14 +165,14 @@ class Bolt11InvoiceSpec extends AnyFunSuite { val ref = "lnbc2500u1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpquwpc4curk03c9wlrswe78q4eyqc7d8d0xqzpu9qrsgqhtjpauu9ur7fw2thcl4y9vfvh4m9wlfyz2gem29g5ghe2aak2pm3ps8fdhtceqsaagty2vph7utlgj48u0ged6a337aewvraedendscp573dxr" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lnbc") - assert(invoice.amount_opt === Some(250000000 msat)) + assert(invoice.amount_opt == Some(250000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Left("ナンセンス 1杯")) - assert(invoice.fallbackAddress() === None) - assert(invoice.tags.size === 5) + assert(invoice.fallbackAddress() == None) + assert(invoice.tags.size == 5) assert(invoice.sign(priv).toString == ref) } @@ -180,14 +180,14 @@ class Bolt11InvoiceSpec extends AnyFunSuite { val ref = "lnbc20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqs9qrsgq7ea976txfraylvgzuxs8kgcw23ezlrszfnh8r6qtfpr6cxga50aj6txm9rxrydzd06dfeawfk6swupvz4erwnyutnjq7x39ymw6j38gp7ynn44" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lnbc") - assert(invoice.amount_opt === Some(2000000000 msat)) + assert(invoice.amount_opt == Some(2000000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Right(Crypto.sha256(ByteVector("One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon".getBytes)))) - assert(invoice.fallbackAddress() === None) - assert(invoice.tags.size === 4) + assert(invoice.fallbackAddress() == None) + assert(invoice.tags.size == 4) assert(invoice.sign(priv).toString == ref) } @@ -195,13 +195,13 @@ class Bolt11InvoiceSpec extends AnyFunSuite { val ref = "lntb20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygshp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfpp3x9et2e20v6pu37c5d9vax37wxq72un989qrsgqdj545axuxtnfemtpwkc45hx9d2ft7x04mt8q7y6t0k2dge9e7h8kpy9p34ytyslj3yu569aalz2xdk8xkd7ltxqld94u8h2esmsmacgpghe9k8" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lntb") - assert(invoice.amount_opt === Some(2000000000 msat)) + assert(invoice.amount_opt == Some(2000000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Right(Crypto.sha256(ByteVector.view("One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon".getBytes)))) - assert(invoice.fallbackAddress() === Some("mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP")) + assert(invoice.fallbackAddress() == Some("mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP")) assert(invoice.tags.size == 5) assert(invoice.sign(priv).toString == ref) } @@ -210,14 +210,14 @@ class Bolt11InvoiceSpec extends AnyFunSuite { val ref = "lnbc20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqsfpp3qjmp7lwpagxun9pygexvgpjdc4jdj85fr9yq20q82gphp2nflc7jtzrcazrra7wwgzxqc8u7754cdlpfrmccae92qgzqvzq2ps8pqqqqqqpqqqqq9qqqvpeuqafqxu92d8lr6fvg0r5gv0heeeqgcrqlnm6jhphu9y00rrhy4grqszsvpcgpy9qqqqqqgqqqqq7qqzq9qrsgqdfjcdk6w3ak5pca9hwfwfh63zrrz06wwfya0ydlzpgzxkn5xagsqz7x9j4jwe7yj7vaf2k9lqsdk45kts2fd0fkr28am0u4w95tt2nsq76cqw0" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lnbc") - assert(invoice.amount_opt === Some(2000000000 msat)) + assert(invoice.amount_opt == Some(2000000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Right(Crypto.sha256(ByteVector.view("One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon".getBytes)))) - assert(invoice.fallbackAddress() === Some("1RustyRX2oai4EYYDpQGWvEL62BBGqN9T")) - assert(invoice.routingInfo === List(List( + assert(invoice.fallbackAddress() == Some("1RustyRX2oai4EYYDpQGWvEL62BBGqN9T")) + assert(invoice.routingInfo == List(List( ExtraHop(PublicKey(hex"029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255"), ShortChannelId("66051x263430x1800"), 1 msat, 20, CltvExpiryDelta(3)), ExtraHop(PublicKey(hex"039e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255"), ShortChannelId("197637x395016x2314"), 2 msat, 30, CltvExpiryDelta(4)) ))) @@ -229,13 +229,13 @@ class Bolt11InvoiceSpec extends AnyFunSuite { val ref = "lnbc20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygshp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppj3a24vwu6r8ejrss3axul8rxldph2q7z99qrsgqz6qsgww34xlatfj6e3sngrwfy3ytkt29d2qttr8qz2mnedfqysuqypgqex4haa2h8fx3wnypranf3pdwyluftwe680jjcfp438u82xqphf75ym" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lnbc") - assert(invoice.amount_opt === Some(2000000000 msat)) + assert(invoice.amount_opt == Some(2000000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Right(Crypto.sha256(ByteVector.view("One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon".getBytes)))) - assert(invoice.fallbackAddress() === Some("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX")) + assert(invoice.fallbackAddress() == Some("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX")) assert(invoice.tags.size == 5) assert(invoice.sign(priv).toString == ref) } @@ -244,13 +244,13 @@ class Bolt11InvoiceSpec extends AnyFunSuite { val ref = "lnbc20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygshp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppqw508d6qejxtdg4y5r3zarvary0c5xw7k9qrsgqt29a0wturnys2hhxpner2e3plp6jyj8qx7548zr2z7ptgjjc7hljm98xhjym0dg52sdrvqamxdezkmqg4gdrvwwnf0kv2jdfnl4xatsqmrnsse" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lnbc") - assert(invoice.amount_opt === Some(2000000000 msat)) + assert(invoice.amount_opt == Some(2000000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Right(Crypto.sha256(ByteVector.view("One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon".getBytes)))) - assert(invoice.fallbackAddress() === Some("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4")) + assert(invoice.fallbackAddress() == Some("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4")) assert(invoice.tags.size == 5) assert(invoice.sign(priv).toString == ref) } @@ -259,14 +259,14 @@ class Bolt11InvoiceSpec extends AnyFunSuite { val ref = "lnbc20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygshp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfp4qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q9qrsgq9vlvyj8cqvq6ggvpwd53jncp9nwc47xlrsnenq2zp70fq83qlgesn4u3uyf4tesfkkwwfg3qs54qe426hp3tz7z6sweqdjg05axsrjqp9yrrwc" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lnbc") - assert(invoice.amount_opt === Some(2000000000 msat)) + assert(invoice.amount_opt == Some(2000000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) assert(!invoice.features.hasFeature(BasicMultiPartPayment)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Right(Crypto.sha256(ByteVector.view("One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon".getBytes)))) - assert(invoice.fallbackAddress() === Some("bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3")) + assert(invoice.fallbackAddress() == Some("bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3")) assert(invoice.tags.size == 5) assert(invoice.sign(priv).toString == ref) } @@ -275,15 +275,15 @@ class Bolt11InvoiceSpec extends AnyFunSuite { val ref = "lnbc20m1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygscqpvpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqsfp4qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q9qrsgq999fraffdzl6c8j7qd325dfurcq7vl0mfkdpdvve9fy3hy4lw0x9j3zcj2qdh5e5pyrp6cncvmxrhchgey64culwmjtw9wym74xm6xqqevh9r0" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lnbc") - assert(invoice.amount_opt === Some(2000000000 msat)) + assert(invoice.amount_opt == Some(2000000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) assert(!invoice.features.hasFeature(BasicMultiPartPayment)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) assert(invoice.description == Right(Crypto.sha256(ByteVector.view("One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon".getBytes)))) - assert(invoice.fallbackAddress() === Some("bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3")) - assert(invoice.minFinalCltvExpiryDelta === CltvExpiryDelta(12)) + assert(invoice.fallbackAddress() == Some("bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3")) + assert(invoice.minFinalCltvExpiryDelta == CltvExpiryDelta(12)) assert(invoice.tags.size == 6) assert(invoice.sign(priv).toString == ref) } @@ -299,71 +299,71 @@ class Bolt11InvoiceSpec extends AnyFunSuite { for (ref <- refs) { val Success(invoice) = Bolt11Invoice.fromString(ref) - assert(invoice.prefix === "lnbc") - assert(invoice.amount_opt === Some(2500000000L msat)) - assert(invoice.paymentHash.bytes === hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.paymentSecret === Some(ByteVector32(hex"1111111111111111111111111111111111111111111111111111111111111111"))) - assert(invoice.createdAt === TimestampSecond(1496314658L)) - assert(invoice.nodeId === PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) - assert(invoice.description === Left("coffee beans")) - assert(features2bits(invoice.features) === bin"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000100000000") + assert(invoice.prefix == "lnbc") + assert(invoice.amount_opt == Some(2500000000L msat)) + assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") + assert(invoice.paymentSecret == Some(ByteVector32(hex"1111111111111111111111111111111111111111111111111111111111111111"))) + assert(invoice.createdAt == TimestampSecond(1496314658L)) + assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) + assert(invoice.description == Left("coffee beans")) + assert(features2bits(invoice.features) == bin"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000100000000") assert(!invoice.features.hasFeature(BasicMultiPartPayment)) assert(invoice.features.hasFeature(PaymentSecret, Some(Mandatory))) assert(!invoice.features.hasFeature(TrampolinePaymentPrototype)) assert(TestConstants.Alice.nodeParams.features.invoiceFeatures().areSupported(invoice.features)) - assert(invoice.sign(priv).toString === ref.toLowerCase) + assert(invoice.sign(priv).toString == ref.toLowerCase) } } test("On mainnet, please send $30 for coffee beans to the same peer, which supports features 8, 14, 99 and 100, using secret 0x1111111111111111111111111111111111111111111111111111111111111111") { val ref = "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqqsgqtqyx5vggfcsll4wu246hz02kp85x4katwsk9639we5n5yngc3yhqkm35jnjw4len8vrnqnf5ejh0mzj9n3vz2px97evektfm2l6wqccp3y7372" val Success(invoice) = Bolt11Invoice.fromString(ref) - assert(invoice.prefix === "lnbc") - assert(invoice.amount_opt === Some(2500000000L msat)) - assert(invoice.paymentHash.bytes === hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.paymentSecret === Some(ByteVector32(hex"1111111111111111111111111111111111111111111111111111111111111111"))) - assert(invoice.createdAt === TimestampSecond(1496314658L)) - assert(invoice.nodeId === PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) - assert(invoice.description === Left("coffee beans")) + assert(invoice.prefix == "lnbc") + assert(invoice.amount_opt == Some(2500000000L msat)) + assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") + assert(invoice.paymentSecret == Some(ByteVector32(hex"1111111111111111111111111111111111111111111111111111111111111111"))) + assert(invoice.createdAt == TimestampSecond(1496314658L)) + assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) + assert(invoice.description == Left("coffee beans")) assert(invoice.fallbackAddress().isEmpty) - assert(features2bits(invoice.features) === bin"000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000100000000") + assert(features2bits(invoice.features) == bin"000011000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000100000000") assert(!invoice.features.hasFeature(BasicMultiPartPayment)) assert(invoice.features.hasFeature(PaymentSecret, Some(Mandatory))) assert(!invoice.features.hasFeature(TrampolinePaymentPrototype)) assert(!TestConstants.Alice.nodeParams.features.invoiceFeatures().areSupported(invoice.features)) - assert(invoice.sign(priv).toString === ref) + assert(invoice.sign(priv).toString == ref) } test("On mainnet, please send 0.00967878534 BTC for a list of items within one week, amount in pico-BTC") { val ref = "lnbc9678785340p1pwmna7lpp5gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0sd8dgfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khxsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygsxqyjw5qcqp2rzjq0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9q9qrsgqrvgkpnmps664wgkp43l22qsgdw4ve24aca4nymnxddlnp8vh9v2sdxlu5ywdxefsfvm0fq3sesf08uf6q9a2ke0hc9j6z6wlxg5z5kqpu2v9wz" val Success(invoice) = Bolt11Invoice.fromString(ref) - assert(invoice.prefix === "lnbc") - assert(invoice.amount_opt === Some(967878534 msat)) - assert(invoice.paymentHash.bytes === hex"462264ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) + assert(invoice.prefix == "lnbc") + assert(invoice.amount_opt == Some(967878534 msat)) + assert(invoice.paymentHash.bytes == hex"462264ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f") + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory)) assert(TestConstants.Alice.nodeParams.features.invoiceFeatures().areSupported(invoice.features)) - assert(invoice.createdAt === TimestampSecond(1572468703L)) - assert(invoice.nodeId === PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) - assert(invoice.description === Left("Blockstream Store: 88.85 USD for Blockstream Ledger Nano S x 1, \"Back In My Day\" Sticker x 2, \"I Got Lightning Working\" Sticker x 2 and 1 more items")) + assert(invoice.createdAt == TimestampSecond(1572468703L)) + assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) + assert(invoice.description == Left("Blockstream Store: 88.85 USD for Blockstream Ledger Nano S x 1, \"Back In My Day\" Sticker x 2, \"I Got Lightning Working\" Sticker x 2 and 1 more items")) assert(invoice.fallbackAddress().isEmpty) - assert(invoice.relativeExpiry === 604800.seconds) - assert(invoice.minFinalCltvExpiryDelta === CltvExpiryDelta(10)) - assert(invoice.routingInfo === Seq(Seq(ExtraHop(PublicKey(hex"03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7"), ShortChannelId("589390x3312x1"), 1000 msat, 2500, CltvExpiryDelta(40))))) - assert(invoice.sign(priv).toString === ref) + assert(invoice.relativeExpiry == 604800.seconds) + assert(invoice.minFinalCltvExpiryDelta == CltvExpiryDelta(10)) + assert(invoice.routingInfo == Seq(Seq(ExtraHop(PublicKey(hex"03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7"), ShortChannelId("589390x3312x1"), 1000 msat, 2500, CltvExpiryDelta(40))))) + assert(invoice.sign(priv).toString == ref) } test("On mainnet, please send 0.01 BTC with payment metadata 0x01fafaf0") { val ref = "lnbc10m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp9wpshjmt9de6zqmt9w3skgct5vysxjmnnd9jx2mq8q8a04uqsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q2gqqqqqqsgq7hf8he7ecf7n4ffphs6awl9t6676rrclv9ckg3d3ncn7fct63p6s365duk5wrk202cfy3aj5xnnp5gs3vrdvruverwwq7yzhkf5a3xqpd05wjc" val Success(invoice) = Bolt11Invoice.fromString(ref) assert(invoice.prefix == "lnbc") - assert(invoice.amount_opt === Some(1000000000 msat)) + assert(invoice.amount_opt == Some(1000000000 msat)) assert(invoice.paymentHash.bytes == hex"0001020304050607080900010203040506070809000102030405060708090102") - assert(invoice.features === Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory, PaymentMetadata -> Mandatory)) + assert(invoice.features == Features(VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory, PaymentMetadata -> Mandatory)) assert(invoice.createdAt == TimestampSecond(1496314658L)) assert(invoice.nodeId == PublicKey(hex"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad")) - assert(invoice.paymentSecret === Some(ByteVector32(hex"1111111111111111111111111111111111111111111111111111111111111111"))) + assert(invoice.paymentSecret == Some(ByteVector32(hex"1111111111111111111111111111111111111111111111111111111111111111"))) assert(invoice.description == Left("payment metadata inside")) - assert(invoice.paymentMetadata === Some(hex"01fafaf0")) + assert(invoice.paymentMetadata == Some(hex"01fafaf0")) assert(invoice.tags.size == 5) assert(invoice.sign(priv).toString == ref) } @@ -401,7 +401,7 @@ class Bolt11InvoiceSpec extends AnyFunSuite { assert(field1 == field) val invoice = Bolt11Invoice(chainHash = Block.LivenetGenesisBlock.hash, amount = Some(123 msat), paymentHash = ByteVector32(ByteVector.fill(32)(1)), privateKey = priv, description = Left("Some invoice"), minFinalCltvExpiryDelta = CltvExpiryDelta(18), expirySeconds = Some(123456), timestamp = 12345 unixsec) - assert(invoice.minFinalCltvExpiryDelta === CltvExpiryDelta(18)) + assert(invoice.minFinalCltvExpiryDelta == CltvExpiryDelta(18)) val serialized = invoice.toString val Success(pr1) = Bolt11Invoice.fromString(serialized) assert(invoice == pr1) @@ -443,9 +443,9 @@ class Bolt11InvoiceSpec extends AnyFunSuite { for ((input, value) <- inputs) { val data = string2Bits(input) val decoded = Codecs.taggedFieldCodec.decode(data).require.value - assert(decoded === value) + assert(decoded == value) val encoded = Codecs.taggedFieldCodec.encode(value).require - assert(encoded === data) + assert(encoded == data) } } @@ -457,8 +457,8 @@ class Bolt11InvoiceSpec extends AnyFunSuite { test("Pay 1 BTC without multiplier") { val ref = "lnbc1000m1pdkmqhusp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5n2ees808r98m0rh4472yyth0c5fptzcxmexcjznrzmq8xald0cgqdqsf4ujqarfwqsxymmccqp2pv37ezvhth477nu0yhhjlcry372eef57qmldhreqnr0kx82jkupp3n7nw42u3kdyyjskdr8jhjy2vugr3skdmy8ersft36969xplkxsp2v7c58" val Success(invoice) = Bolt11Invoice.fromString(ref) - assert(invoice.amount_opt === Some(100000000000L msat)) - assert(features2bits(invoice.features) === BitVector.empty) + assert(invoice.amount_opt == Some(100000000000L msat)) + assert(features2bits(invoice.features) == BitVector.empty) } test("supported invoice features") { @@ -486,8 +486,8 @@ class Bolt11InvoiceSpec extends AnyFunSuite { for ((features, res) <- featureBits) { val invoice = createInvoiceUnsafe(Block.LivenetGenesisBlock.hash, Some(123 msat), ByteVector32.One, priv, Left("Some invoice"), CltvExpiryDelta(18), features = features) - assert(Result(invoice.features.hasFeature(BasicMultiPartPayment), invoice.features.hasFeature(PaymentSecret, Some(Mandatory)), nodeParams.features.invoiceFeatures().areSupported(invoice.features)) === res) - assert(Bolt11Invoice.fromString(invoice.toString).get === invoice) + assert(Result(invoice.features.hasFeature(BasicMultiPartPayment), invoice.features.hasFeature(PaymentSecret, Some(Mandatory)), nodeParams.features.invoiceFeatures().areSupported(invoice.features)) == res) + assert(Bolt11Invoice.fromString(invoice.toString).get == invoice) } } @@ -504,22 +504,22 @@ class Bolt11InvoiceSpec extends AnyFunSuite { ) for ((bitmask, featureBytes) <- testCases) { - assert(Features(bitmask).toByteVector === featureBytes) + assert(Features(bitmask).toByteVector == featureBytes) } } test("payment secret") { val invoice = Bolt11Invoice(Block.LivenetGenesisBlock.hash, Some(123 msat), ByteVector32.One, priv, Left("Some invoice"), CltvExpiryDelta(18)) assert(invoice.paymentSecret.isDefined) - assert(invoice.features === Features(PaymentSecret -> Mandatory, VariableLengthOnion -> Mandatory)) + assert(invoice.features == Features(PaymentSecret -> Mandatory, VariableLengthOnion -> Mandatory)) assert(invoice.features.hasFeature(PaymentSecret, Some(Mandatory))) val Success(pr1) = Bolt11Invoice.fromString(invoice.toString) - assert(pr1.paymentSecret === invoice.paymentSecret) + assert(pr1.paymentSecret == invoice.paymentSecret) val Success(pr2) = Bolt11Invoice.fromString("lnbc40n1pw9qjvwpp5qq3w2ln6krepcslqszkrsfzwy49y0407hvks30ec6pu9s07jur3sdpstfshq5n9v9jzucm0d5s8vmm5v5s8qmmnwssyj3p6yqenwdencqzysxqrrss7ju0s4dwx6w8a95a9p2xc5vudl09gjl0w2n02sjrvffde632nxwh2l4w35nqepj4j5njhh4z65wyfc724yj6dn9wajvajfn5j7em6wsq2elakl") assert(!pr2.features.hasFeature(PaymentSecret, Some(Mandatory))) - assert(pr2.paymentSecret === None) + assert(pr2.paymentSecret == None) // An invoice that sets the payment secret feature bit must provide a payment secret. assert(Bolt11Invoice.fromString("lnbc1230p1pwljzn3pp5qyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdq52dhk6efqd9h8vmmfvdjs9qypqsqylvwhf7xlpy6xpecsnpcjjuuslmzzgeyv90mh7k7vs88k2dkxgrkt75qyfjv5ckygw206re7spga5zfd4agtdvtktxh5pkjzhn9dq2cqz9upw7").isFailure) @@ -615,16 +615,16 @@ class Bolt11InvoiceSpec extends AnyFunSuite { for ((req, nodeId) <- requests) { val Success(invoice) = Bolt11Invoice.fromString(req) - assert(invoice.nodeId === nodeId) - assert(invoice.toString === req) + assert(invoice.nodeId == nodeId) + assert(invoice.toString == req) } } test("no unknown feature in invoice") { assert(TestConstants.Alice.nodeParams.features.invoiceFeatures().unknown.nonEmpty) val invoice = Bolt11Invoice(Block.LivenetGenesisBlock.hash, Some(123 msat), ByteVector32.One, priv, Left("Some invoice"), CltvExpiryDelta(18), features = TestConstants.Alice.nodeParams.features.invoiceFeatures()) - assert(invoice.features === Features(PaymentSecret -> Mandatory, BasicMultiPartPayment -> Optional, PaymentMetadata -> Optional, VariableLengthOnion -> Mandatory)) - assert(Bolt11Invoice.fromString(invoice.toString).get === invoice) + assert(invoice.features == Features(PaymentSecret -> Mandatory, BasicMultiPartPayment -> Optional, PaymentMetadata -> Optional, VariableLengthOnion -> Mandatory)) + assert(Bolt11Invoice.fromString(invoice.toString).get == invoice) } test("Invoices can't have high features"){ diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt12InvoiceSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt12InvoiceSpec.scala index 4808e268af..5cfddb4c22 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt12InvoiceSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt12InvoiceSpec.scala @@ -49,7 +49,7 @@ class Bolt12InvoiceSpec extends AnyFunSuite { assert(invoice.isValidFor(offer, request)) assert(invoice.checkSignature()) assert(!invoice.checkRefundSignature()) - assert(Bolt12Invoice.fromString(invoice.toString).get.toString === invoice.toString) + assert(Bolt12Invoice.fromString(invoice.toString).get.toString == invoice.toString) // changing signature makes check fail val withInvalidSignature = Bolt12Invoice(TlvStream(invoice.records.records.map { case Signature(_) => Signature(randomBytes64()) case x => x }, invoice.records.unknown), None) assert(!withInvalidSignature.checkSignature()) @@ -97,7 +97,7 @@ class Bolt12InvoiceSpec extends AnyFunSuite { val (nodeKey, payerKey, chain) = (randomKey(), randomKey(), randomBytes32()) val offer = Offer(Some(15000 msat), "test offer", nodeKey.publicKey, Features(VariableLengthOnion -> Mandatory), chain) val request = InvoiceRequest(offer, 15000 msat, 1, Features(VariableLengthOnion -> Mandatory), payerKey, chain) - assert(request.quantity_opt === None) // when paying for a single item, the quantity field must not be present + assert(request.quantity_opt == None) // when paying for a single item, the quantity field must not be present val invoice = Bolt12Invoice(offer, request, randomBytes32(), nodeKey, Features(VariableLengthOnion -> Mandatory, BasicMultiPartPayment -> Optional)) assert(invoice.isValidFor(offer, request)) val withInvalidFeatures = signInvoice(Bolt12Invoice(TlvStream(invoice.records.records.map { case FeaturesTlv(_) => FeaturesTlv(Features(VariableLengthOnion -> Mandatory, BasicMultiPartPayment -> Mandatory)) case x => x }.toSeq), None), nodeKey) @@ -241,9 +241,9 @@ class Bolt12InvoiceSpec extends AnyFunSuite { val nodeKey = PrivateKey(hex"c6a75116a91dc5ff741b079c32c8ce7544656b98f047fb0c0fa011bfb2bb3c05") val payerKey = PrivateKey(hex"7dd30ec116470c5f7f00af2c7e84968e28cdb43083b33ee832decbe73ec07f1a") val Success(offer) = Offer.decode("lno1qgsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqgqvqcdgq2pd3xzumfvvsx7enxv4epug9kku8f4e9nuef5lv59yrkdc24t5mtrym62cg085w5wtqkp0rsuly") - assert(offer.amount === Some(100_000 msat)) - assert(offer.nodeIdXOnly === xOnlyPublicKey(nodeKey.publicKey)) - assert(offer.chains === Seq(Block.TestnetGenesisBlock.hash)) + assert(offer.amount == Some(100_000 msat)) + assert(offer.nodeIdXOnly == xOnlyPublicKey(nodeKey.publicKey)) + assert(offer.chains == Seq(Block.TestnetGenesisBlock.hash)) val request = InvoiceRequest(offer, 100_000 msat, 1, Features.empty, payerKey, Block.TestnetGenesisBlock.hash) val Success(invoice) = Bolt12Invoice.fromString("lni1qvsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqyyp53zuupqkwxpmdq0tjg58ntat5ujpejlvyn92r0l5xzh4wru8e5zzqrqxr2qzstvfshx6tryphkven9wgxqq83qk6msaxhyk0n9xnajs5swehp24wndvvn0ftppu7363evzc9uwrnujvg95tuyy05nqkcdetsaljgq4u6789jllc54qrpjrzzn3c38dj3tscu5qgcs2y4lj5gqlvq50uu7sce478j3j0l599nxfs6svx2cfefgn4a0675893wtzuckqfwlcrcq0qspa9zynlpdk9zzechehkemgaksklylxhr7yfjfx6h696th327nm4nsf52xzq0ukchx69g00c4vvk6kzc5jyklneyy05l9tef7a5jcjn5") assert(!invoice.isExpired()) @@ -254,14 +254,14 @@ class Bolt12InvoiceSpec extends AnyFunSuite { val nodeKey = PrivateKey(hex"c6a75116a91dc5ff741b079c32c8ce7544656b98f047fb0c0fa011bfb2bb3c05") val payerKey = PrivateKey(hex"94c7a21a11efa16c5f73b093dc136d9525e2ff40ea7a958c43c1f6004bf6a676") val Success(offer) = Offer.decode("lno1pqpzwyq2pf382mrtyphkven9wgtqzqgcqy9pug9kku8f4e9nuef5lv59yrkdc24t5mtrym62cg085w5wtqkp0rsuly") - assert(offer.amount === Some(10_000 msat)) - assert(offer.nodeIdXOnly === xOnlyPublicKey(nodeKey.publicKey)) - assert(offer.chains === Seq(Block.LivenetGenesisBlock.hash)) + assert(offer.amount == Some(10_000 msat)) + assert(offer.nodeIdXOnly == xOnlyPublicKey(nodeKey.publicKey)) + assert(offer.chains == Seq(Block.LivenetGenesisBlock.hash)) val request = InvoiceRequest(offer, 50_000 msat, 5, Features.empty, payerKey, Block.LivenetGenesisBlock.hash) val Success(invoice) = Bolt12Invoice.fromString("lni1qss8u47nw2lsgml7fy4jaqwph9f8cl83zfrrhxccvh6076avqzzzv4qgqtp4qzs2vf6kc6eqdanxvetjpsqpug9kku8f4e9nuef5lv59yrkdc24t5mtrym62cg085w5wtqkp0rsulysqzpfxyrat02l8wtgtwuc4h5hw6dxhn0hcpdrtu3dpejfjdlw9h4j3nppxc2qyvg9z0lf2yq7wl9ygd6td4cj7whp3ye4cfxrtu7zq4r2mc0mcdspk3duzv7d0stqyh0upuq8sgr44r7aaluwqfw8pkd9f3cgk7ae2l8rkexznhegr0p7w4mlhvfkvlnr5k2lnw0hhsf6ckys3sst7kng5p7m2pxlvdxl3tan809vkk75j") assert(!invoice.isExpired()) - assert(invoice.amount === 50_000.msat) - assert(invoice.quantity === Some(5)) + assert(invoice.amount == 50_000.msat) + assert(invoice.quantity == Some(5)) assert(invoice.isValidFor(offer, request)) } @@ -324,26 +324,26 @@ class Bolt12InvoiceSpec extends AnyFunSuite { ), Seq(GenericTlv(UInt64(311), hex"010203"), GenericTlv(UInt64(313), hex""))) val signature = signSchnorr(Bolt12Invoice.signatureTag("signature"), rootHash(tlvs, invoiceTlvCodec), nodeKey) val invoice = Bolt12Invoice(tlvs.copy(records = tlvs.records ++ Seq(Signature(signature))), None) - assert(invoice.toString === "lni1qvsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqyyz9ut9uduhtztjgpxm06394g5qkw7v79g4czw6zxsl3lnrsvljj0qzqrq83yqzscd9h8vmmfvdjjqamfw35zqmtpdeujqenfv4kxgucvqgqsq9qgv93kjmn39e3k783qc3nnudswp67znrydjtv7ta56c9cpc0nmjmv7rszs568gqdz3w77zqqfeycsgl2kawxcl0zckye09kpsmn54c3zgsztw845uxymh24g4zw9s45ef8p3yjwmfqw35x2grtd9hxw2qyv2sqd032ypge282v20ysgq6lpv5nmjwlrs88jeepxsc2upa970snfnfnxff5ztqzpcgzuqsq0vcpgpcyqqzpy02klq9svqqgavadc6y5tmmqzvsv484ku5nw43vumxuflvsrsgr345pnuh6zq6pz2cy8wra8vujs23y5yhd4gwslns3m7qm9023hc8cyq6knwqxzve9r5kpufq3szuhn9f437cj05az5kqnsl9wefhfnwzenf5z68qh5jj48rmku97u0gzdm2wlkuwrylpvqfttdtw972cwdteal6qfhqvqsyqlaqyusq") + assert(invoice.toString == "lni1qvsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqyyz9ut9uduhtztjgpxm06394g5qkw7v79g4czw6zxsl3lnrsvljj0qzqrq83yqzscd9h8vmmfvdjjqamfw35zqmtpdeujqenfv4kxgucvqgqsq9qgv93kjmn39e3k783qc3nnudswp67znrydjtv7ta56c9cpc0nmjmv7rszs568gqdz3w77zqqfeycsgl2kawxcl0zckye09kpsmn54c3zgsztw845uxymh24g4zw9s45ef8p3yjwmfqw35x2grtd9hxw2qyv2sqd032ypge282v20ysgq6lpv5nmjwlrs88jeepxsc2upa970snfnfnxff5ztqzpcgzuqsq0vcpgpcyqqzpy02klq9svqqgavadc6y5tmmqzvsv484ku5nw43vumxuflvsrsgr345pnuh6zq6pz2cy8wra8vujs23y5yhd4gwslns3m7qm9023hc8cyq6knwqxzve9r5kpufq3szuhn9f437cj05az5kqnsl9wefhfnwzenf5z68qh5jj48rmku97u0gzdm2wlkuwrylpvqfttdtw972cwdteal6qfhqvqsyqlaqyusq") val Success(codedDecoded) = Bolt12Invoice.fromString(invoice.toString) - assert(codedDecoded.chain === chain) - assert(codedDecoded.offerId === Some(offerId)) - assert(codedDecoded.amount === amount) - assert(codedDecoded.description === Left(description)) - assert(codedDecoded.features === features) - assert(codedDecoded.issuer === Some(issuer)) - assert(codedDecoded.nodeId.value.drop(1) === nodeKey.publicKey.value.drop(1)) - assert(codedDecoded.quantity === Some(quantity)) - assert(codedDecoded.payerKey === Some(payerKey)) - assert(codedDecoded.payerNote === Some(payerNote)) - assert(codedDecoded.payerInfo === Some(payerInfo)) - assert(codedDecoded.createdAt === createdAt) - assert(codedDecoded.paymentHash === paymentHash) - assert(codedDecoded.relativeExpiry === relativeExpiry.seconds) - assert(codedDecoded.minFinalCltvExpiryDelta === cltv) - assert(codedDecoded.fallbacks === Some(fallbacks)) - assert(codedDecoded.replaceInvoice === Some(replaceInvoice)) - assert(codedDecoded.records.unknown.toSet === Set(GenericTlv(UInt64(311), hex"010203"), GenericTlv(UInt64(313), hex""))) + assert(codedDecoded.chain == chain) + assert(codedDecoded.offerId == Some(offerId)) + assert(codedDecoded.amount == amount) + assert(codedDecoded.description == Left(description)) + assert(codedDecoded.features == features) + assert(codedDecoded.issuer == Some(issuer)) + assert(codedDecoded.nodeId.value.drop(1) == nodeKey.publicKey.value.drop(1)) + assert(codedDecoded.quantity == Some(quantity)) + assert(codedDecoded.payerKey == Some(payerKey)) + assert(codedDecoded.payerNote == Some(payerNote)) + assert(codedDecoded.payerInfo == Some(payerInfo)) + assert(codedDecoded.createdAt == createdAt) + assert(codedDecoded.paymentHash == paymentHash) + assert(codedDecoded.relativeExpiry == relativeExpiry.seconds) + assert(codedDecoded.minFinalCltvExpiryDelta == cltv) + assert(codedDecoded.fallbacks == Some(fallbacks)) + assert(codedDecoded.replaceInvoice == Some(replaceInvoice)) + assert(codedDecoded.records.unknown.toSet == Set(GenericTlv(UInt64(311), hex"010203"), GenericTlv(UInt64(313), hex""))) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartHandlerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartHandlerSpec.scala index 8409805683..52495bbec0 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartHandlerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartHandlerSpec.scala @@ -89,19 +89,19 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val invoice = sender.expectMsgType[Invoice] val incoming = nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) assert(incoming.isDefined) - assert(incoming.get.status === IncomingPaymentStatus.Pending) + assert(incoming.get.status == IncomingPaymentStatus.Pending) assert(!incoming.get.invoice.isExpired()) - assert(Crypto.sha256(incoming.get.paymentPreimage) === invoice.paymentHash) + assert(Crypto.sha256(incoming.get.paymentPreimage) == invoice.paymentHash) val add = UpdateAddHtlc(ByteVector32.One, 0, amountMsat, invoice.paymentHash, defaultExpiry, TestConstants.emptyOnionPacket) sender.send(handlerWithoutMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createSinglePartPayload(add.amountMsat, add.cltvExpiry, invoice.paymentSecret.get, invoice.paymentMetadata))) register.expectMsgType[Register.Forward[CMD_FULFILL_HTLC]] val paymentReceived = eventListener.expectMsgType[PaymentReceived] - assert(paymentReceived.copy(parts = paymentReceived.parts.map(_.copy(timestamp = 0 unixms))) === PaymentReceived(add.paymentHash, PartialPayment(amountMsat, add.channelId, timestamp = 0 unixms) :: Nil)) + assert(paymentReceived.copy(parts = paymentReceived.parts.map(_.copy(timestamp = 0 unixms))) == PaymentReceived(add.paymentHash, PartialPayment(amountMsat, add.channelId, timestamp = 0 unixms) :: Nil)) val received = nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) assert(received.isDefined && received.get.status.isInstanceOf[IncomingPaymentStatus.Received]) - assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].copy(receivedAt = 0 unixms) === IncomingPaymentStatus.Received(amountMsat, 0 unixms)) + assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].copy(receivedAt = 0 unixms) == IncomingPaymentStatus.Received(amountMsat, 0 unixms)) sender.expectNoMessage(50 millis) } @@ -110,17 +110,17 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(handlerWithMpp, ReceivePayment(Some(amountMsat), Left("another coffee with multi-part"))) val invoice = sender.expectMsgType[Invoice] assert(invoice.features.hasFeature(Features.BasicMultiPartPayment)) - assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) val add = UpdateAddHtlc(ByteVector32.One, 0, amountMsat, invoice.paymentHash, defaultExpiry, TestConstants.emptyOnionPacket) sender.send(handlerWithMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createSinglePartPayload(add.amountMsat, add.cltvExpiry, invoice.paymentSecret.get, invoice.paymentMetadata))) register.expectMsgType[Register.Forward[CMD_FULFILL_HTLC]] val paymentReceived = eventListener.expectMsgType[PaymentReceived] - assert(paymentReceived.copy(parts = paymentReceived.parts.map(_.copy(timestamp = 0 unixms))) === PaymentReceived(add.paymentHash, PartialPayment(amountMsat, add.channelId, timestamp = 0 unixms) :: Nil)) + assert(paymentReceived.copy(parts = paymentReceived.parts.map(_.copy(timestamp = 0 unixms))) == PaymentReceived(add.paymentHash, PartialPayment(amountMsat, add.channelId, timestamp = 0 unixms) :: Nil)) val received = nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) assert(received.isDefined && received.get.status.isInstanceOf[IncomingPaymentStatus.Received]) - assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].copy(receivedAt = 0 unixms) === IncomingPaymentStatus.Received(amountMsat, 0 unixms)) + assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].copy(receivedAt = 0 unixms) == IncomingPaymentStatus.Received(amountMsat, 0 unixms)) sender.expectNoMessage(50 millis) } @@ -128,13 +128,13 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike { sender.send(handlerWithMpp, ReceivePayment(Some(amountMsat), Left("bad expiry"))) val invoice = sender.expectMsgType[Invoice] - assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) val add = UpdateAddHtlc(ByteVector32.One, 0, amountMsat, invoice.paymentHash, CltvExpiryDelta(3).toCltvExpiry(nodeParams.currentBlockHeight), TestConstants.emptyOnionPacket) sender.send(handlerWithMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createSinglePartPayload(add.amountMsat, add.cltvExpiry, invoice.paymentSecret.get, invoice.paymentMetadata))) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(amountMsat, nodeParams.currentBlockHeight))) - assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) eventListener.expectNoMessage(100 milliseconds) sender.expectNoMessage(50 millis) @@ -173,13 +173,13 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(handlerWithMpp, ReceivePayment(Some(42000 msat), Left("1 coffee"))) val pr1 = sender.expectMsgType[Invoice] - assert(pr1.minFinalCltvExpiryDelta === nodeParams.channelConf.minFinalExpiryDelta) - assert(pr1.relativeExpiry === Alice.nodeParams.invoiceExpiry) + assert(pr1.minFinalCltvExpiryDelta == nodeParams.channelConf.minFinalExpiryDelta) + assert(pr1.relativeExpiry == Alice.nodeParams.invoiceExpiry) sender.send(handlerWithMpp, ReceivePayment(Some(42000 msat), Left("1 coffee with custom expiry"), expirySeconds_opt = Some(60))) val pr2 = sender.expectMsgType[Invoice] - assert(pr2.minFinalCltvExpiryDelta === nodeParams.channelConf.minFinalExpiryDelta) - assert(pr2.relativeExpiry === 60.seconds) + assert(pr2.minFinalCltvExpiryDelta == nodeParams.channelConf.minFinalExpiryDelta) + assert(pr2.relativeExpiry == 60.seconds) } test("Invoice generation with trampoline support") { _ => @@ -227,10 +227,10 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val route_x_t = extraHop_x_t :: Nil sender.send(handlerWithMpp, ReceivePayment(Some(42000 msat), Left("1 coffee with additional routing info"), extraHops = List(route_x_z, route_x_t))) - assert(sender.expectMsgType[Invoice].routingInfo === Seq(route_x_z, route_x_t)) + assert(sender.expectMsgType[Invoice].routingInfo == Seq(route_x_z, route_x_t)) sender.send(handlerWithMpp, ReceivePayment(Some(42000 msat), Left("1 coffee without routing info"))) - assert(sender.expectMsgType[Invoice].routingInfo === Nil) + assert(sender.expectMsgType[Invoice].routingInfo == Nil) } test("PaymentHandler should reject incoming payments if the invoice is expired") { f => @@ -245,7 +245,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(handlerWithoutMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createSinglePartPayload(add.amountMsat, add.cltvExpiry, invoice.paymentSecret.get, invoice.paymentMetadata))) register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]] val Some(incoming) = nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) - assert(incoming.invoice.isExpired() && incoming.status === IncomingPaymentStatus.Expired) + assert(incoming.invoice.isExpired() && incoming.status == IncomingPaymentStatus.Expired) } test("PaymentHandler should reject incoming multi-part payment if the invoice is expired") { f => @@ -261,7 +261,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) val Some(incoming) = nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) - assert(incoming.invoice.isExpired() && incoming.status === IncomingPaymentStatus.Expired) + assert(incoming.invoice.isExpired() && incoming.status == IncomingPaymentStatus.Expired) } test("PaymentHandler should reject incoming multi-part payment if the invoice does not allow it") { f => @@ -275,7 +275,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(handlerWithoutMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createMultiPartPayload(add.amountMsat, 1000 msat, add.cltvExpiry, invoice.paymentSecret.get, invoice.paymentMetadata))) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) - assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) } test("PaymentHandler should reject incoming multi-part payment with an invalid expiry") { f => @@ -290,7 +290,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(handlerWithMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createMultiPartPayload(add.amountMsat, 1000 msat, add.cltvExpiry, invoice.paymentSecret.get, invoice.paymentMetadata))) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) - assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) } test("PaymentHandler should reject incoming multi-part payment with an unknown payment hash") { f => @@ -304,7 +304,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(handlerWithMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createMultiPartPayload(add.amountMsat, 1000 msat, add.cltvExpiry, invoice.paymentSecret.get, invoice.paymentMetadata))) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) - assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) } test("PaymentHandler should reject incoming multi-part payment with a total amount too low") { f => @@ -318,7 +318,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(handlerWithMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createMultiPartPayload(add.amountMsat, 999 msat, add.cltvExpiry, invoice.paymentSecret.get, invoice.paymentMetadata))) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(999 msat, nodeParams.currentBlockHeight))) - assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) } test("PaymentHandler should reject incoming multi-part payment with a total amount too high") { f => @@ -332,7 +332,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(handlerWithMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createMultiPartPayload(add.amountMsat, 2001 msat, add.cltvExpiry, invoice.paymentSecret.get, invoice.paymentMetadata))) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(2001 msat, nodeParams.currentBlockHeight))) - assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) } test("PaymentHandler should reject incoming multi-part payment with an invalid payment secret") { f => @@ -347,7 +347,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(handlerWithMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createMultiPartPayload(add.amountMsat, 1000 msat, add.cltvExpiry, invoice.paymentSecret.get.reverse, invoice.paymentMetadata))) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) - assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status === IncomingPaymentStatus.Pending) + assert(nodeParams.db.payments.getIncomingPayment(invoice.paymentHash).get.status == IncomingPaymentStatus.Pending) } test("PaymentHandler should handle multi-part payment timeout") { f => @@ -372,7 +372,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike } val commands = f.register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]] :: f.register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]] :: Nil - assert(commands.toSet === Set( + assert(commands.toSet == Set( Register.Forward(ActorRef.noSender, ByteVector32.One, CMD_FAIL_HTLC(0, Right(PaymentTimeout), commit = true)), Register.Forward(ActorRef.noSender, ByteVector32.One, CMD_FAIL_HTLC(1, Right(PaymentTimeout), commit = true)) )) @@ -387,7 +387,7 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike // The payment should still be pending in DB. val Some(incomingPayment) = nodeParams.db.payments.getIncomingPayment(pr1.paymentHash) - assert(incomingPayment.status === IncomingPaymentStatus.Pending) + assert(incomingPayment.status == IncomingPaymentStatus.Pending) } test("PaymentHandler should handle multi-part payment success") { f => @@ -413,10 +413,10 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike ) val paymentReceived = f.eventListener.expectMsgType[PaymentReceived] - assert(paymentReceived.parts.map(_.copy(timestamp = 0 unixms)).toSet === Set(PartialPayment(800 msat, ByteVector32.One, 0 unixms), PartialPayment(200 msat, ByteVector32.Zeroes, 0 unixms))) + assert(paymentReceived.parts.map(_.copy(timestamp = 0 unixms)).toSet == Set(PartialPayment(800 msat, ByteVector32.One, 0 unixms), PartialPayment(200 msat, ByteVector32.Zeroes, 0 unixms))) val received = nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) assert(received.isDefined && received.get.status.isInstanceOf[IncomingPaymentStatus.Received]) - assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].amount === 1000.msat) + assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].amount == 1000.msat) awaitCond({ f.sender.send(handler, GetPendingPayments) f.sender.expectMsgType[PendingPayments].paymentHashes.isEmpty @@ -425,9 +425,9 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike // Extraneous HTLCs should be fulfilled. f.sender.send(handler, MultiPartPaymentFSM.ExtraPaymentReceived(invoice.paymentHash, HtlcPart(1000 msat, UpdateAddHtlc(ByteVector32.One, 44, 200 msat, invoice.paymentHash, add1.cltvExpiry, add1.onionRoutingPacket)), None)) f.register.expectMsg(Register.Forward(ActorRef.noSender, ByteVector32.One, CMD_FULFILL_HTLC(44, preimage, commit = true))) - assert(f.eventListener.expectMsgType[PaymentReceived].amount === 200.msat) + assert(f.eventListener.expectMsgType[PaymentReceived].amount == 200.msat) val received2 = nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) - assert(received2.get.status.asInstanceOf[IncomingPaymentStatus.Received].amount === 1200.msat) + assert(received2.get.status.asInstanceOf[IncomingPaymentStatus.Received].amount == 1200.msat) f.sender.send(handler, GetPendingPayments) f.sender.expectMsgType[PendingPayments].paymentHashes.isEmpty @@ -463,11 +463,11 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike ) val paymentReceived = f.eventListener.expectMsgType[PaymentReceived] - assert(paymentReceived.paymentHash === invoice.paymentHash) - assert(paymentReceived.parts.map(_.copy(timestamp = 0 unixms)).toSet === Set(PartialPayment(300 msat, ByteVector32.One, 0 unixms), PartialPayment(700 msat, ByteVector32.Zeroes, 0 unixms))) + assert(paymentReceived.paymentHash == invoice.paymentHash) + assert(paymentReceived.parts.map(_.copy(timestamp = 0 unixms)).toSet == Set(PartialPayment(300 msat, ByteVector32.One, 0 unixms), PartialPayment(700 msat, ByteVector32.Zeroes, 0 unixms))) val received = nodeParams.db.payments.getIncomingPayment(invoice.paymentHash) assert(received.isDefined && received.get.status.isInstanceOf[IncomingPaymentStatus.Received]) - assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].amount === 1000.msat) + assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].amount == 1000.msat) awaitCond({ f.sender.send(handler, GetPendingPayments) f.sender.expectMsgType[PendingPayments].paymentHashes.isEmpty @@ -483,17 +483,17 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val paymentSecret = randomBytes32() val payload = FinalTlvPayload(TlvStream(Seq(OnionPaymentPayloadTlv.AmountToForward(amountMsat), OnionPaymentPayloadTlv.OutgoingCltv(defaultExpiry), OnionPaymentPayloadTlv.PaymentData(paymentSecret, 0 msat), OnionPaymentPayloadTlv.KeySend(paymentPreimage)))) - assert(nodeParams.db.payments.getIncomingPayment(paymentHash) === None) + assert(nodeParams.db.payments.getIncomingPayment(paymentHash) == None) val add = UpdateAddHtlc(ByteVector32.One, 0, amountMsat, paymentHash, defaultExpiry, TestConstants.emptyOnionPacket) sender.send(handlerWithKeySend, IncomingPaymentPacket.FinalPacket(add, payload)) register.expectMsgType[Register.Forward[CMD_FULFILL_HTLC]] val paymentReceived = eventListener.expectMsgType[PaymentReceived] - assert(paymentReceived.copy(parts = paymentReceived.parts.map(_.copy(timestamp = 0 unixms))) === PaymentReceived(add.paymentHash, PartialPayment(amountMsat, add.channelId, timestamp = 0 unixms) :: Nil)) + assert(paymentReceived.copy(parts = paymentReceived.parts.map(_.copy(timestamp = 0 unixms))) == PaymentReceived(add.paymentHash, PartialPayment(amountMsat, add.channelId, timestamp = 0 unixms) :: Nil)) val received = nodeParams.db.payments.getIncomingPayment(paymentHash) assert(received.isDefined && received.get.status.isInstanceOf[IncomingPaymentStatus.Received]) - assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].copy(receivedAt = 0 unixms) === IncomingPaymentStatus.Received(amountMsat, 0 unixms)) + assert(received.get.status.asInstanceOf[IncomingPaymentStatus.Received].copy(receivedAt = 0 unixms) == IncomingPaymentStatus.Received(amountMsat, 0 unixms)) } test("PaymentHandler should reject KeySend payment when feature is disabled") { f => @@ -505,13 +505,13 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val paymentSecret = randomBytes32() val payload = FinalTlvPayload(TlvStream(Seq(OnionPaymentPayloadTlv.AmountToForward(amountMsat), OnionPaymentPayloadTlv.OutgoingCltv(defaultExpiry), OnionPaymentPayloadTlv.PaymentData(paymentSecret, 0 msat), OnionPaymentPayloadTlv.KeySend(paymentPreimage)))) - assert(nodeParams.db.payments.getIncomingPayment(paymentHash) === None) + assert(nodeParams.db.payments.getIncomingPayment(paymentHash) == None) val add = UpdateAddHtlc(ByteVector32.One, 0, amountMsat, paymentHash, defaultExpiry, TestConstants.emptyOnionPacket) sender.send(handlerWithMpp, IncomingPaymentPacket.FinalPacket(add, payload)) f.register.expectMsg(Register.Forward(ActorRef.noSender, add.channelId, CMD_FAIL_HTLC(add.id, Right(IncorrectOrUnknownPaymentDetails(42000 msat, nodeParams.currentBlockHeight)), commit = true))) - assert(nodeParams.db.payments.getIncomingPayment(paymentHash) === None) + assert(nodeParams.db.payments.getIncomingPayment(paymentHash) == None) } test("PaymentHandler should reject incoming payments if the invoice doesn't exist") { f => @@ -519,13 +519,13 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val paymentHash = randomBytes32() val paymentSecret = randomBytes32() - assert(nodeParams.db.payments.getIncomingPayment(paymentHash) === None) + assert(nodeParams.db.payments.getIncomingPayment(paymentHash) == None) val add = UpdateAddHtlc(ByteVector32.One, 0, 1000 msat, paymentHash, defaultExpiry, TestConstants.emptyOnionPacket) sender.send(handlerWithoutMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createSinglePartPayload(add.amountMsat, add.cltvExpiry, paymentSecret, None))) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message - assert(cmd.id === add.id) - assert(cmd.reason === Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) + assert(cmd.id == add.id) + assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) } test("PaymentHandler should reject incoming multi-part payment if the invoice doesn't exist") { f => @@ -533,13 +533,13 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val paymentHash = randomBytes32() val paymentSecret = randomBytes32() - assert(nodeParams.db.payments.getIncomingPayment(paymentHash) === None) + assert(nodeParams.db.payments.getIncomingPayment(paymentHash) == None) val add = UpdateAddHtlc(ByteVector32.One, 0, 800 msat, paymentHash, defaultExpiry, TestConstants.emptyOnionPacket) sender.send(handlerWithMpp, IncomingPaymentPacket.FinalPacket(add, PaymentOnion.createMultiPartPayload(add.amountMsat, 1000 msat, add.cltvExpiry, paymentSecret, Some(hex"012345")))) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message - assert(cmd.id === add.id) - assert(cmd.reason === Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) + assert(cmd.id == add.id) + assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) } test("PaymentHandler should fail fulfilling incoming payments if the invoice doesn't exist") { f => @@ -547,13 +547,13 @@ class MultiPartHandlerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val paymentPreimage = randomBytes32() val paymentHash = Crypto.sha256(paymentPreimage) - assert(nodeParams.db.payments.getIncomingPayment(paymentHash) === None) + assert(nodeParams.db.payments.getIncomingPayment(paymentHash) == None) val add = UpdateAddHtlc(ByteVector32.One, 0, 1000 msat, paymentHash, defaultExpiry, TestConstants.emptyOnionPacket) val fulfill = DoFulfill(paymentPreimage, MultiPartPaymentFSM.MultiPartPaymentSucceeded(paymentHash, Queue(HtlcPart(1000 msat, add)))) sender.send(handlerWithoutMpp, fulfill) val cmd = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]].message - assert(cmd.id === add.id) - assert(cmd.reason === Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) + assert(cmd.id == add.id) + assert(cmd.reason == Right(IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight))) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartPaymentFSMSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartPaymentFSMSpec.scala index e66d61754f..f2c2a79e40 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartPaymentFSMSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartPaymentFSMSpec.scala @@ -73,9 +73,9 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { parts.foreach(p => f.parent.send(f.handler, p)) val fail = f.parent.expectMsgType[MultiPartPaymentFailed] - assert(fail.paymentHash === paymentHash) - assert(fail.failure === protocol.PaymentTimeout) - assert(fail.parts.toSet === parts.toSet) + assert(fail.paymentHash == paymentHash) + assert(fail.failure == protocol.PaymentTimeout) + assert(fail.parts.toSet == parts.toSet) f.parent.expectNoMessage(50 millis) f.eventListener.expectNoMessage(50 millis) @@ -85,14 +85,14 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { val f = createFixture(250 millis, 1000 msat) f.parent.send(f.handler, createMultiPartHtlc(1000 msat, 150 msat, 1)) f.parent.send(f.handler, createMultiPartHtlc(1000 msat, 100 msat, 2)) - assert(f.parent.expectMsgType[MultiPartPaymentFailed].parts.length === 2) + assert(f.parent.expectMsgType[MultiPartPaymentFailed].parts.length == 2) val extraPart = createMultiPartHtlc(1000 msat, 300 msat, 3) f.parent.send(f.handler, extraPart) val fail = f.parent.expectMsgType[ExtraPaymentReceived[PaymentPart]] - assert(fail.paymentHash === paymentHash) - assert(fail.failure === Some(protocol.PaymentTimeout)) - assert(fail.payment === extraPart) + assert(fail.paymentHash == paymentHash) + assert(fail.failure == Some(protocol.PaymentTimeout)) + assert(fail.payment == extraPart) f.parent.expectNoMessage(50 millis) f.eventListener.expectNoMessage(50 millis) @@ -103,9 +103,9 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { f.parent.send(f.handler, createMultiPartHtlc(1000 msat, 600 msat, 1)) f.parent.send(f.handler, createMultiPartHtlc(1100 msat, 650 msat, 2)) val fail = f.parent.expectMsgType[MultiPartPaymentFailed] - assert(fail.paymentHash === paymentHash) - assert(fail.failure === IncorrectOrUnknownPaymentDetails(1100 msat, f.currentBlockHeight)) - assert(fail.parts.length === 2) + assert(fail.paymentHash == paymentHash) + assert(fail.failure == IncorrectOrUnknownPaymentDetails(1100 msat, f.currentBlockHeight)) + assert(fail.parts.length == 2) f.parent.expectNoMessage(50 millis) f.eventListener.expectNoMessage(50 millis) @@ -121,8 +121,8 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { parts.foreach(p => f.parent.send(f.handler, p)) val paymentResult = f.parent.expectMsgType[MultiPartPaymentSucceeded] - assert(paymentResult.paymentHash === paymentHash) - assert(paymentResult.parts.toSet === parts.toSet) + assert(paymentResult.paymentHash == paymentHash) + assert(paymentResult.parts.toSet == parts.toSet) f.parent.expectNoMessage(50 millis) f.eventListener.expectNoMessage(50 millis) } @@ -137,8 +137,8 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { parts.foreach(p => f.parent.send(f.handler, p)) val paymentResult = f.parent.expectMsgType[MultiPartPaymentSucceeded] - assert(paymentResult.paymentHash === paymentHash) - assert(paymentResult.parts.toSet === parts.toSet) + assert(paymentResult.paymentHash == paymentHash) + assert(paymentResult.parts.toSet == parts.toSet) f.parent.expectNoMessage(50 millis) f.eventListener.expectNoMessage(50 millis) @@ -150,7 +150,7 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { f.parent.send(f.handler, part) val paymentResult = f.parent.expectMsgType[MultiPartPaymentSucceeded] - assert(paymentResult.parts === Seq(part)) + assert(paymentResult.parts == Seq(part)) f.parent.expectNoMessage(50 millis) f.eventListener.expectNoMessage(50 millis) @@ -162,7 +162,7 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { f.parent.send(f.handler, part) val paymentResult = f.parent.expectMsgType[MultiPartPaymentSucceeded] - assert(paymentResult.parts === Seq(part)) + assert(paymentResult.parts == Seq(part)) f.parent.expectNoMessage(50 millis) f.eventListener.expectNoMessage(50 millis) @@ -177,14 +177,14 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { ) parts.foreach(p => f.parent.send(f.handler, p)) val paymentResult = f.parent.expectMsgType[MultiPartPaymentSucceeded] - assert(paymentResult.parts.toSet === parts.toSet) + assert(paymentResult.parts.toSet == parts.toSet) f.parent.expectNoMessage(50 millis) val extra = createMultiPartHtlc(1000 msat, 300 msat, 3) f.parent.send(f.handler, extra) val extraneousPayment = f.parent.expectMsgType[ExtraPaymentReceived[PaymentPart]] - assert(extraneousPayment.paymentHash === paymentHash) - assert(extraneousPayment.payment === extra) + assert(extraneousPayment.paymentHash == paymentHash) + assert(extraneousPayment.payment == extra) f.parent.expectNoMessage(50 millis) f.eventListener.expectNoMessage(50 millis) @@ -203,8 +203,8 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { f.parent.send(f.handler, parts(1)) val paymentResult = f.parent.expectMsgType[MultiPartPaymentSucceeded] - assert(paymentResult.paymentHash === paymentHash) - assert(paymentResult.parts.toSet === parts.toSet) + assert(paymentResult.paymentHash == paymentHash) + assert(paymentResult.parts.toSet == parts.toSet) f.parent.expectNoMessage(50 millis) } @@ -219,7 +219,7 @@ class MultiPartPaymentFSMSpec extends TestKitBaseClass with AnyFunSuiteLike { f.parent.send(f.handler, parts(1)) val paymentResult = f.parent.expectMsgType[MultiPartPaymentSucceeded] - assert(paymentResult.parts.toSet === parts.toSet) + assert(paymentResult.parts.toSet == parts.toSet) f.parent.expectNoMessage(50 millis) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartPaymentLifecycleSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartPaymentLifecycleSpec.scala index 634f7e42a1..8b4591a212 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartPaymentLifecycleSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/MultiPartPaymentLifecycleSpec.scala @@ -78,27 +78,27 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS test("successful first attempt (single part)") { f => import f._ - assert(payFsm.stateName === WAIT_FOR_PAYMENT_REQUEST) + assert(payFsm.stateName == WAIT_FOR_PAYMENT_REQUEST) val payment = SendMultiPartPayment(sender.ref, randomBytes32(), e, finalAmount, expiry, 1, None, routeParams = routeParams.copy(randomize = true)) sender.send(payFsm, payment) router.expectMsg(RouteRequest(nodeParams.nodeId, e, finalAmount, maxFee, routeParams = routeParams.copy(randomize = false), allowMultiPart = true, paymentContext = Some(cfg.paymentContext))) - assert(payFsm.stateName === WAIT_FOR_ROUTES) + assert(payFsm.stateName == WAIT_FOR_ROUTES) val singleRoute = Route(finalAmount, hop_ab_1 :: hop_be :: Nil) router.send(payFsm, RouteResponse(Seq(singleRoute))) val childPayment = childPayFsm.expectMsgType[SendPaymentToRoute] - assert(childPayment.route === Right(singleRoute)) - assert(childPayment.finalPayload.expiry === expiry) - assert(childPayment.finalPayload.paymentSecret === payment.paymentSecret) - assert(childPayment.finalPayload.amount === finalAmount) - assert(childPayment.finalPayload.totalAmount === finalAmount) - assert(payFsm.stateName === PAYMENT_IN_PROGRESS) + assert(childPayment.route == Right(singleRoute)) + assert(childPayment.finalPayload.expiry == expiry) + assert(childPayment.finalPayload.paymentSecret == payment.paymentSecret) + assert(childPayment.finalPayload.amount == finalAmount) + assert(childPayment.finalPayload.totalAmount == finalAmount) + assert(payFsm.stateName == PAYMENT_IN_PROGRESS) val result = fulfillPendingPayments(f, 1) - assert(result.amountWithFees === finalAmount + 100.msat) - assert(result.trampolineFees === 0.msat) - assert(result.nonTrampolineFees === 100.msat) + assert(result.amountWithFees == finalAmount + 100.msat) + assert(result.trampolineFees == 0.msat) + assert(result.nonTrampolineFees == 100.msat) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] assert(metrics.status == "SUCCESS") @@ -111,12 +111,12 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS test("successful first attempt (multiple parts)") { f => import f._ - assert(payFsm.stateName === WAIT_FOR_PAYMENT_REQUEST) + assert(payFsm.stateName == WAIT_FOR_PAYMENT_REQUEST) val payment = SendMultiPartPayment(sender.ref, randomBytes32(), e, 1200000 msat, expiry, 1, Some(hex"012345"), routeParams = routeParams.copy(randomize = false)) sender.send(payFsm, payment) router.expectMsg(RouteRequest(nodeParams.nodeId, e, 1200000 msat, maxFee, routeParams = routeParams.copy(randomize = false), allowMultiPart = true, paymentContext = Some(cfg.paymentContext))) - assert(payFsm.stateName === WAIT_FOR_ROUTES) + assert(payFsm.stateName == WAIT_FOR_ROUTES) val routes = Seq( Route(500000 msat, hop_ab_1 :: hop_be :: Nil), @@ -124,18 +124,18 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS ) router.send(payFsm, RouteResponse(routes)) val childPayments = childPayFsm.expectMsgType[SendPaymentToRoute] :: childPayFsm.expectMsgType[SendPaymentToRoute] :: Nil - assert(childPayments.map(_.route).toSet === routes.map(r => Right(r)).toSet) - assert(childPayments.map(_.finalPayload.expiry).toSet === Set(expiry)) - assert(childPayments.map(_.finalPayload.paymentSecret).toSet === Set(payment.paymentSecret)) - assert(childPayments.map(_.finalPayload.paymentMetadata).toSet === Set(Some(hex"012345"))) - assert(childPayments.map(_.finalPayload.amount).toSet === Set(500000 msat, 700000 msat)) - assert(childPayments.map(_.finalPayload.totalAmount).toSet === Set(1200000 msat)) - assert(payFsm.stateName === PAYMENT_IN_PROGRESS) + assert(childPayments.map(_.route).toSet == routes.map(r => Right(r)).toSet) + assert(childPayments.map(_.finalPayload.expiry).toSet == Set(expiry)) + assert(childPayments.map(_.finalPayload.paymentSecret).toSet == Set(payment.paymentSecret)) + assert(childPayments.map(_.finalPayload.paymentMetadata).toSet == Set(Some(hex"012345"))) + assert(childPayments.map(_.finalPayload.amount).toSet == Set(500000 msat, 700000 msat)) + assert(childPayments.map(_.finalPayload.totalAmount).toSet == Set(1200000 msat)) + assert(payFsm.stateName == PAYMENT_IN_PROGRESS) val result = fulfillPendingPayments(f, 2) - assert(result.amountWithFees === 1200200.msat) - assert(result.trampolineFees === 200000.msat) - assert(result.nonTrampolineFees === 200.msat) + assert(result.amountWithFees == 1200200.msat) + assert(result.trampolineFees == 200000.msat) + assert(result.nonTrampolineFees == 200.msat) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] assert(metrics.status == "SUCCESS") @@ -157,12 +157,12 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS router.send(payFsm, RouteResponse(Seq(Route(500000 msat, hop_ab_1 :: hop_be :: Nil), Route(501000 msat, hop_ac_1 :: hop_ce :: Nil)))) val childPayments = childPayFsm.expectMsgType[SendPaymentToRoute] :: childPayFsm.expectMsgType[SendPaymentToRoute] :: Nil childPayments.map(_.finalPayload.asInstanceOf[PaymentOnion.FinalTlvPayload]).foreach(p => { - assert(p.records.get[OnionPaymentPayloadTlv.TrampolineOnion] === Some(trampolineTlv)) - assert(p.records.unknown.toSeq === Seq(userCustomTlv)) + assert(p.records.get[OnionPaymentPayloadTlv.TrampolineOnion] == Some(trampolineTlv)) + assert(p.records.unknown.toSeq == Seq(userCustomTlv)) }) val result = fulfillPendingPayments(f, 2) - assert(result.trampolineFees === 1000.msat) + assert(result.trampolineFees == 1000.msat) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] assert(metrics.status == "SUCCESS") @@ -193,9 +193,9 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS assert(!payFsm.stateData.asInstanceOf[PaymentProgress].pending.contains(childId)) val result = fulfillPendingPayments(f, 2) - assert(result.amountWithFees === 1000200.msat) - assert(result.trampolineFees === 0.msat) - assert(result.nonTrampolineFees === 200.msat) + assert(result.amountWithFees == 1000200.msat) + assert(result.trampolineFees == 0.msat) + assert(result.nonTrampolineFees == 200.msat) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] assert(metrics.status == "SUCCESS") @@ -236,8 +236,8 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS childPayFsm.expectMsgType[SendPaymentToRoute] val result = fulfillPendingPayments(f, 2) - assert(result.amountWithFees === 1000200.msat) - assert(result.nonTrampolineFees === 200.msat) + assert(result.amountWithFees == 1000200.msat) + assert(result.nonTrampolineFees == 200.msat) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] assert(metrics.status == "SUCCESS") @@ -304,7 +304,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS childPayFsm.expectMsgType[SendPaymentToRoute] val result = fulfillPendingPayments(f, 2) - assert(result.amountWithFees === 1000200.msat) + assert(result.amountWithFees == 1000200.msat) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] assert(metrics.status == "SUCCESS") @@ -321,7 +321,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS val routingHint = ExtraHop(b, hop_be.shortChannelId, hop_be.params.relayFees.feeBase, hop_be.params.relayFees.feeProportionalMillionths, hop_be.params.cltvExpiryDelta) val payment = SendMultiPartPayment(sender.ref, randomBytes32(), e, finalAmount, expiry, 3, None, routeParams = routeParams, assistedRoutes = List(List(routingHint))) sender.send(payFsm, payment) - assert(router.expectMsgType[RouteRequest].assistedRoutes.head.head === routingHint) + assert(router.expectMsgType[RouteRequest].assistedRoutes.head.head == routingHint) val route = Route(finalAmount, hop_ab_1 :: hop_be :: Nil) router.send(payFsm, RouteResponse(Seq(route))) childPayFsm.expectMsgType[SendPaymentToRoute] @@ -332,7 +332,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS val childId = payFsm.stateData.asInstanceOf[PaymentProgress].pending.keys.head childPayFsm.send(payFsm, PaymentFailed(childId, paymentHash, Seq(RemoteFailure(route.amount, route.hops, Sphinx.DecryptedFailurePacket(b, FeeInsufficient(finalAmount, channelUpdate)))))) // We update the routing hints accordingly before requesting a new route. - assert(router.expectMsgType[RouteRequest].assistedRoutes.head.head === ExtraHop(b, channelUpdate.shortChannelId, 250 msat, 150, CltvExpiryDelta(24))) + assert(router.expectMsgType[RouteRequest].assistedRoutes.head.head == ExtraHop(b, channelUpdate.shortChannelId, 250 msat, 150, CltvExpiryDelta(24))) } test("retry with ignored routing hints (temporary channel failure)") { f => @@ -342,7 +342,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS val routingHint = ExtraHop(b, hop_be.shortChannelId, hop_be.params.relayFees.feeBase, hop_be.params.relayFees.feeProportionalMillionths, hop_be.params.cltvExpiryDelta) val payment = SendMultiPartPayment(sender.ref, randomBytes32(), e, finalAmount, expiry, 3, None, routeParams = routeParams, assistedRoutes = List(List(routingHint))) sender.send(payFsm, payment) - assert(router.expectMsgType[RouteRequest].assistedRoutes.head.head === routingHint) + assert(router.expectMsgType[RouteRequest].assistedRoutes.head.head == routingHint) val route = Route(finalAmount, hop_ab_1 :: hop_be :: Nil) router.send(payFsm, RouteResponse(Seq(route))) childPayFsm.expectMsgType[SendPaymentToRoute] @@ -356,8 +356,8 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS childPayFsm.send(payFsm, PaymentFailed(childId, paymentHash, Seq(RemoteFailure(route.amount, route.hops, Sphinx.DecryptedFailurePacket(b, TemporaryChannelFailure(channelUpdateBE1)))))) // We update the routing hints accordingly before requesting a new route and ignore the channel. val routeRequest = router.expectMsgType[RouteRequest] - assert(routeRequest.assistedRoutes.head.head === routingHint) - assert(routeRequest.ignore.channels.map(_.shortChannelId) === Set(channelUpdateBE1.shortChannelId)) + assert(routeRequest.assistedRoutes.head.head == routingHint) + assert(routeRequest.ignore.channels.map(_.shortChannelId) == Set(channelUpdateBE1.shortChannelId)) } test("update routing hints") { _ => @@ -380,7 +380,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS Seq(ExtraHop(a, ShortChannelId(1), 10 msat, 0, CltvExpiryDelta(12)), ExtraHop(b, ShortChannelId(2), 15 msat, 150, CltvExpiryDelta(48))), Seq(ExtraHop(a, ShortChannelId(3), 1 msat, 10, CltvExpiryDelta(144))) ) - assert(routingHints1 === PaymentFailure.updateRoutingHints(failures, routingHints)) + assert(routingHints1 == PaymentFailure.updateRoutingHints(failures, routingHints)) } { val failures = Seq( @@ -393,7 +393,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS Seq(ExtraHop(a, ShortChannelId(1), 23 msat, 23, CltvExpiryDelta(23)), ExtraHop(b, ShortChannelId(2), 21 msat, 21, CltvExpiryDelta(21))), Seq(ExtraHop(a, ShortChannelId(3), 22 msat, 22, CltvExpiryDelta(22))) ) - assert(routingHints1 === PaymentFailure.updateRoutingHints(failures, routingHints)) + assert(routingHints1 == PaymentFailure.updateRoutingHints(failures, routingHints)) } } @@ -437,13 +437,13 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS router.send(payFsm, Status.Failure(RouteNotFound)) val result = sender.expectMsgType[PaymentFailed] - assert(result.id === cfg.id) - assert(result.paymentHash === paymentHash) - assert(result.failures === Seq(LocalFailure(finalAmount, Nil, RouteNotFound))) + assert(result.id == cfg.id) + assert(result.paymentHash == paymentHash) + assert(result.failures == Seq(LocalFailure(finalAmount, Nil, RouteNotFound))) val Some(outgoing) = nodeParams.db.payments.getOutgoingPayment(cfg.id) assert(outgoing.status.isInstanceOf[OutgoingPaymentStatus.Failed]) - assert(outgoing.status.asInstanceOf[OutgoingPaymentStatus.Failed].failures === Seq(FailureSummary(FailureType.LOCAL, RouteNotFound.getMessage, Nil, None))) + assert(outgoing.status.asInstanceOf[OutgoingPaymentStatus.Failed].failures == Seq(FailureSummary(FailureType.LOCAL, RouteNotFound.getMessage, Nil, None))) sender.expectTerminated(payFsm) sender.expectNoMessage(100 millis) @@ -469,7 +469,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS val (failedId, failedRoute) = payFsm.stateData.asInstanceOf[PaymentProgress].pending.head val result = abortAfterFailure(f, PaymentFailed(failedId, paymentHash, Seq(RemoteFailure(failedRoute.amount, failedRoute.hops, Sphinx.DecryptedFailurePacket(e, IncorrectOrUnknownPaymentDetails(600000 msat, BlockHeight(0))))))) - assert(result.failures.length === 1) + assert(result.failures.length == 1) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] assert(metrics.status == "FAILURE") @@ -490,7 +490,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS val (failedId, failedRoute) = payFsm.stateData.asInstanceOf[PaymentProgress].pending.head val result = abortAfterFailure(f, PaymentFailed(failedId, paymentHash, Seq(LocalFailure(failedRoute.amount, failedRoute.hops, HtlcsTimedoutDownstream(channelId = ByteVector32.One, htlcs = Set.empty))))) - assert(result.failures.length === 1) + assert(result.failures.length == 1) } test("abort if recipient sends error during retry") { f => @@ -508,7 +508,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS router.expectMsgType[RouteRequest] val result = abortAfterFailure(f, PaymentFailed(failedId2, paymentHash, Seq(RemoteFailure(failedRoute2.amount, failedRoute2.hops, Sphinx.DecryptedFailurePacket(e, PaymentTimeout))))) - assert(result.failures.length === 2) + assert(result.failures.length == 2) } test("receive partial success after retriable failure (recipient spec violation)") { f => @@ -527,8 +527,8 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS val result = fulfillPendingPayments(f, 1) assert(result.amountWithFees < finalAmount) // we got the preimage without paying the full amount - assert(result.nonTrampolineFees === successRoute.fee(false)) // we paid the fee for only one of the partial payments - assert(result.parts.length === 1 && result.parts.head.id === successId) + assert(result.nonTrampolineFees == successRoute.fee(false)) // we paid the fee for only one of the partial payments + assert(result.parts.length == 1 && result.parts.head.id == successId) } test("receive partial success after abort (recipient spec violation)") { f => @@ -543,20 +543,20 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS val (failedId, failedRoute) :: (successId, successRoute) :: Nil = payFsm.stateData.asInstanceOf[PaymentProgress].pending.toSeq childPayFsm.send(payFsm, PaymentFailed(failedId, paymentHash, Seq(RemoteFailure(failedRoute.amount, failedRoute.hops, Sphinx.DecryptedFailurePacket(e, PaymentTimeout))))) - awaitCond(payFsm.stateName === PAYMENT_ABORTED) + awaitCond(payFsm.stateName == PAYMENT_ABORTED) sender.watch(payFsm) childPayFsm.send(payFsm, PaymentSent(cfg.id, paymentHash, paymentPreimage, finalAmount, e, Seq(PaymentSent.PartialPayment(successId, successRoute.amount, successRoute.fee(false), randomBytes32(), Some(successRoute.hops))))) sender.expectMsg(PreimageReceived(paymentHash, paymentPreimage)) val result = sender.expectMsgType[PaymentSent] - assert(result.id === cfg.id) - assert(result.paymentHash === paymentHash) - assert(result.paymentPreimage === paymentPreimage) - assert(result.parts.length === 1 && result.parts.head.id === successId) - assert(result.recipientAmount === finalAmount) - assert(result.recipientNodeId === finalRecipient) + assert(result.id == cfg.id) + assert(result.paymentHash == paymentHash) + assert(result.paymentPreimage == paymentPreimage) + assert(result.parts.length == 1 && result.parts.head.id == successId) + assert(result.recipientAmount == finalAmount) + assert(result.recipientNodeId == finalRecipient) assert(result.amountWithFees < finalAmount) // we got the preimage without paying the full amount - assert(result.nonTrampolineFees === successRoute.fee(false)) // we paid the fee for only one of the partial payments + assert(result.nonTrampolineFees == successRoute.fee(false)) // we paid the fee for only one of the partial payments sender.expectTerminated(payFsm) sender.expectNoMessage(100 millis) @@ -577,14 +577,14 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS val (childId, route) :: (failedId, failedRoute) :: Nil = payFsm.stateData.asInstanceOf[PaymentProgress].pending.toSeq childPayFsm.send(payFsm, PaymentSent(cfg.id, paymentHash, paymentPreimage, finalAmount, e, Seq(PaymentSent.PartialPayment(childId, route.amount, route.fee(false), randomBytes32(), Some(route.hops))))) sender.expectMsg(PreimageReceived(paymentHash, paymentPreimage)) - awaitCond(payFsm.stateName === PAYMENT_SUCCEEDED) + awaitCond(payFsm.stateName == PAYMENT_SUCCEEDED) sender.watch(payFsm) childPayFsm.send(payFsm, PaymentFailed(failedId, paymentHash, Seq(RemoteFailure(failedRoute.amount, failedRoute.hops, Sphinx.DecryptedFailurePacket(e, PaymentTimeout))))) val result = sender.expectMsgType[PaymentSent] - assert(result.parts.length === 1 && result.parts.head.id === childId) + assert(result.parts.length == 1 && result.parts.head.id == childId) assert(result.amountWithFees < finalAmount) // we got the preimage without paying the full amount - assert(result.nonTrampolineFees === route.fee(false)) // we paid the fee for only one of the partial payments + assert(result.nonTrampolineFees == route.fee(false)) // we paid the fee for only one of the partial payments sender.expectTerminated(payFsm) sender.expectNoMessage(100 millis) @@ -597,7 +597,7 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS sender.watch(payFsm) val pending = payFsm.stateData.asInstanceOf[PaymentProgress].pending - assert(pending.size === childCount) + assert(pending.size == childCount) val partialPayments = pending.map { case (childId, route) => PaymentSent.PartialPayment(childId, route.amount, route.fee(false), randomBytes32(), Some(route.hops)) @@ -605,12 +605,12 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS partialPayments.foreach(pp => childPayFsm.send(payFsm, PaymentSent(cfg.id, paymentHash, paymentPreimage, finalAmount, e, Seq(pp)))) sender.expectMsg(PreimageReceived(paymentHash, paymentPreimage)) val result = sender.expectMsgType[PaymentSent] - assert(result.id === cfg.id) - assert(result.paymentHash === paymentHash) - assert(result.paymentPreimage === paymentPreimage) - assert(result.parts.toSet === partialPayments.toSet) - assert(result.recipientAmount === finalAmount) - assert(result.recipientNodeId === finalRecipient) + assert(result.id == cfg.id) + assert(result.paymentHash == paymentHash) + assert(result.paymentPreimage == paymentPreimage) + assert(result.parts.toSet == partialPayments.toSet) + assert(result.recipientAmount == finalAmount) + assert(result.recipientNodeId == finalRecipient) sender.expectTerminated(payFsm) sender.expectNoMessage(100 millis) @@ -627,8 +627,8 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS val pending = payFsm.stateData.asInstanceOf[PaymentProgress].pending childPayFsm.send(payFsm, childFailure) // this failure should trigger an abort if (pending.size > 1) { - awaitCond(payFsm.stateName === PAYMENT_ABORTED) - assert(payFsm.stateData.asInstanceOf[PaymentAborted].pending.size === pending.size - 1) + awaitCond(payFsm.stateName == PAYMENT_ABORTED) + assert(payFsm.stateData.asInstanceOf[PaymentAborted].pending.size == pending.size - 1) // Fail all remaining child payments. payFsm.stateData.asInstanceOf[PaymentAborted].pending.foreach(childId => childPayFsm.send(payFsm, PaymentFailed(childId, paymentHash, Seq(RemoteFailure(pending(childId).amount, hop_ab_1 :: hop_be :: Nil, Sphinx.DecryptedFailurePacket(e, PaymentTimeout))))) @@ -636,8 +636,8 @@ class MultiPartPaymentLifecycleSpec extends TestKitBaseClass with FixtureAnyFunS } val result = sender.expectMsgType[PaymentFailed] - assert(result.id === cfg.id) - assert(result.paymentHash === paymentHash) + assert(result.id == cfg.id) + assert(result.paymentHash == paymentHash) assert(result.failures.nonEmpty) sender.expectTerminated(payFsm) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentInitiatorSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentInitiatorSpec.scala index 19ee4ff7ad..a72817e183 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentInitiatorSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentInitiatorSpec.scala @@ -135,9 +135,9 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(initiator, req) val id = sender.expectMsgType[UUID] val fail = sender.expectMsgType[PaymentFailed] - assert(fail.id === id) + assert(fail.id == id) assert(fail.failures.head.isInstanceOf[LocalFailure]) - assert(fail.failures.head.asInstanceOf[LocalFailure].t === UnsupportedFeatures(invoice.features)) + assert(fail.failures.head.asInstanceOf[LocalFailure].t == UnsupportedFeatures(invoice.features)) } test("forward payment with pre-defined route") { f => @@ -170,7 +170,7 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val finalExpiryDelta = CltvExpiryDelta(24) val invoice = Bolt11Invoice(Block.LivenetGenesisBlock.hash, Some(finalAmount), paymentHash, priv_c.privateKey, Left("Some MPP invoice"), finalExpiryDelta, features = featuresWithMpp) val req = SendPaymentToNode(finalAmount, invoice, 1, routeParams = nodeParams.routerConf.pathFindingExperimentConf.getRandomConf().getDefaultRouteParams) - assert(req.finalExpiry(nodeParams.currentBlockHeight) === (finalExpiryDelta + 1).toCltvExpiry(nodeParams.currentBlockHeight)) + assert(req.finalExpiry(nodeParams.currentBlockHeight) == (finalExpiryDelta + 1).toCltvExpiry(nodeParams.currentBlockHeight)) sender.send(initiator, req) val id = sender.expectMsgType[UUID] payFsm.expectMsg(SendPaymentConfig(id, id, None, paymentHash, finalAmount, c, Upstream.Local(id), Some(invoice), storeInDb = true, publishEvent = true, recordPathFindingMetrics = true, Nil)) @@ -222,12 +222,12 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val payment = sender.expectMsgType[SendPaymentToRouteResponse] payFsm.expectMsg(SendPaymentConfig(payment.paymentId, payment.parentId, None, paymentHash, finalAmount, c, Upstream.Local(payment.paymentId), Some(invoice), storeInDb = true, publishEvent = true, recordPathFindingMetrics = false, Nil)) val msg = payFsm.expectMsgType[PaymentLifecycle.SendPaymentToRoute] - assert(msg.replyTo === initiator) - assert(msg.route === Left(route)) - assert(msg.finalPayload.amount === finalAmount / 2) - assert(msg.finalPayload.expiry === req.finalExpiry(nodeParams.currentBlockHeight)) - assert(msg.finalPayload.paymentSecret === invoice.paymentSecret.get) - assert(msg.finalPayload.totalAmount === finalAmount) + assert(msg.replyTo == initiator) + assert(msg.route == Left(route)) + assert(msg.finalPayload.amount == finalAmount / 2) + assert(msg.finalPayload.expiry == req.finalExpiry(nodeParams.currentBlockHeight)) + assert(msg.finalPayload.paymentSecret == invoice.paymentSecret.get) + assert(msg.finalPayload.totalAmount == finalAmount) sender.send(initiator, GetPayment(Left(payment.paymentId))) sender.expectMsg(PaymentIsPending(payment.paymentId, invoice.paymentHash, PendingPaymentToRoute(sender.ref, req))) @@ -260,33 +260,33 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val msg = multiPartPayFsm.expectMsgType[SendMultiPartPayment] assert(msg.paymentSecret !== invoice.paymentSecret.get) // we should not leak the invoice secret to the trampoline node - assert(msg.targetNodeId === b) - assert(msg.targetExpiry.toLong === currentBlockCount + 9 + 12 + 1) - assert(msg.totalAmount === finalAmount + trampolineFees) + assert(msg.targetNodeId == b) + assert(msg.targetExpiry.toLong == currentBlockCount + 9 + 12 + 1) + assert(msg.totalAmount == finalAmount + trampolineFees) assert(msg.additionalTlvs.head.isInstanceOf[OnionPaymentPayloadTlv.TrampolineOnion]) - assert(msg.maxAttempts === nodeParams.maxPaymentAttempts) + assert(msg.maxAttempts == nodeParams.maxPaymentAttempts) // Verify that the trampoline node can correctly peel the trampoline onion. val trampolineOnion = msg.additionalTlvs.head.asInstanceOf[OnionPaymentPayloadTlv.TrampolineOnion].packet val Right(decrypted) = Sphinx.peel(priv_b.privateKey, Some(invoice.paymentHash), trampolineOnion) assert(!decrypted.isLastPacket) val trampolinePayload = PaymentOnionCodecs.nodeRelayPerHopPayloadCodec.decode(decrypted.payload.bits).require.value - assert(trampolinePayload.amountToForward === finalAmount) - assert(trampolinePayload.totalAmount === finalAmount) - assert(trampolinePayload.outgoingCltv.toLong === currentBlockCount + 9 + 1) - assert(trampolinePayload.outgoingNodeId === c) - assert(trampolinePayload.paymentSecret === None) // we're not leaking the invoice secret to the trampoline node - assert(trampolinePayload.invoiceRoutingInfo === None) - assert(trampolinePayload.invoiceFeatures === None) + assert(trampolinePayload.amountToForward == finalAmount) + assert(trampolinePayload.totalAmount == finalAmount) + assert(trampolinePayload.outgoingCltv.toLong == currentBlockCount + 9 + 1) + assert(trampolinePayload.outgoingNodeId == c) + assert(trampolinePayload.paymentSecret == None) // we're not leaking the invoice secret to the trampoline node + assert(trampolinePayload.invoiceRoutingInfo == None) + assert(trampolinePayload.invoiceFeatures == None) // Verify that the recipient can correctly peel the trampoline onion. val Right(decrypted1) = Sphinx.peel(priv_c.privateKey, Some(invoice.paymentHash), decrypted.nextPacket) assert(decrypted1.isLastPacket) val finalPayload = PaymentOnionCodecs.finalPerHopPayloadCodec.decode(decrypted1.payload.bits).require.value - assert(finalPayload.amount === finalAmount) - assert(finalPayload.totalAmount === finalAmount) - assert(finalPayload.expiry.toLong === currentBlockCount + 9 + 1) - assert(finalPayload.paymentSecret === invoice.paymentSecret.get) + assert(finalPayload.amount == finalAmount) + assert(finalPayload.totalAmount == finalAmount) + assert(finalPayload.expiry.toLong == currentBlockCount + 9 + 1) + assert(finalPayload.paymentSecret == invoice.paymentSecret.get) } test("forward trampoline to legacy payment") { f => @@ -300,9 +300,9 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val msg = multiPartPayFsm.expectMsgType[SendMultiPartPayment] assert(msg.paymentSecret !== invoice.paymentSecret.get) // we should not leak the invoice secret to the trampoline node - assert(msg.targetNodeId === b) - assert(msg.targetExpiry.toLong === currentBlockCount + 9 + 12 + 1) - assert(msg.totalAmount === finalAmount + trampolineFees) + assert(msg.targetNodeId == b) + assert(msg.targetExpiry.toLong == currentBlockCount + 9 + 12 + 1) + assert(msg.totalAmount == finalAmount + trampolineFees) assert(msg.additionalTlvs.head.isInstanceOf[OnionPaymentPayloadTlv.TrampolineOnion]) // Verify that the trampoline node can correctly peel the trampoline onion. @@ -310,12 +310,12 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val Right(decrypted) = Sphinx.peel(priv_b.privateKey, Some(invoice.paymentHash), trampolineOnion) assert(!decrypted.isLastPacket) val trampolinePayload = PaymentOnionCodecs.nodeRelayPerHopPayloadCodec.decode(decrypted.payload.bits).require.value - assert(trampolinePayload.amountToForward === finalAmount) - assert(trampolinePayload.totalAmount === finalAmount) - assert(trampolinePayload.outgoingCltv.toLong === currentBlockCount + 9 + 1) - assert(trampolinePayload.outgoingNodeId === c) - assert(trampolinePayload.paymentSecret === invoice.paymentSecret) - assert(trampolinePayload.invoiceFeatures === Some(hex"4100")) // var_onion_optin, payment_secret + assert(trampolinePayload.amountToForward == finalAmount) + assert(trampolinePayload.totalAmount == finalAmount) + assert(trampolinePayload.outgoingCltv.toLong == currentBlockCount + 9 + 1) + assert(trampolinePayload.outgoingNodeId == c) + assert(trampolinePayload.paymentSecret == invoice.paymentSecret) + assert(trampolinePayload.invoiceFeatures == Some(hex"4100")) // var_onion_optin, payment_secret } test("reject trampoline to legacy payment for 0-value invoice") { f => @@ -328,8 +328,8 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(initiator, req) val id = sender.expectMsgType[UUID] val fail = sender.expectMsgType[PaymentFailed] - assert(fail.id === id) - assert(fail.failures === LocalFailure(finalAmount, Nil, PaymentError.TrampolineLegacyAmountLessInvoice) :: Nil) + assert(fail.id == id) + assert(fail.failures == LocalFailure(finalAmount, Nil, PaymentError.TrampolineLegacyAmountLessInvoice) :: Nil) multiPartPayFsm.expectNoMessage(50 millis) payFsm.expectNoMessage(50 millis) @@ -344,9 +344,9 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike sender.send(initiator, req) val id = sender.expectMsgType[UUID] val fail = sender.expectMsgType[PaymentFailed] - assert(fail.id === id) - assert(fail.failures.length === 1) - assert(fail.failures.head.asInstanceOf[LocalFailure].t.getMessage === "requirement failed: packet per-hop payloads cannot exceed 400 bytes") + assert(fail.id == id) + assert(fail.failures.length == 1) + assert(fail.failures.head.asInstanceOf[LocalFailure].t.getMessage == "requirement failed: packet per-hop payloads cannot exceed 400 bytes") } test("retry trampoline payment") { f => @@ -361,7 +361,7 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike assert(!cfg.publishEvent) val msg1 = multiPartPayFsm.expectMsgType[SendMultiPartPayment] - assert(msg1.totalAmount === finalAmount + 21000.msat) + assert(msg1.totalAmount == finalAmount + 21000.msat) sender.send(initiator, GetPayment(Left(id))) sender.expectMsgType[PaymentIsPending] @@ -370,7 +370,7 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike multiPartPayFsm.send(initiator, PaymentFailed(cfg.parentId, invoice.paymentHash, Seq(RemoteFailure(msg1.totalAmount, Nil, Sphinx.DecryptedFailurePacket(b, TrampolineFeeInsufficient))))) multiPartPayFsm.expectMsgType[SendPaymentConfig] val msg2 = multiPartPayFsm.expectMsgType[SendMultiPartPayment] - assert(msg2.totalAmount === finalAmount + 25000.msat) + assert(msg2.totalAmount == finalAmount + 25000.msat) // Simulate success which should publish the event and respond to the original sender. val success = PaymentSent(cfg.parentId, invoice.paymentHash, randomBytes32(), finalAmount, c, Seq(PaymentSent.PartialPayment(UUID.randomUUID(), 1000 msat, 500 msat, randomBytes32(), None))) @@ -396,13 +396,13 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike assert(!cfg.publishEvent) val msg1 = multiPartPayFsm.expectMsgType[SendMultiPartPayment] - assert(msg1.totalAmount === finalAmount + 21000.msat) + assert(msg1.totalAmount == finalAmount + 21000.msat) // Simulate a failure which should trigger a retry. multiPartPayFsm.send(initiator, PaymentFailed(cfg.parentId, invoice.paymentHash, Seq(RemoteFailure(msg1.totalAmount, Nil, Sphinx.DecryptedFailurePacket(b, TrampolineFeeInsufficient))))) multiPartPayFsm.expectMsgType[SendPaymentConfig] val msg2 = multiPartPayFsm.expectMsgType[SendMultiPartPayment] - assert(msg2.totalAmount === finalAmount + 25000.msat) + assert(msg2.totalAmount == finalAmount + 25000.msat) // Simulate a failure that exhausts payment attempts. val failed = PaymentFailed(cfg.parentId, invoice.paymentHash, Seq(RemoteFailure(msg2.totalAmount, Nil, Sphinx.DecryptedFailurePacket(b, TemporaryNodeFailure)))) @@ -423,18 +423,18 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val cfg = multiPartPayFsm.expectMsgType[SendPaymentConfig] val msg1 = multiPartPayFsm.expectMsgType[SendMultiPartPayment] - assert(msg1.totalAmount === finalAmount + 21000.msat) + assert(msg1.totalAmount == finalAmount + 21000.msat) // Trampoline node couldn't find a route for the given fee. val failed = PaymentFailed(cfg.parentId, invoice.paymentHash, Seq(RemoteFailure(msg1.totalAmount, Nil, Sphinx.DecryptedFailurePacket(b, TrampolineFeeInsufficient)))) multiPartPayFsm.send(initiator, failed) multiPartPayFsm.expectMsgType[SendPaymentConfig] val msg2 = multiPartPayFsm.expectMsgType[SendMultiPartPayment] - assert(msg2.totalAmount === finalAmount + 25000.msat) + assert(msg2.totalAmount == finalAmount + 25000.msat) // Trampoline node couldn't find a route even with the increased fee. multiPartPayFsm.send(initiator, failed) val failure = sender.expectMsgType[PaymentFailed] - assert(failure.failures === Seq(LocalFailure(finalAmount, Seq(NodeHop(nodeParams.nodeId, b, nodeParams.channelConf.expiryDelta, 0 msat), NodeHop(b, c, CltvExpiryDelta(24), 25000 msat)), RouteNotFound))) + assert(failure.failures == Seq(LocalFailure(finalAmount, Seq(NodeHop(nodeParams.nodeId, b, nodeParams.channelConf.expiryDelta, 0 msat), NodeHop(b, c, CltvExpiryDelta(24), 25000 msat)), RouteNotFound))) eventListener.expectMsg(failure) sender.expectNoMessage(100 millis) eventListener.expectNoMessage(100 millis) @@ -451,10 +451,10 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike assert(payment.trampolineSecret.nonEmpty) payFsm.expectMsg(SendPaymentConfig(payment.paymentId, payment.parentId, None, paymentHash, finalAmount, c, Upstream.Local(payment.paymentId), Some(invoice), storeInDb = true, publishEvent = true, recordPathFindingMetrics = false, Seq(NodeHop(b, c, CltvExpiryDelta(0), 0 msat)))) val msg = payFsm.expectMsgType[PaymentLifecycle.SendPaymentToRoute] - assert(msg.route === Left(route)) - assert(msg.finalPayload.amount === finalAmount + trampolineFees) - assert(msg.finalPayload.paymentSecret === payment.trampolineSecret.get) - assert(msg.finalPayload.totalAmount === finalAmount + trampolineFees) + assert(msg.route == Left(route)) + assert(msg.finalPayload.amount == finalAmount + trampolineFees) + assert(msg.finalPayload.paymentSecret == payment.trampolineSecret.get) + assert(msg.finalPayload.totalAmount == finalAmount + trampolineFees) assert(msg.finalPayload.isInstanceOf[PaymentOnion.FinalTlvPayload]) val trampolineOnion = msg.finalPayload.asInstanceOf[PaymentOnion.FinalTlvPayload].records.get[OnionPaymentPayloadTlv.TrampolineOnion] assert(trampolineOnion.nonEmpty) @@ -463,10 +463,10 @@ class PaymentInitiatorSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike val Right(decrypted) = Sphinx.peel(priv_b.privateKey, Some(invoice.paymentHash), trampolineOnion.get.packet) assert(!decrypted.isLastPacket) val trampolinePayload = PaymentOnionCodecs.nodeRelayPerHopPayloadCodec.decode(decrypted.payload.bits).require.value - assert(trampolinePayload.amountToForward === finalAmount) - assert(trampolinePayload.totalAmount === finalAmount) - assert(trampolinePayload.outgoingNodeId === c) - assert(trampolinePayload.paymentSecret === invoice.paymentSecret) + assert(trampolinePayload.amountToForward == finalAmount) + assert(trampolinePayload.totalAmount == finalAmount) + assert(trampolinePayload.outgoingNodeId == c) + assert(trampolinePayload.paymentSecret == invoice.paymentSecret) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentLifecycleSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentLifecycleSpec.scala index c0fedefb3a..f766cdc821 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentLifecycleSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentLifecycleSpec.scala @@ -112,12 +112,12 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val Transition(_, WAITING_FOR_ROUTE, WAITING_FOR_PAYMENT_COMPLETE) = monitor.expectMsgClass(classOf[Transition[_]]) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val Some(outgoing) = nodeParams.db.payments.getOutgoingPayment(id) - assert(outgoing.copy(createdAt = 0 unixms) === OutgoingPayment(id, parentId, Some(defaultExternalId), defaultPaymentHash, PaymentType.Standard, defaultAmountMsat, defaultAmountMsat, d, 0 unixms, Some(defaultInvoice), OutgoingPaymentStatus.Pending)) + assert(outgoing.copy(createdAt = 0 unixms) == OutgoingPayment(id, parentId, Some(defaultExternalId), defaultPaymentHash, PaymentType.Standard, defaultAmountMsat, defaultAmountMsat, d, 0 unixms, Some(defaultInvoice), OutgoingPaymentStatus.Pending)) sender.send(paymentFSM, addCompleted(HtlcResult.RemoteFulfill(UpdateFulfillHtlc(ByteVector32.Zeroes, 0, defaultPaymentPreimage)))) val ps = sender.expectMsgType[PaymentSent] - assert(ps.id === parentId) - assert(ps.parts.head.route === Some(route.hops)) + assert(ps.id == parentId) + assert(ps.parts.head.route == Some(route.hops)) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status.isInstanceOf[OutgoingPaymentStatus.Succeeded])) metricsListener.expectNoMessage() @@ -140,11 +140,11 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val Transition(_, WAITING_FOR_ROUTE, WAITING_FOR_PAYMENT_COMPLETE) = monitor.expectMsgClass(classOf[Transition[_]]) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val Some(outgoing) = nodeParams.db.payments.getOutgoingPayment(id) - assert(outgoing.copy(createdAt = 0 unixms) === OutgoingPayment(id, parentId, Some(defaultExternalId), defaultPaymentHash, PaymentType.Standard, defaultAmountMsat, defaultAmountMsat, d, 0 unixms, Some(defaultInvoice), OutgoingPaymentStatus.Pending)) + assert(outgoing.copy(createdAt = 0 unixms) == OutgoingPayment(id, parentId, Some(defaultExternalId), defaultPaymentHash, PaymentType.Standard, defaultAmountMsat, defaultAmountMsat, d, 0 unixms, Some(defaultInvoice), OutgoingPaymentStatus.Pending)) sender.send(paymentFSM, addCompleted(HtlcResult.RemoteFulfill(UpdateFulfillHtlc(ByteVector32.Zeroes, 0, defaultPaymentPreimage)))) val ps = sender.expectMsgType[PaymentSent] - assert(ps.id === parentId) + assert(ps.id == parentId) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status.isInstanceOf[OutgoingPaymentStatus.Succeeded])) metricsListener.expectNoMessage() @@ -201,7 +201,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { sender.send(paymentFSM, addCompleted(HtlcResult.OnChainFulfill(defaultPaymentPreimage))) val ps = sender.expectMsgType[PaymentSent] - assert(ps.id === parentId) + assert(ps.id == parentId) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status.isInstanceOf[OutgoingPaymentStatus.Succeeded])) metricsListener.expectNoMessage() @@ -216,10 +216,10 @@ class PaymentLifecycleSpec extends BaseRouterSpec { sender.send(paymentFSM, request) val Transition(_, WAITING_FOR_REQUEST, WAITING_FOR_ROUTE) = monitor.expectMsgClass(classOf[Transition[_]]) val routeRequest = routerForwarder.expectMsgType[RouteRequest] - awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) routerForwarder.forward(routerFixture.router, routeRequest) - assert(sender.expectMsgType[PaymentFailed].failures === LocalFailure(defaultAmountMsat, Nil, RouteNotFound) :: Nil) + assert(sender.expectMsgType[PaymentFailed].failures == LocalFailure(defaultAmountMsat, Nil, RouteNotFound) :: Nil) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status.isInstanceOf[OutgoingPaymentStatus.Failed])) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] @@ -273,7 +273,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { routerForwarder.forward(routerFixture.router, routeRequest) val pf = sender.expectMsgType[PaymentFailed] - assert(pf.failures.length === 1) + assert(pf.failures.length == 1) assert(pf.failures.head.isInstanceOf[LocalFailure]) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status.isInstanceOf[OutgoingPaymentStatus.Failed])) } @@ -286,7 +286,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 2, routeParams = defaultRouteParams) sender.send(paymentFSM, request) routerForwarder.expectMsg(defaultRouteRequest(a, d, cfg)) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val WaitingForRoute(_, Nil, _) = paymentFSM.stateData routerForwarder.forward(routerFixture.router) @@ -304,13 +304,13 @@ class PaymentLifecycleSpec extends BaseRouterSpec { sender.send(paymentFSM, RouteResponse(route :: Nil)) awaitCond(paymentFSM.stateName == WAITING_FOR_PAYMENT_COMPLETE) val WaitingForComplete(_, cmd2, _, _, ignore2, _) = paymentFSM.stateData - assert(ignore2.nodes === Set(c)) + assert(ignore2.nodes == Set(c)) // and reply a 2nd time with an unparsable failure register.expectMsg(ForwardShortId(paymentFSM, scid_ab, cmd2)) sender.send(paymentFSM, addCompleted(HtlcResult.RemoteFail(UpdateFailHtlc(ByteVector32.Zeroes, 0, defaultPaymentHash)))) // unparsable message // we allow 2 tries, so we send a 2nd request to the router - assert(sender.expectMsgType[PaymentFailed].failures === UnreadableRemoteFailure(route.amount, route.hops) :: UnreadableRemoteFailure(route.amount, route.hops) :: Nil) + assert(sender.expectMsgType[PaymentFailed].failures == UnreadableRemoteFailure(route.amount, route.hops) :: UnreadableRemoteFailure(route.amount, route.hops) :: Nil) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status.isInstanceOf[OutgoingPaymentStatus.Failed])) // after last attempt the payment is failed val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] @@ -328,7 +328,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 2, routeParams = defaultRouteParams) sender.send(paymentFSM, request) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) routerForwarder.expectMsgType[RouteRequest] routerForwarder.forward(routerFixture.router) awaitCond(paymentFSM.stateName == WAITING_FOR_PAYMENT_COMPLETE) @@ -339,7 +339,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { // then the payment lifecycle will ask for a new route excluding the channel routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg).copy(ignore = Ignore(Set.empty, Set(ChannelDesc(scid_ab, a, b))))) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) // payment is still pending because the error is recoverable + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) // payment is still pending because the error is recoverable } test("payment failed (register error)") { routerFixture => @@ -349,7 +349,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 2, routeParams = defaultRouteParams) sender.send(paymentFSM, request) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) routerForwarder.expectMsgType[RouteRequest] routerForwarder.forward(routerFixture.router) awaitCond(paymentFSM.stateName == WAITING_FOR_PAYMENT_COMPLETE) @@ -359,7 +359,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { // then the payment lifecycle will ask for a new route excluding the channel routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg).copy(ignore = Ignore(Set.empty, Set(ChannelDesc(scid_ab, a, b))))) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) // payment is still pending because the error is recoverable + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) // payment is still pending because the error is recoverable } test("payment failed (first hop returns an UpdateFailMalformedHtlc)") { routerFixture => @@ -369,7 +369,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 2, routeParams = defaultRouteParams) sender.send(paymentFSM, request) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val WaitingForRoute(_, Nil, _) = paymentFSM.stateData routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg)) @@ -382,7 +382,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { // then the payment lifecycle will ask for a new route excluding the channel routerForwarder.expectMsg(defaultRouteRequest(a, d, cfg).copy(ignore = Ignore(Set.empty, Set(ChannelDesc(scid_ab, a, b))))) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) } test("payment failed (first htlc failed on-chain)") { routerFixture => @@ -392,7 +392,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 2, routeParams = defaultRouteParams) sender.send(paymentFSM, request) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val WaitingForRoute(_, Nil, _) = paymentFSM.stateData routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg)) @@ -415,7 +415,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 2, routeParams = defaultRouteParams) sender.send(paymentFSM, request) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val WaitingForRoute(_, Nil, _) = paymentFSM.stateData routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg)) @@ -429,7 +429,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { // then the payment lifecycle will ask for a new route excluding the channel routerForwarder.expectMsg(defaultRouteRequest(a, d, cfg).copy(ignore = Ignore(Set.empty, Set(ChannelDesc(scid_ab, a, b))))) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) } test("payment failed (TemporaryChannelFailure)") { routerFixture => @@ -458,7 +458,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { routerForwarder.expectMsg(defaultRouteRequest(a, d, cfg).copy(ignore = Ignore(Set.empty, Set(ChannelDesc(update_bc.shortChannelId, b, c))))) routerForwarder.forward(routerFixture.router) // we allow 2 tries, so we send a 2nd request to the router - assert(sender.expectMsgType[PaymentFailed].failures === RemoteFailure(route.amount, route.hops, Sphinx.DecryptedFailurePacket(b, failure)) :: LocalFailure(defaultAmountMsat, Nil, RouteNotFound) :: Nil) + assert(sender.expectMsgType[PaymentFailed].failures == RemoteFailure(route.amount, route.hops, Sphinx.DecryptedFailurePacket(b, failure)) :: LocalFailure(defaultAmountMsat, Nil, RouteNotFound) :: Nil) } test("payment failed (Update)") { routerFixture => @@ -468,7 +468,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 5, routeParams = defaultRouteParams) sender.send(paymentFSM, request) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val WaitingForRoute(_, Nil, _) = paymentFSM.stateData routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg)) @@ -485,7 +485,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { // payment lifecycle forwards the embedded channelUpdate to the router routerForwarder.expectMsg(channelUpdate_bc_modified) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) // 1 failure but not final, the payment is still PENDING + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) // 1 failure but not final, the payment is still PENDING routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg)) routerForwarder.forward(routerFixture.router) @@ -510,7 +510,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { routerForwarder.forward(routerFixture.router) // this time the router can't find a route: game over - assert(sender.expectMsgType[PaymentFailed].failures === RemoteFailure(route1.amount, route1.hops, Sphinx.DecryptedFailurePacket(b, failure)) :: RemoteFailure(route2.amount, route2.hops, Sphinx.DecryptedFailurePacket(b, failure2)) :: LocalFailure(defaultAmountMsat, Nil, RouteNotFound) :: Nil) + assert(sender.expectMsgType[PaymentFailed].failures == RemoteFailure(route1.amount, route1.hops, Sphinx.DecryptedFailurePacket(b, failure)) :: RemoteFailure(route2.amount, route2.hops, Sphinx.DecryptedFailurePacket(b, failure2)) :: LocalFailure(defaultAmountMsat, Nil, RouteNotFound) :: Nil) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status.isInstanceOf[OutgoingPaymentStatus.Failed])) } @@ -550,7 +550,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 5, assistedRoutes = assistedRoutes, routeParams = defaultRouteParams) sender.send(paymentFSM, request) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val WaitingForRoute(_, Nil, _) = paymentFSM.stateData routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg).copy(assistedRoutes = assistedRoutes)) @@ -567,7 +567,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { // payment lifecycle forwards the embedded channelUpdate to the router routerForwarder.expectMsg(channelUpdate_bc_modified) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) // 1 failure but not final, the payment is still PENDING + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) // 1 failure but not final, the payment is still PENDING val assistedRoutes1 = Seq(Seq( ExtraHop(b, scid_bc, update_bc.feeBaseMsat, update_bc.feeProportionalMillionths, channelUpdate_bc_modified.cltvExpiryDelta), ExtraHop(c, scid_cd, update_cd.feeBaseMsat, update_cd.feeProportionalMillionths, update_cd.cltvExpiryDelta) @@ -591,7 +591,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val assistedRoutes = Seq(Seq(ExtraHop(c, scid_cd, update_cd.feeBaseMsat, update_cd.feeProportionalMillionths, update_cd.cltvExpiryDelta))) val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 1, assistedRoutes = assistedRoutes, routeParams = defaultRouteParams) sender.send(paymentFSM, request) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg).copy(assistedRoutes = assistedRoutes)) routerForwarder.forward(routerFixture.router) @@ -616,7 +616,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val request = SendPaymentToNode(sender.ref, d, PaymentOnion.createSinglePartPayload(defaultAmountMsat, defaultExpiry, defaultInvoice.paymentSecret.get, defaultInvoice.paymentMetadata), 2, routeParams = defaultRouteParams) sender.send(paymentFSM, request) - awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(paymentFSM.stateName == WAITING_FOR_ROUTE && nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val WaitingForRoute(_, Nil, _) = paymentFSM.stateData routerForwarder.expectMsg(defaultRouteRequest(nodeParams.nodeId, d, cfg)) @@ -633,7 +633,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { routerForwarder.forward(router) // we allow 2 tries, so we send a 2nd request to the router, which won't find another route - assert(sender.expectMsgType[PaymentFailed].failures === RemoteFailure(route1.amount, route1.hops, Sphinx.DecryptedFailurePacket(b, failure)) :: LocalFailure(defaultAmountMsat, Nil, RouteNotFound) :: Nil) + assert(sender.expectMsgType[PaymentFailed].failures == RemoteFailure(route1.amount, route1.hops, Sphinx.DecryptedFailurePacket(b, failure)) :: LocalFailure(defaultAmountMsat, Nil, RouteNotFound) :: Nil) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status.isInstanceOf[OutgoingPaymentStatus.Failed])) } @@ -658,18 +658,18 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val Transition(_, WAITING_FOR_REQUEST, WAITING_FOR_ROUTE) = monitor.expectMsgClass(classOf[Transition[_]]) routerForwarder.forward(routerFixture.router) val Transition(_, WAITING_FOR_ROUTE, WAITING_FOR_PAYMENT_COMPLETE) = monitor.expectMsgClass(classOf[Transition[_]]) - awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status === OutgoingPaymentStatus.Pending)) + awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val Some(outgoing) = nodeParams.db.payments.getOutgoingPayment(id) - assert(outgoing.copy(createdAt = 0 unixms) === OutgoingPayment(id, parentId, Some(defaultExternalId), defaultPaymentHash, PaymentType.Standard, defaultAmountMsat, defaultAmountMsat, d, 0 unixms, Some(defaultInvoice), OutgoingPaymentStatus.Pending)) + assert(outgoing.copy(createdAt = 0 unixms) == OutgoingPayment(id, parentId, Some(defaultExternalId), defaultPaymentHash, PaymentType.Standard, defaultAmountMsat, defaultAmountMsat, d, 0 unixms, Some(defaultInvoice), OutgoingPaymentStatus.Pending)) sender.send(paymentFSM, addCompleted(HtlcResult.RemoteFulfill(UpdateFulfillHtlc(ByteVector32.Zeroes, 0, defaultPaymentPreimage)))) val ps = eventListener.expectMsgType[PaymentSent] - assert(ps.id === parentId) + assert(ps.id == parentId) assert(ps.feesPaid > 0.msat) - assert(ps.recipientAmount === defaultAmountMsat) - assert(ps.paymentHash === defaultPaymentHash) - assert(ps.paymentPreimage === defaultPaymentPreimage) - assert(ps.parts.head.id === id) + assert(ps.recipientAmount == defaultAmountMsat) + assert(ps.paymentHash == defaultPaymentHash) + assert(ps.paymentPreimage == defaultPaymentPreimage) + assert(ps.parts.head.id == id) awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status.isInstanceOf[OutgoingPaymentStatus.Succeeded])) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] @@ -693,12 +693,12 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val chan_bh = channelAnnouncement(channelId_bh, priv_b, priv_h, priv_funding_b, priv_funding_h) val channelUpdate_bh = makeChannelUpdate(Block.RegtestGenesisBlock.hash, priv_b, h, channelId_bh, CltvExpiryDelta(9), htlcMinimumMsat = 0 msat, feeBaseMsat = 0 msat, feeProportionalMillionths = 0, htlcMaximumMsat = 500000000 msat) val channelUpdate_hb = makeChannelUpdate(Block.RegtestGenesisBlock.hash, priv_h, b, channelId_bh, CltvExpiryDelta(9), htlcMinimumMsat = 0 msat, feeBaseMsat = 10 msat, feeProportionalMillionths = 8, htlcMaximumMsat = 500000000 msat) - assert(ChannelDesc(channelUpdate_bh, chan_bh) === ChannelDesc(channelId_bh, priv_b.publicKey, priv_h.publicKey)) + assert(ChannelDesc(channelUpdate_bh, chan_bh) == ChannelDesc(channelId_bh, priv_b.publicKey, priv_h.publicKey)) val peerConnection = TestProbe() router ! PeerRoutingMessage(peerConnection.ref, remoteNodeId, chan_bh) router ! PeerRoutingMessage(peerConnection.ref, remoteNodeId, channelUpdate_bh) router ! PeerRoutingMessage(peerConnection.ref, remoteNodeId, channelUpdate_hb) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_bh) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_bh) watcher.send(router, ValidateResult(chan_bh, Right((Transaction(version = 0, txIn = Nil, txOut = TxOut(1000000 sat, write(pay2wsh(Scripts.multiSig2of2(funding_b, funding_h)))) :: Nil, lockTime = 0), UtxoStatus.Unspent)))) watcher.expectMsgType[WatchExternalChannelSpent] @@ -718,12 +718,12 @@ class PaymentLifecycleSpec extends BaseRouterSpec { sender.send(paymentFSM, addCompleted(HtlcResult.OnChainFulfill(defaultPaymentPreimage))) val paymentOK = sender.expectMsgType[PaymentSent] val PaymentSent(_, _, paymentOK.paymentPreimage, finalAmount, _, PartialPayment(_, request.finalPayload.amount, fee, ByteVector32.Zeroes, _, _) :: Nil) = eventListener.expectMsgType[PaymentSent] - assert(finalAmount === defaultAmountMsat) + assert(finalAmount == defaultAmountMsat) // NB: A -> B doesn't pay fees because it's our direct neighbor // NB: B -> H doesn't asks for fees at all - assert(fee === 0.msat) - assert(paymentOK.recipientAmount === request.finalPayload.amount) + assert(fee == 0.msat) + assert(paymentOK.recipientAmount == request.finalPayload.amount) val metrics = metricsListener.expectMsgType[PathFindingExperimentMetrics] assert(metrics.status == "SUCCESS") @@ -746,7 +746,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { RemoteFailure(defaultAmountMsat, channelHopFromUpdate(a, b, update_ab) :: Nil, Sphinx.DecryptedFailurePacket(a, TemporaryNodeFailure)), LocalFailure(defaultAmountMsat, channelHopFromUpdate(a, b, update_ab) :: Nil, ChannelUnavailable(ByteVector32.Zeroes)) ) - assert(filtered === expected) + assert(filtered == expected) } test("ignore failed nodes/channels") { _ => @@ -771,8 +771,8 @@ class PaymentLifecycleSpec extends BaseRouterSpec { for ((failure, expectedNodes, expectedChannels) <- testCases) { val ignore = PaymentFailure.updateIgnored(failure, Ignore.empty) - assert(ignore.nodes === expectedNodes, failure) - assert(ignore.channels === expectedChannels, failure) + assert(ignore.nodes == expectedNodes, failure) + assert(ignore.channels == expectedChannels, failure) } val failures = Seq( @@ -781,8 +781,8 @@ class PaymentLifecycleSpec extends BaseRouterSpec { LocalFailure(defaultAmountMsat, route_abcd, new RuntimeException("fatal")) ) val ignore = PaymentFailure.updateIgnored(failures, Ignore.empty) - assert(ignore.nodes === Set(c)) - assert(ignore.channels === Set(ChannelDesc(scid_ab, a, b), ChannelDesc(scid_bc, b, c))) + assert(ignore.nodes == Set(c)) + assert(ignore.channels == Set(ChannelDesc(scid_ab, a, b), ChannelDesc(scid_bc, b, c))) } test("disable database and events") { routerFixture => @@ -796,11 +796,11 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val Transition(_, WAITING_FOR_REQUEST, WAITING_FOR_ROUTE) = monitor.expectMsgClass(classOf[Transition[_]]) routerForwarder.forward(routerFixture.router) val Transition(_, WAITING_FOR_ROUTE, WAITING_FOR_PAYMENT_COMPLETE) = monitor.expectMsgClass(classOf[Transition[_]]) - assert(nodeParams.db.payments.getOutgoingPayment(id) === None) + assert(nodeParams.db.payments.getOutgoingPayment(id) == None) sender.send(paymentFSM, addCompleted(HtlcResult.RemoteFulfill(UpdateFulfillHtlc(ByteVector32.Zeroes, 0, defaultPaymentPreimage)))) sender.expectMsgType[PaymentSent] - assert(nodeParams.db.payments.getOutgoingPayment(id) === None) + assert(nodeParams.db.payments.getOutgoingPayment(id) == None) eventListener.expectNoMessage(100 millis) } @@ -820,7 +820,7 @@ class PaymentLifecycleSpec extends BaseRouterSpec { val WaitingForComplete(_, _, Nil, sharedSecrets1, _, _) = paymentFSM.stateData awaitCond(nodeParams.db.payments.getOutgoingPayment(id).exists(_.status == OutgoingPaymentStatus.Pending)) val Some(outgoing) = nodeParams.db.payments.getOutgoingPayment(id) - assert(outgoing.copy(createdAt = 0 unixms) === OutgoingPayment(id, parentId, Some(defaultExternalId), defaultPaymentHash, PaymentType.Standard, defaultAmountMsat, defaultAmountMsat, d, 0 unixms, Some(defaultInvoice), OutgoingPaymentStatus.Pending)) + assert(outgoing.copy(createdAt = 0 unixms) == OutgoingPayment(id, parentId, Some(defaultExternalId), defaultPaymentHash, PaymentType.Standard, defaultAmountMsat, defaultAmountMsat, d, 0 unixms, Some(defaultInvoice), OutgoingPaymentStatus.Pending)) // we change the cltv expiry val channelUpdate_bc_modified = makeChannelUpdate(Block.RegtestGenesisBlock.hash, priv_b, c, scid_bc, CltvExpiryDelta(42), htlcMinimumMsat = update_bc.htlcMinimumMsat, feeBaseMsat = update_bc.feeBaseMsat, feeProportionalMillionths = update_bc.feeProportionalMillionths, htlcMaximumMsat = update_bc.htlcMaximumMsat.get) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentPacketSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentPacketSpec.scala index 3193df2d3e..491f200789 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentPacketSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentPacketSpec.scala @@ -59,15 +59,15 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { // spec: fee-base-msat + htlc-amount-msat * fee-proportional-millionths / 1000000 val ref = feeBaseMsat + htlcAmountMsat * feeProportionalMillionth / 1000000 val fee = nodeFee(feeBaseMsat, feeProportionalMillionth, htlcAmountMsat) - assert(ref === fee) + assert(ref == fee) } def testBuildOnion(): Unit = { val finalPayload = FinalTlvPayload(TlvStream(AmountToForward(finalAmount), OutgoingCltv(finalExpiry), PaymentData(paymentSecret, 0 msat))) val Success((firstAmount, firstExpiry, onion)) = buildPaymentPacket(paymentHash, hops, finalPayload) - assert(firstAmount === amount_ab) - assert(firstExpiry === expiry_ab) - assert(onion.packet.payload.length === PaymentOnionCodecs.paymentOnionPayloadLength) + assert(firstAmount == amount_ab) + assert(firstExpiry == expiry_ab) + assert(onion.packet.payload.length == PaymentOnionCodecs.paymentOnionPayloadLength) // let's peel the onion testPeelOnion(onion.packet) @@ -76,41 +76,41 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { def testPeelOnion(packet_b: OnionRoutingPacket): Unit = { val add_b = UpdateAddHtlc(randomBytes32(), 0, amount_ab, paymentHash, expiry_ab, packet_b) val Right(relay_b@ChannelRelayPacket(add_b2, payload_b, packet_c)) = decrypt(add_b, priv_b.privateKey) - assert(add_b2 === add_b) - assert(packet_c.payload.length === PaymentOnionCodecs.paymentOnionPayloadLength) - assert(payload_b.amountToForward === amount_bc) - assert(payload_b.outgoingCltv === expiry_bc) - assert(payload_b.outgoingChannelId === channelUpdate_bc.shortChannelId) - assert(relay_b.relayFeeMsat === fee_b) - assert(relay_b.expiryDelta === channelUpdate_bc.cltvExpiryDelta) + assert(add_b2 == add_b) + assert(packet_c.payload.length == PaymentOnionCodecs.paymentOnionPayloadLength) + assert(payload_b.amountToForward == amount_bc) + assert(payload_b.outgoingCltv == expiry_bc) + assert(payload_b.outgoingChannelId == channelUpdate_bc.shortChannelId) + assert(relay_b.relayFeeMsat == fee_b) + assert(relay_b.expiryDelta == channelUpdate_bc.cltvExpiryDelta) val add_c = UpdateAddHtlc(randomBytes32(), 1, amount_bc, paymentHash, expiry_bc, packet_c) val Right(relay_c@ChannelRelayPacket(add_c2, payload_c, packet_d)) = decrypt(add_c, priv_c.privateKey) - assert(add_c2 === add_c) - assert(packet_d.payload.length === PaymentOnionCodecs.paymentOnionPayloadLength) - assert(payload_c.amountToForward === amount_cd) - assert(payload_c.outgoingCltv === expiry_cd) - assert(payload_c.outgoingChannelId === channelUpdate_cd.shortChannelId) - assert(relay_c.relayFeeMsat === fee_c) - assert(relay_c.expiryDelta === channelUpdate_cd.cltvExpiryDelta) + assert(add_c2 == add_c) + assert(packet_d.payload.length == PaymentOnionCodecs.paymentOnionPayloadLength) + assert(payload_c.amountToForward == amount_cd) + assert(payload_c.outgoingCltv == expiry_cd) + assert(payload_c.outgoingChannelId == channelUpdate_cd.shortChannelId) + assert(relay_c.relayFeeMsat == fee_c) + assert(relay_c.expiryDelta == channelUpdate_cd.cltvExpiryDelta) val add_d = UpdateAddHtlc(randomBytes32(), 2, amount_cd, paymentHash, expiry_cd, packet_d) val Right(relay_d@ChannelRelayPacket(add_d2, payload_d, packet_e)) = decrypt(add_d, priv_d.privateKey) - assert(add_d2 === add_d) - assert(packet_e.payload.length === PaymentOnionCodecs.paymentOnionPayloadLength) - assert(payload_d.amountToForward === amount_de) - assert(payload_d.outgoingCltv === expiry_de) - assert(payload_d.outgoingChannelId === channelUpdate_de.shortChannelId) - assert(relay_d.relayFeeMsat === fee_d) - assert(relay_d.expiryDelta === channelUpdate_de.cltvExpiryDelta) + assert(add_d2 == add_d) + assert(packet_e.payload.length == PaymentOnionCodecs.paymentOnionPayloadLength) + assert(payload_d.amountToForward == amount_de) + assert(payload_d.outgoingCltv == expiry_de) + assert(payload_d.outgoingChannelId == channelUpdate_de.shortChannelId) + assert(relay_d.relayFeeMsat == fee_d) + assert(relay_d.expiryDelta == channelUpdate_de.cltvExpiryDelta) val add_e = UpdateAddHtlc(randomBytes32(), 2, amount_de, paymentHash, expiry_de, packet_e) val Right(FinalPacket(add_e2, payload_e)) = decrypt(add_e, priv_e.privateKey) - assert(add_e2 === add_e) - assert(payload_e.amount === finalAmount) - assert(payload_e.totalAmount === finalAmount) - assert(payload_e.expiry === finalExpiry) - assert(payload_e.paymentSecret === paymentSecret) + assert(add_e2 == add_e) + assert(payload_e.amount == finalAmount) + assert(payload_e.totalAmount == finalAmount) + assert(payload_e.expiry == finalExpiry) + assert(payload_e.paymentSecret == paymentSecret) } test("build onion with final payload") { @@ -120,9 +120,9 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { test("build a command including the onion") { val Success((add, _)) = buildCommand(ActorRef.noSender, Upstream.Local(UUID.randomUUID), paymentHash, hops, PaymentOnion.createSinglePartPayload(finalAmount, finalExpiry, paymentSecret, None)) assert(add.amount > finalAmount) - assert(add.cltvExpiry === finalExpiry + channelUpdate_de.cltvExpiryDelta + channelUpdate_cd.cltvExpiryDelta + channelUpdate_bc.cltvExpiryDelta) - assert(add.paymentHash === paymentHash) - assert(add.onion.payload.length === PaymentOnionCodecs.paymentOnionPayloadLength) + assert(add.cltvExpiry == finalExpiry + channelUpdate_de.cltvExpiryDelta + channelUpdate_cd.cltvExpiryDelta + channelUpdate_bc.cltvExpiryDelta) + assert(add.paymentHash == paymentHash) + assert(add.onion.payload.length == PaymentOnionCodecs.paymentOnionPayloadLength) // let's peel the onion testPeelOnion(add.onion) @@ -130,20 +130,20 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { test("build a command with no hops") { val Success((add, _)) = buildCommand(ActorRef.noSender, Upstream.Local(UUID.randomUUID()), paymentHash, hops.take(1), PaymentOnion.createSinglePartPayload(finalAmount, finalExpiry, paymentSecret, Some(paymentMetadata))) - assert(add.amount === finalAmount) - assert(add.cltvExpiry === finalExpiry) - assert(add.paymentHash === paymentHash) - assert(add.onion.payload.length === PaymentOnionCodecs.paymentOnionPayloadLength) + assert(add.amount == finalAmount) + assert(add.cltvExpiry == finalExpiry) + assert(add.paymentHash == paymentHash) + assert(add.onion.payload.length == PaymentOnionCodecs.paymentOnionPayloadLength) // let's peel the onion val add_b = UpdateAddHtlc(randomBytes32(), 0, finalAmount, paymentHash, finalExpiry, add.onion) val Right(FinalPacket(add_b2, payload_b)) = decrypt(add_b, priv_b.privateKey) - assert(add_b2 === add_b) - assert(payload_b.amount === finalAmount) - assert(payload_b.totalAmount === finalAmount) - assert(payload_b.expiry === finalExpiry) - assert(payload_b.paymentSecret === paymentSecret) - assert(payload_b.paymentMetadata === Some(paymentMetadata)) + assert(add_b2 == add_b) + assert(payload_b.amount == finalAmount) + assert(payload_b.totalAmount == finalAmount) + assert(payload_b.expiry == finalExpiry) + assert(payload_b.paymentSecret == paymentSecret) + assert(payload_b.paymentMetadata == Some(paymentMetadata)) } test("build a trampoline payment") { @@ -153,58 +153,58 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { // a -> b -> c d e val Success((amount_ac, expiry_ac, trampolineOnion)) = buildTrampolinePacket(paymentHash, trampolineHops, PaymentOnion.createMultiPartPayload(finalAmount, finalAmount * 3, finalExpiry, paymentSecret, Some(hex"010203"))) - assert(amount_ac === amount_bc) - assert(expiry_ac === expiry_bc) + assert(amount_ac == amount_bc) + assert(expiry_ac == expiry_bc) val Success((firstAmount, firstExpiry, onion)) = buildPaymentPacket(paymentHash, trampolineChannelHops, PaymentOnion.createTrampolinePayload(amount_ac, amount_ac, expiry_ac, randomBytes32(), trampolineOnion.packet)) - assert(firstAmount === amount_ab) - assert(firstExpiry === expiry_ab) + assert(firstAmount == amount_ab) + assert(firstExpiry == expiry_ab) val add_b = UpdateAddHtlc(randomBytes32(), 1, firstAmount, paymentHash, firstExpiry, onion.packet) val Right(ChannelRelayPacket(add_b2, payload_b, packet_c)) = decrypt(add_b, priv_b.privateKey) - assert(add_b2 === add_b) - assert(payload_b === ChannelRelayTlvPayload(channelUpdate_bc.shortChannelId, amount_bc, expiry_bc)) + assert(add_b2 == add_b) + assert(payload_b == ChannelRelayTlvPayload(channelUpdate_bc.shortChannelId, amount_bc, expiry_bc)) val add_c = UpdateAddHtlc(randomBytes32(), 2, amount_bc, paymentHash, expiry_bc, packet_c) val Right(NodeRelayPacket(add_c2, outer_c, inner_c, packet_d)) = decrypt(add_c, priv_c.privateKey) - assert(add_c2 === add_c) - assert(outer_c.amount === amount_bc) - assert(outer_c.totalAmount === amount_bc) - assert(outer_c.expiry === expiry_bc) - assert(inner_c.amountToForward === amount_cd) - assert(inner_c.outgoingCltv === expiry_cd) - assert(inner_c.outgoingNodeId === d) - assert(inner_c.invoiceRoutingInfo === None) - assert(inner_c.invoiceFeatures === None) - assert(inner_c.paymentSecret === None) - assert(inner_c.paymentMetadata === None) + assert(add_c2 == add_c) + assert(outer_c.amount == amount_bc) + assert(outer_c.totalAmount == amount_bc) + assert(outer_c.expiry == expiry_bc) + assert(inner_c.amountToForward == amount_cd) + assert(inner_c.outgoingCltv == expiry_cd) + assert(inner_c.outgoingNodeId == d) + assert(inner_c.invoiceRoutingInfo == None) + assert(inner_c.invoiceFeatures == None) + assert(inner_c.paymentSecret == None) + assert(inner_c.paymentMetadata == None) // c forwards the trampoline payment to d. val Success((amount_d, expiry_d, onion_d)) = buildPaymentPacket(paymentHash, channelHopFromUpdate(c, d, channelUpdate_cd) :: Nil, PaymentOnion.createTrampolinePayload(amount_cd, amount_cd, expiry_cd, randomBytes32(), packet_d)) - assert(amount_d === amount_cd) - assert(expiry_d === expiry_cd) + assert(amount_d == amount_cd) + assert(expiry_d == expiry_cd) val add_d = UpdateAddHtlc(randomBytes32(), 3, amount_d, paymentHash, expiry_d, onion_d.packet) val Right(NodeRelayPacket(add_d2, outer_d, inner_d, packet_e)) = decrypt(add_d, priv_d.privateKey) - assert(add_d2 === add_d) - assert(outer_d.amount === amount_cd) - assert(outer_d.totalAmount === amount_cd) - assert(outer_d.expiry === expiry_cd) - assert(inner_d.amountToForward === amount_de) - assert(inner_d.outgoingCltv === expiry_de) - assert(inner_d.outgoingNodeId === e) - assert(inner_d.invoiceRoutingInfo === None) - assert(inner_d.invoiceFeatures === None) - assert(inner_d.paymentSecret === None) - assert(inner_d.paymentMetadata === None) + assert(add_d2 == add_d) + assert(outer_d.amount == amount_cd) + assert(outer_d.totalAmount == amount_cd) + assert(outer_d.expiry == expiry_cd) + assert(inner_d.amountToForward == amount_de) + assert(inner_d.outgoingCltv == expiry_de) + assert(inner_d.outgoingNodeId == e) + assert(inner_d.invoiceRoutingInfo == None) + assert(inner_d.invoiceFeatures == None) + assert(inner_d.paymentSecret == None) + assert(inner_d.paymentMetadata == None) // d forwards the trampoline payment to e. val Success((amount_e, expiry_e, onion_e)) = buildPaymentPacket(paymentHash, channelHopFromUpdate(d, e, channelUpdate_de) :: Nil, PaymentOnion.createTrampolinePayload(amount_de, amount_de, expiry_de, randomBytes32(), packet_e)) - assert(amount_e === amount_de) - assert(expiry_e === expiry_de) + assert(amount_e == amount_de) + assert(expiry_e == expiry_de) val add_e = UpdateAddHtlc(randomBytes32(), 4, amount_e, paymentHash, expiry_e, onion_e.packet) val Right(FinalPacket(add_e2, payload_e)) = decrypt(add_e, priv_e.privateKey) - assert(add_e2 === add_e) - assert(payload_e === FinalTlvPayload(TlvStream(AmountToForward(finalAmount), OutgoingCltv(finalExpiry), PaymentData(paymentSecret, finalAmount * 3), OnionPaymentPayloadTlv.PaymentMetadata(hex"010203")))) + assert(add_e2 == add_e) + assert(payload_e == FinalTlvPayload(TlvStream(AmountToForward(finalAmount), OutgoingCltv(finalExpiry), PaymentData(paymentSecret, finalAmount * 3), OnionPaymentPayloadTlv.PaymentMetadata(hex"010203")))) } test("build a trampoline payment with non-trampoline recipient") { @@ -217,47 +217,47 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { val invoiceFeatures = Features[InvoiceFeature](VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory, BasicMultiPartPayment -> Optional) val invoice = Bolt11Invoice(Block.RegtestGenesisBlock.hash, Some(finalAmount), paymentHash, priv_a.privateKey, Left("#reckless"), CltvExpiryDelta(18), None, None, routingHints, features = invoiceFeatures, paymentMetadata = Some(hex"010203")) val Success((amount_ac, expiry_ac, trampolineOnion)) = buildTrampolineToLegacyPacket(invoice, trampolineHops, PaymentOnion.createSinglePartPayload(finalAmount, finalExpiry, invoice.paymentSecret.get, None)) - assert(amount_ac === amount_bc) - assert(expiry_ac === expiry_bc) + assert(amount_ac == amount_bc) + assert(expiry_ac == expiry_bc) val Success((firstAmount, firstExpiry, onion)) = buildPaymentPacket(paymentHash, trampolineChannelHops, PaymentOnion.createTrampolinePayload(amount_ac, amount_ac, expiry_ac, randomBytes32(), trampolineOnion.packet)) - assert(firstAmount === amount_ab) - assert(firstExpiry === expiry_ab) + assert(firstAmount == amount_ab) + assert(firstExpiry == expiry_ab) val add_b = UpdateAddHtlc(randomBytes32(), 1, firstAmount, paymentHash, firstExpiry, onion.packet) val Right(ChannelRelayPacket(_, _, packet_c)) = decrypt(add_b, priv_b.privateKey) val add_c = UpdateAddHtlc(randomBytes32(), 2, amount_bc, paymentHash, expiry_bc, packet_c) val Right(NodeRelayPacket(_, outer_c, inner_c, packet_d)) = decrypt(add_c, priv_c.privateKey) - assert(outer_c.amount === amount_bc) - assert(outer_c.totalAmount === amount_bc) - assert(outer_c.expiry === expiry_bc) + assert(outer_c.amount == amount_bc) + assert(outer_c.totalAmount == amount_bc) + assert(outer_c.expiry == expiry_bc) assert(outer_c.paymentSecret !== invoice.paymentSecret) - assert(inner_c.amountToForward === amount_cd) - assert(inner_c.outgoingCltv === expiry_cd) - assert(inner_c.outgoingNodeId === d) - assert(inner_c.invoiceRoutingInfo === None) - assert(inner_c.invoiceFeatures === None) - assert(inner_c.paymentSecret === None) + assert(inner_c.amountToForward == amount_cd) + assert(inner_c.outgoingCltv == expiry_cd) + assert(inner_c.outgoingNodeId == d) + assert(inner_c.invoiceRoutingInfo == None) + assert(inner_c.invoiceFeatures == None) + assert(inner_c.paymentSecret == None) // c forwards the trampoline payment to d. val Success((amount_d, expiry_d, onion_d)) = buildPaymentPacket(paymentHash, channelHopFromUpdate(c, d, channelUpdate_cd) :: Nil, PaymentOnion.createTrampolinePayload(amount_cd, amount_cd, expiry_cd, randomBytes32(), packet_d)) - assert(amount_d === amount_cd) - assert(expiry_d === expiry_cd) + assert(amount_d == amount_cd) + assert(expiry_d == expiry_cd) val add_d = UpdateAddHtlc(randomBytes32(), 3, amount_d, paymentHash, expiry_d, onion_d.packet) val Right(NodeRelayPacket(_, outer_d, inner_d, _)) = decrypt(add_d, priv_d.privateKey) - assert(outer_d.amount === amount_cd) - assert(outer_d.totalAmount === amount_cd) - assert(outer_d.expiry === expiry_cd) + assert(outer_d.amount == amount_cd) + assert(outer_d.totalAmount == amount_cd) + assert(outer_d.expiry == expiry_cd) assert(outer_d.paymentSecret !== invoice.paymentSecret) - assert(inner_d.amountToForward === finalAmount) - assert(inner_d.outgoingCltv === expiry_de) - assert(inner_d.outgoingNodeId === e) - assert(inner_d.totalAmount === finalAmount) - assert(inner_d.paymentSecret === invoice.paymentSecret) - assert(inner_d.paymentMetadata === Some(hex"010203")) - assert(inner_d.invoiceFeatures === Some(hex"024100")) // var_onion_optin, payment_secret, basic_mpp - assert(inner_d.invoiceRoutingInfo === Some(routingHints)) + assert(inner_d.amountToForward == finalAmount) + assert(inner_d.outgoingCltv == expiry_de) + assert(inner_d.outgoingNodeId == e) + assert(inner_d.totalAmount == finalAmount) + assert(inner_d.paymentSecret == invoice.paymentSecret) + assert(inner_d.paymentMetadata == Some(hex"010203")) + assert(inner_d.invoiceFeatures == Some(hex"024100")) // var_onion_optin, payment_secret, basic_mpp + assert(inner_d.invoiceRoutingInfo == Some(routingHints)) } test("fail to build a trampoline payment when too much invoice data is provided") { @@ -294,14 +294,14 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { val Success((firstAmount, firstExpiry, onion)) = buildPaymentPacket(paymentHash, hops.take(1), PaymentOnion.createSinglePartPayload(finalAmount, finalExpiry, paymentSecret, None)) val add = UpdateAddHtlc(randomBytes32(), 1, firstAmount - 100.msat, paymentHash, firstExpiry, onion.packet) val Left(failure) = decrypt(add, priv_b.privateKey) - assert(failure === FinalIncorrectHtlcAmount(firstAmount - 100.msat)) + assert(failure == FinalIncorrectHtlcAmount(firstAmount - 100.msat)) } test("fail to decrypt at the final node when expiry has been modified by next-to-last node") { val Success((firstAmount, firstExpiry, onion)) = buildPaymentPacket(paymentHash, hops.take(1), PaymentOnion.createSinglePartPayload(finalAmount, finalExpiry, paymentSecret, None)) val add = UpdateAddHtlc(randomBytes32(), 1, firstAmount, paymentHash, firstExpiry - CltvExpiryDelta(12), onion.packet) val Left(failure) = decrypt(add, priv_b.privateKey) - assert(failure === FinalIncorrectCltvExpiry(firstExpiry - CltvExpiryDelta(12))) + assert(failure == FinalIncorrectCltvExpiry(firstExpiry - CltvExpiryDelta(12))) } test("fail to decrypt at the final trampoline node when amount has been modified by next-to-last trampoline") { @@ -316,7 +316,7 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { val invalidTotalAmount = amount_de + 100.msat val Success((amount_e, expiry_e, onion_e)) = buildPaymentPacket(paymentHash, channelHopFromUpdate(d, e, channelUpdate_de) :: Nil, PaymentOnion.createTrampolinePayload(amount_de, invalidTotalAmount, expiry_de, randomBytes32(), packet_e)) val Left(failure) = decrypt(UpdateAddHtlc(randomBytes32(), 4, amount_e, paymentHash, expiry_e, onion_e.packet), priv_e.privateKey) - assert(failure === FinalIncorrectHtlcAmount(invalidTotalAmount)) + assert(failure == FinalIncorrectHtlcAmount(invalidTotalAmount)) } test("fail to decrypt at the final trampoline node when expiry has been modified by next-to-last trampoline") { @@ -331,7 +331,7 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { val invalidExpiry = expiry_de - CltvExpiryDelta(12) val Success((amount_e, expiry_e, onion_e)) = buildPaymentPacket(paymentHash, channelHopFromUpdate(d, e, channelUpdate_de) :: Nil, PaymentOnion.createTrampolinePayload(amount_de, amount_de, invalidExpiry, randomBytes32(), packet_e)) val Left(failure) = decrypt(UpdateAddHtlc(randomBytes32(), 4, amount_e, paymentHash, expiry_e, onion_e.packet), priv_e.privateKey) - assert(failure === FinalIncorrectCltvExpiry(invalidExpiry)) + assert(failure == FinalIncorrectCltvExpiry(invalidExpiry)) } test("fail to decrypt at intermediate trampoline node when amount is invalid") { @@ -340,7 +340,7 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { val Right(ChannelRelayPacket(_, _, packet_c)) = decrypt(UpdateAddHtlc(randomBytes32(), 1, firstAmount, paymentHash, firstExpiry, onion.packet), priv_b.privateKey) // A trampoline relay is very similar to a final node: it can validate that the HTLC amount matches the onion outer amount. val Left(failure) = decrypt(UpdateAddHtlc(randomBytes32(), 2, amount_bc - 100.msat, paymentHash, expiry_bc, packet_c), priv_c.privateKey) - assert(failure === FinalIncorrectHtlcAmount(amount_bc - 100.msat)) + assert(failure == FinalIncorrectHtlcAmount(amount_bc - 100.msat)) } test("fail to decrypt at intermediate trampoline node when expiry is invalid") { @@ -349,7 +349,7 @@ class PaymentPacketSpec extends AnyFunSuite with BeforeAndAfterAll { val Right(ChannelRelayPacket(_, _, packet_c)) = decrypt(UpdateAddHtlc(randomBytes32(), 1, firstAmount, paymentHash, firstExpiry, onion.packet), priv_b.privateKey) // A trampoline relay is very similar to a final node: it can validate that the HTLC expiry matches the onion outer expiry. val Left(failure) = decrypt(UpdateAddHtlc(randomBytes32(), 2, amount_bc, paymentHash, expiry_bc - CltvExpiryDelta(12), packet_c), priv_c.privateKey) - assert(failure === FinalIncorrectCltvExpiry(expiry_bc - CltvExpiryDelta(12))) + assert(failure == FinalIncorrectCltvExpiry(expiry_bc - CltvExpiryDelta(12))) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PostRestartHtlcCleanerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PostRestartHtlcCleanerSpec.scala index f53be5caa5..9dfcf00f73 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/PostRestartHtlcCleanerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/PostRestartHtlcCleanerSpec.scala @@ -123,19 +123,19 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit // channel 1 goes to NORMAL state: system.eventStream.publish(ChannelStateChanged(channel.ref, channels.head.commitments.channelId, system.deadLetters, a, OFFLINE, NORMAL, Some(channels.head.commitments))) val fails_ab_1 = channel.expectMsgType[CMD_FAIL_HTLC] :: channel.expectMsgType[CMD_FAIL_HTLC] :: Nil - assert(fails_ab_1.toSet === Set(CMD_FAIL_HTLC(1, Right(TemporaryNodeFailure), commit = true), CMD_FAIL_HTLC(4, Right(TemporaryNodeFailure), commit = true))) + assert(fails_ab_1.toSet == Set(CMD_FAIL_HTLC(1, Right(TemporaryNodeFailure), commit = true), CMD_FAIL_HTLC(4, Right(TemporaryNodeFailure), commit = true))) channel.expectNoMessage(100 millis) // channel 2 goes to NORMAL state: system.eventStream.publish(ChannelStateChanged(channel.ref, channels(1).commitments.channelId, system.deadLetters, a, OFFLINE, NORMAL, Some(channels(1).commitments))) val fails_ab_2 = channel.expectMsgType[CMD_FAIL_HTLC] :: channel.expectMsgType[CMD_FAIL_HTLC] :: Nil - assert(fails_ab_2.toSet === Set(CMD_FAIL_HTLC(0, Right(TemporaryNodeFailure), commit = true), CMD_FAIL_HTLC(4, Right(TemporaryNodeFailure), commit = true))) + assert(fails_ab_2.toSet == Set(CMD_FAIL_HTLC(0, Right(TemporaryNodeFailure), commit = true), CMD_FAIL_HTLC(4, Right(TemporaryNodeFailure), commit = true))) channel.expectNoMessage(100 millis) // let's assume that channel 1 was disconnected before having signed the fails, and gets connected again: system.eventStream.publish(ChannelStateChanged(channel.ref, channels.head.channelId, system.deadLetters, a, OFFLINE, NORMAL, Some(channels.head.commitments))) val fails_ab_1_bis = channel.expectMsgType[CMD_FAIL_HTLC] :: channel.expectMsgType[CMD_FAIL_HTLC] :: Nil - assert(fails_ab_1_bis.toSet === Set(CMD_FAIL_HTLC(1, Right(TemporaryNodeFailure), commit = true), CMD_FAIL_HTLC(4, Right(TemporaryNodeFailure), commit = true))) + assert(fails_ab_1_bis.toSet == Set(CMD_FAIL_HTLC(1, Right(TemporaryNodeFailure), commit = true), CMD_FAIL_HTLC(4, Right(TemporaryNodeFailure), commit = true))) channel.expectNoMessage(100 millis) // let's now assume that channel 1 gets reconnected, and it had the time to fail the htlcs: @@ -191,7 +191,7 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit CMD_FAIL_HTLC(7, Right(TemporaryNodeFailure), commit = true) ) val received1 = expected1.map(_ => channel.expectMsgType[Command]) - assert(received1 === expected1) + assert(received1 == expected1) channel.expectNoMessage(100 millis) // channel 2 goes to NORMAL state: @@ -203,13 +203,13 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit CMD_FAIL_HTLC(9, Right(TemporaryNodeFailure), commit = true) ) val received2 = expected2.map(_ => channel.expectMsgType[Command]) - assert(received2 === expected2) + assert(received2 == expected2) channel.expectNoMessage(100 millis) // let's assume that channel 1 was disconnected before having signed the updates, and gets connected again: system.eventStream.publish(ChannelStateChanged(channel.ref, channels.head.channelId, system.deadLetters, a, OFFLINE, NORMAL, Some(channels.head.commitments))) val received3 = expected1.map(_ => channel.expectMsgType[Command]) - assert(received3 === expected1) + assert(received3 == expected1) channel.expectNoMessage(100 millis) // let's now assume that channel 1 gets reconnected, and it had the time to sign the htlcs: @@ -232,20 +232,20 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit sender.send(relayer, testCase.fails(1)) eventListener.expectNoMessage(100 millis) // This is a multi-part payment, the second part is still pending. - assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds(2)).get.status === OutgoingPaymentStatus.Pending) + assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds(2)).get.status == OutgoingPaymentStatus.Pending) sender.send(relayer, testCase.fails(2)) val e1 = eventListener.expectMsgType[PaymentFailed] - assert(e1.id === testCase.parentId) - assert(e1.paymentHash === paymentHash2) + assert(e1.id == testCase.parentId) + assert(e1.paymentHash == paymentHash2) assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds(1)).get.status.isInstanceOf[OutgoingPaymentStatus.Failed]) assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds(2)).get.status.isInstanceOf[OutgoingPaymentStatus.Failed]) - assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds.head).get.status === OutgoingPaymentStatus.Pending) + assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds.head).get.status == OutgoingPaymentStatus.Pending) sender.send(relayer, testCase.fails.head) val e2 = eventListener.expectMsgType[PaymentFailed] - assert(e2.id === testCase.childIds.head) - assert(e2.paymentHash === paymentHash1) + assert(e2.id == testCase.childIds.head) + assert(e2.paymentHash == paymentHash1) assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds.head).get.status.isInstanceOf[OutgoingPaymentStatus.Failed]) register.expectNoMessage(100 millis) @@ -261,27 +261,27 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit sender.send(relayer, testCase.fulfills(1)) eventListener.expectNoMessage(100 millis) // This is a multi-part payment, the second part is still pending. - assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds(2)).get.status === OutgoingPaymentStatus.Pending) + assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds(2)).get.status == OutgoingPaymentStatus.Pending) sender.send(relayer, testCase.fulfills(2)) val e1 = eventListener.expectMsgType[PaymentSent] - assert(e1.id === testCase.parentId) - assert(e1.paymentPreimage === preimage2) - assert(e1.paymentHash === paymentHash2) - assert(e1.parts.length === 2) - assert(e1.amountWithFees === 2834.msat) - assert(e1.recipientAmount === 2500.msat) + assert(e1.id == testCase.parentId) + assert(e1.paymentPreimage == preimage2) + assert(e1.paymentHash == paymentHash2) + assert(e1.parts.length == 2) + assert(e1.amountWithFees == 2834.msat) + assert(e1.recipientAmount == 2500.msat) assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds(1)).get.status.isInstanceOf[OutgoingPaymentStatus.Succeeded]) assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds(2)).get.status.isInstanceOf[OutgoingPaymentStatus.Succeeded]) - assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds.head).get.status === OutgoingPaymentStatus.Pending) + assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds.head).get.status == OutgoingPaymentStatus.Pending) sender.send(relayer, testCase.fulfills.head) val e2 = eventListener.expectMsgType[PaymentSent] - assert(e2.id === testCase.childIds.head) - assert(e2.paymentPreimage === preimage1) - assert(e2.paymentHash === paymentHash1) - assert(e2.parts.length === 1) - assert(e2.recipientAmount === 561.msat) + assert(e2.id == testCase.childIds.head) + assert(e2.paymentPreimage == preimage1) + assert(e2.paymentHash == paymentHash1) + assert(e2.parts.length == 1) + assert(e2.recipientAmount == 561.msat) assert(nodeParams.db.payments.getOutgoingPayment(testCase.childIds.head).get.status.isInstanceOf[OutgoingPaymentStatus.Succeeded]) register.expectNoMessage(100 millis) @@ -299,8 +299,8 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit val probe = TestProbe() probe.send(postRestart, PostRestartHtlcCleaner.GetBrokenHtlcs) val brokenHtlcs = probe.expectMsgType[PostRestartHtlcCleaner.BrokenHtlcs] - assert(brokenHtlcs.notRelayed.map(htlc => (htlc.add.id, htlc.add.channelId)).toSet === testCase.notRelayed) - assert(brokenHtlcs.relayedOut === Map( + assert(brokenHtlcs.notRelayed.map(htlc => (htlc.add.id, htlc.add.channelId)).toSet == testCase.notRelayed) + assert(brokenHtlcs.relayedOut == Map( testCase.origin_1 -> Set(testCase.downstream_1_1).map(htlc => (htlc.channelId, htlc.id)), testCase.origin_2 -> Set(testCase.downstream_2_1, testCase.downstream_2_2, testCase.downstream_2_3).map(htlc => (htlc.channelId, htlc.id)) )) @@ -383,8 +383,8 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit val closingState = localClose(alice, alice2blockchain) alice ! WatchTxConfirmedTriggered(BlockHeight(42), 0, closingState.commitTx) // All committed htlcs timed out except the last two; one will be fulfilled later and the other will timeout later. - assert(closingState.htlcTxs.size === 4) - assert(getHtlcTimeoutTxs(closingState).length === 4) + assert(closingState.htlcTxs.size == 4) + assert(getHtlcTimeoutTxs(closingState).length == 4) val htlcTxs = getHtlcTimeoutTxs(closingState).sortBy(_.tx.txOut.map(_.amount).sum) htlcTxs.reverse.drop(2).zipWithIndex.foreach { case (htlcTx, i) => alice ! WatchTxConfirmedTriggered(BlockHeight(201), i, htlcTx.tx) @@ -479,13 +479,13 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit nodeParams.db.channels.addOrUpdateChannel(upstreamChannel) nodeParams.db.channels.addOrUpdateChannel(downstreamChannel) - assert(Closing.isClosed(downstreamChannel, None) === None) + assert(Closing.isClosed(downstreamChannel, None) == None) val (_, postRestart) = f.createRelayer(nodeParams) sender.send(postRestart, PostRestartHtlcCleaner.GetBrokenHtlcs) val brokenHtlcs = sender.expectMsgType[PostRestartHtlcCleaner.BrokenHtlcs] assert(brokenHtlcs.relayedOut.isEmpty) - assert(brokenHtlcs.notRelayed === htlc_ab.map(htlc => PostRestartHtlcCleaner.IncomingHtlc(htlc.add, None))) + assert(brokenHtlcs.notRelayed == htlc_ab.map(htlc => PostRestartHtlcCleaner.IncomingHtlc(htlc.add, None))) } test("handle a channel relay htlc-fail") { f => @@ -529,7 +529,7 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit // This downstream HTLC has two upstream HTLCs. sender.send(relayer, buildForwardFail(testCase.downstream_1_1, testCase.origin_1)) val fails = register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]] :: register.expectMsgType[Register.Forward[CMD_FAIL_HTLC]] :: Nil - assert(fails.toSet === testCase.origin_1.htlcs.map { + assert(fails.toSet == testCase.origin_1.htlcs.map { case (channelId, htlcId) => Register.Forward(ActorRef.noSender, channelId, CMD_FAIL_HTLC(htlcId, Right(TemporaryNodeFailure), commit = true)) }.toSet) @@ -559,7 +559,7 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit // This downstream HTLC has two upstream HTLCs. sender.send(relayer, buildForwardFulfill(testCase.downstream_1_1, testCase.origin_1, preimage1)) val fulfills = register.expectMsgType[Register.Forward[CMD_FULFILL_HTLC]] :: register.expectMsgType[Register.Forward[CMD_FULFILL_HTLC]] :: Nil - assert(fulfills.toSet === testCase.origin_1.htlcs.map { + assert(fulfills.toSet == testCase.origin_1.htlcs.map { case (channelId, htlcId) => Register.Forward(ActorRef.noSender, channelId, CMD_FULFILL_HTLC(htlcId, preimage1, commit = true)) }.toSet) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/receive/InvoicePurgerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/receive/InvoicePurgerSpec.scala index 24b0bbaabb..e7cf259e7e 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/receive/InvoicePurgerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/receive/InvoicePurgerSpec.scala @@ -60,11 +60,11 @@ class InvoicePurgerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("ap }) val now = TimestampMilli.now() - assert(db.listIncomingPayments(0 unixms, now) === expiredPayments ++ pendingPayments ++ paidPayments) - assert(db.listIncomingPayments(now - 100.days, now) === pendingPayments ++ paidPayments) - assert(db.listPendingIncomingPayments(0 unixms, now) === pendingPayments) - assert(db.listReceivedIncomingPayments(0 unixms, now) === paidPayments) - assert(db.listExpiredIncomingPayments(0 unixms, now) === expiredPayments) + assert(db.listIncomingPayments(0 unixms, now) == expiredPayments ++ pendingPayments ++ paidPayments) + assert(db.listIncomingPayments(now - 100.days, now) == pendingPayments ++ paidPayments) + assert(db.listPendingIncomingPayments(0 unixms, now) == pendingPayments) + assert(db.listReceivedIncomingPayments(0 unixms, now) == paidPayments) + assert(db.listExpiredIncomingPayments(0 unixms, now) == expiredPayments) val probe = testKit.createTestProbe[PurgeEvent]() system.eventStream ! EventStream.Subscribe(probe.ref) @@ -75,7 +75,7 @@ class InvoicePurgerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("ap probe.expectMessage(5 seconds, PurgeCompleted) probe.expectNoMessage() assert(db.listExpiredIncomingPayments(0 unixms, now).isEmpty) - assert(db.listIncomingPayments(0 unixms, now) === pendingPayments ++ paidPayments) + assert(db.listIncomingPayments(0 unixms, now) == pendingPayments ++ paidPayments) testKit.stop(purger) } @@ -122,7 +122,7 @@ class InvoicePurgerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("ap // check that subsequent purge runs do not go back > 15 days probe.expectMessage(10 seconds, PurgeCompleted) probe.expectNoMessage() - assert(db.listExpiredIncomingPayments(0 unixms, TimestampMilli.now()) === Seq(expiredPayment3)) + assert(db.listExpiredIncomingPayments(0 unixms, TimestampMilli.now()) == Seq(expiredPayment3)) testKit.stop(purger) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/ChannelRelayerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/ChannelRelayerSpec.scala index 3aba714c92..b3096820c1 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/ChannelRelayerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/ChannelRelayerSpec.scala @@ -57,19 +57,19 @@ class ChannelRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("a def expectFwdFail(register: TestProbe[Any], channelId: ByteVector32, cmd: channel.Command): Register.Forward[channel.Command] = { val fwd = register.expectMessageType[Register.Forward[channel.Command]] - assert(fwd.channelId === channelId) - assert(fwd.message === cmd) + assert(fwd.channelId == channelId) + assert(fwd.message == cmd) fwd } def expectFwdAdd(register: TestProbe[Any], channelId: ByteVector32, outAmount: MilliSatoshi, outExpiry: CltvExpiry): Register.Forward[CMD_ADD_HTLC] = { val fwd = register.expectMessageType[Register.Forward[CMD_ADD_HTLC]] - assert(fwd.channelId === channelId) - assert(fwd.message.amount === outAmount) - assert(fwd.message.cltvExpiry === outExpiry) + assert(fwd.channelId == channelId) + assert(fwd.message.amount == outAmount) + assert(fwd.message.cltvExpiry == outExpiry) assert(fwd.message.origin.isInstanceOf[Origin.ChannelRelayedHot]) val o = fwd.message.origin.asInstanceOf[Origin.ChannelRelayedHot] - assert(o.amountOut === outAmount) + assert(o.amountOut == outAmount) fwd } @@ -433,12 +433,12 @@ class ChannelRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("a fwd1.message.origin.replyTo ! RES_ADD_SETTLED(fwd1.message.origin, downstream_htlc, testCase.result) val fwd2 = register.expectMessageType[Register.Forward[CMD_FULFILL_HTLC]] - assert(fwd2.channelId === r.add.channelId) - assert(fwd2.message.id === r.add.id) - assert(fwd2.message.r === paymentPreimage) + assert(fwd2.channelId == r.add.channelId) + assert(fwd2.message.id == r.add.id) + assert(fwd2.message.r == paymentPreimage) val paymentRelayed = eventListener.expectMessageType[ChannelPaymentRelayed] - assert(paymentRelayed.copy(timestamp = 0 unixms) === ChannelPaymentRelayed(r.add.amountMsat, r.payload.amountToForward, r.add.paymentHash, r.add.channelId, channelId1, timestamp = 0 unixms)) + assert(paymentRelayed.copy(timestamp = 0 unixms) == ChannelPaymentRelayed(r.add.amountMsat, r.payload.amountToForward, r.add.paymentHash, r.add.channelId, channelId1, timestamp = 0 unixms)) } } @@ -461,30 +461,30 @@ class ChannelRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("a channelRelayer ! WrappedLocalChannelUpdate(LocalChannelUpdate(null, channelId_bc, channelUpdate_bc.shortChannelId, c, None, channelUpdate_bc, makeCommitments(channelId_bc, 400000 msat, -5000 msat))) val channels1 = getOutgoingChannels(true) - assert(channels1.size === 2) - assert(channels1.head.channelUpdate === channelUpdate_ab) - assert(channels1.head.toChannelBalance === Relayer.ChannelBalance(a, channelUpdate_ab.shortChannelId, 0 msat, 300000 msat, isPublic = false, isEnabled = true)) - assert(channels1.last.channelUpdate === channelUpdate_bc) - assert(channels1.last.toChannelBalance === Relayer.ChannelBalance(c, channelUpdate_bc.shortChannelId, 400000 msat, 0 msat, isPublic = false, isEnabled = true)) + assert(channels1.size == 2) + assert(channels1.head.channelUpdate == channelUpdate_ab) + assert(channels1.head.toChannelBalance == Relayer.ChannelBalance(a, channelUpdate_ab.shortChannelId, 0 msat, 300000 msat, isPublic = false, isEnabled = true)) + assert(channels1.last.channelUpdate == channelUpdate_bc) + assert(channels1.last.toChannelBalance == Relayer.ChannelBalance(c, channelUpdate_bc.shortChannelId, 400000 msat, 0 msat, isPublic = false, isEnabled = true)) channelRelayer ! WrappedAvailableBalanceChanged(AvailableBalanceChanged(null, channelId_bc, channelUpdate_bc.shortChannelId, makeCommitments(channelId_bc, 200000 msat, 500000 msat))) val channels2 = getOutgoingChannels(true) - assert(channels2.last.commitments.availableBalanceForReceive === 500000.msat && channels2.last.commitments.availableBalanceForSend === 200000.msat) + assert(channels2.last.commitments.availableBalanceForReceive == 500000.msat && channels2.last.commitments.availableBalanceForSend == 200000.msat) channelRelayer ! WrappedAvailableBalanceChanged(AvailableBalanceChanged(null, channelId_ab, channelUpdate_ab.shortChannelId, makeCommitments(channelId_ab, 100000 msat, 200000 msat))) channelRelayer ! WrappedLocalChannelDown(LocalChannelDown(null, channelId_bc, channelUpdate_bc.shortChannelId, c)) val channels3 = getOutgoingChannels(true) - assert(channels3.size === 1 && channels3.head.commitments.availableBalanceForSend === 100000.msat) + assert(channels3.size == 1 && channels3.head.commitments.availableBalanceForSend == 100000.msat) channelRelayer ! WrappedLocalChannelUpdate(LocalChannelUpdate(null, channelId_ab, channelUpdate_ab.shortChannelId, a, None, channelUpdate_ab.copy(channelFlags = ChannelUpdate.ChannelFlags(isEnabled = false, isNode1 = true)), makeCommitments(channelId_ab, 100000 msat, 200000 msat))) val channels4 = getOutgoingChannels(true) assert(channels4.isEmpty) val channels5 = getOutgoingChannels(false) - assert(channels5.size === 1) + assert(channels5.size == 1) channelRelayer ! WrappedLocalChannelUpdate(LocalChannelUpdate(null, channelId_ab, channelUpdate_ab.shortChannelId, a, None, channelUpdate_ab, makeCommitments(channelId_ab, 100000 msat, 200000 msat))) val channels6 = getOutgoingChannels(true) - assert(channels6.size === 1) + assert(channels6.size == 1) // Simulate a chain re-org that changes the shortChannelId: channelRelayer ! WrappedShortChannelIdAssigned(ShortChannelIdAssigned(null, channelId_ab, ShortChannelId(42), Some(channelUpdate_ab.shortChannelId))) @@ -492,8 +492,8 @@ class ChannelRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("a // We should receive the updated channel update containing the new shortChannelId: channelRelayer ! WrappedLocalChannelUpdate(LocalChannelUpdate(null, channelId_ab, ShortChannelId(42), a, None, channelUpdate_ab.copy(shortChannelId = ShortChannelId(42)), makeCommitments(channelId_ab, 100000 msat, 200000 msat))) val channels7 = getOutgoingChannels(true) - assert(channels7.size === 1) - assert(channels7.head.channelUpdate.shortChannelId === ShortChannelId(42)) + assert(channels7.size == 1) + assert(channels7.head.channelUpdate.shortChannelId == ShortChannelId(42)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/NodeRelayerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/NodeRelayerSpec.scala index f851e4627e..26a76adf64 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/NodeRelayerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/NodeRelayerSpec.scala @@ -101,26 +101,26 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl parentRelayer ! NodeRelayer.Relay(payment1) parentRelayer ! NodeRelayer.GetPendingPayments(probe.ref.toClassic) val pending1 = probe.expectMessageType[Map[PaymentKey, ActorRef[NodeRelay.Command]]] - assert(pending1.keySet === Set(PaymentKey(paymentHash1, paymentSecret1))) + assert(pending1.keySet == Set(PaymentKey(paymentHash1, paymentSecret1))) val (paymentHash2, paymentSecret2) = (randomBytes32(), randomBytes32()) val payment2 = createPartialIncomingPacket(paymentHash2, paymentSecret2) parentRelayer ! NodeRelayer.Relay(payment2) parentRelayer ! NodeRelayer.GetPendingPayments(probe.ref.toClassic) val pending2 = probe.expectMessageType[Map[PaymentKey, ActorRef[NodeRelay.Command]]] - assert(pending2.keySet === Set(PaymentKey(paymentHash1, paymentSecret1), PaymentKey(paymentHash2, paymentSecret2))) + assert(pending2.keySet == Set(PaymentKey(paymentHash1, paymentSecret1), PaymentKey(paymentHash2, paymentSecret2))) val payment3a = createPartialIncomingPacket(paymentHash1, paymentSecret2) parentRelayer ! NodeRelayer.Relay(payment3a) parentRelayer ! NodeRelayer.GetPendingPayments(probe.ref.toClassic) val pending3 = probe.expectMessageType[Map[PaymentKey, ActorRef[NodeRelay.Command]]] - assert(pending3.keySet === Set(PaymentKey(paymentHash1, paymentSecret1), PaymentKey(paymentHash2, paymentSecret2), PaymentKey(paymentHash1, paymentSecret2))) + assert(pending3.keySet == Set(PaymentKey(paymentHash1, paymentSecret1), PaymentKey(paymentHash2, paymentSecret2), PaymentKey(paymentHash1, paymentSecret2))) val payment3b = createPartialIncomingPacket(paymentHash1, paymentSecret2) parentRelayer ! NodeRelayer.Relay(payment3b) parentRelayer ! NodeRelayer.GetPendingPayments(probe.ref.toClassic) val pending4 = probe.expectMessageType[Map[PaymentKey, ActorRef[NodeRelay.Command]]] - assert(pending4.keySet === Set(PaymentKey(paymentHash1, paymentSecret1), PaymentKey(paymentHash2, paymentSecret2), PaymentKey(paymentHash1, paymentSecret2))) + assert(pending4.keySet == Set(PaymentKey(paymentHash1, paymentSecret1), PaymentKey(paymentHash2, paymentSecret2), PaymentKey(paymentHash1, paymentSecret2))) register.expectNoMessage(100 millis) } @@ -169,8 +169,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl parentRelayer ! NodeRelayer.Relay(incomingMultiPart.head) parentRelayer ! NodeRelayer.GetPendingPayments(probe.ref.toClassic) val pending1 = probe.expectMessageType[Map[PaymentKey, ActorRef[NodeRelay.Command]]] - assert(pending1.size === 1) - assert(pending1.head._1 === PaymentKey(paymentHash, incomingSecret)) + assert(pending1.size == 1) + assert(pending1.head._1 == PaymentKey(paymentHash, incomingSecret)) parentRelayer ! NodeRelayer.RelayComplete(pending1.head._2, paymentHash, incomingSecret) parentRelayer ! NodeRelayer.GetPendingPayments(probe.ref.toClassic) @@ -179,8 +179,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl parentRelayer ! NodeRelayer.Relay(incomingMultiPart.head) parentRelayer ! NodeRelayer.GetPendingPayments(probe.ref.toClassic) val pending2 = probe.expectMessageType[Map[PaymentKey, ActorRef[NodeRelay.Command]]] - assert(pending2.size === 1) - assert(pending2.head._1 === pending1.head._1) + assert(pending2.size == 1) + assert(pending2.head._1 == pending1.head._1) assert(pending2.head._2 !== pending1.head._2) } } @@ -194,9 +194,9 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl // after a while the payment times out incomingMultiPart.dropRight(1).foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]](30 seconds) - assert(fwd.channelId === p.add.channelId) + assert(fwd.channelId == p.add.channelId) val failure = Right(PaymentTimeout) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, failure, commit = true)) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, failure, commit = true)) } parent.expectMessageType[NodeRelayer.RelayComplete] @@ -219,9 +219,9 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl // the extra payment will be rejected val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === extra.add.channelId) + assert(fwd.channelId == extra.add.channelId) val failure = IncorrectOrUnknownPaymentDetails(extra.add.amountMsat, nodeParams.currentBlockHeight) - assert(fwd.message === CMD_FAIL_HTLC(extra.add.id, Right(failure), commit = true)) + assert(fwd.message == CMD_FAIL_HTLC(extra.add.id, Right(failure), commit = true)) register.expectNoMessage(100 millis) } @@ -247,9 +247,9 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayer ! NodeRelay.Relay(i1) val fwd1 = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd1.channelId === i1.add.channelId) + assert(fwd1.channelId == i1.add.channelId) val failure1 = IncorrectOrUnknownPaymentDetails(1000 msat, nodeParams.currentBlockHeight) - assert(fwd1.message === CMD_FAIL_HTLC(i1.add.id, Right(failure1), commit = true)) + assert(fwd1.message == CMD_FAIL_HTLC(i1.add.id, Right(failure1), commit = true)) // Receive new HTLC with different details, but for the same payment hash. val i2 = IncomingPaymentPacket.NodeRelayPacket( @@ -260,9 +260,9 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayer ! NodeRelay.Relay(i2) val fwd2 = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd1.channelId === i1.add.channelId) + assert(fwd1.channelId == i1.add.channelId) val failure2 = IncorrectOrUnknownPaymentDetails(1500 msat, nodeParams.currentBlockHeight) - assert(fwd2.message === CMD_FAIL_HTLC(i2.add.id, Right(failure2), commit = true)) + assert(fwd2.message == CMD_FAIL_HTLC(i2.add.id, Right(failure2), commit = true)) register.expectNoMessage(100 millis) } @@ -277,8 +277,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayer ! NodeRelay.Relay(p) val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(TrampolineExpiryTooSoon), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(TrampolineExpiryTooSoon), commit = true)) register.expectNoMessage(100 millis) } @@ -293,8 +293,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayer ! NodeRelay.Relay(p) val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(TrampolineExpiryTooSoon), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(TrampolineExpiryTooSoon), commit = true)) register.expectNoMessage(100 millis) } @@ -314,8 +314,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl p.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(TrampolineExpiryTooSoon), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(TrampolineExpiryTooSoon), commit = true)) } register.expectNoMessage(100 millis) @@ -329,8 +329,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayer ! NodeRelay.Relay(p) val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(TrampolineFeeInsufficient), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(TrampolineFeeInsufficient), commit = true)) register.expectNoMessage(100 millis) } @@ -347,8 +347,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl p.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(TrampolineFeeInsufficient), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(TrampolineFeeInsufficient), commit = true)) } register.expectNoMessage(100 millis) @@ -362,8 +362,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayer ! NodeRelay.Relay(p) val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(InvalidOnionPayload(UInt64(2), 0)), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(InvalidOnionPayload(UInt64(2), 0)), commit = true)) register.expectNoMessage(100 millis) } @@ -380,8 +380,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl p.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(InvalidOnionPayload(UInt64(2), 0)), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(InvalidOnionPayload(UInt64(2), 0)), commit = true)) } register.expectNoMessage(100 millis) @@ -402,8 +402,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayerAdapters ! PaymentFailed(relayId, paymentHash, LocalFailure(outgoingAmount, Nil, BalanceTooLow) :: Nil) incomingMultiPart.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(TrampolineFeeInsufficient), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(TrampolineFeeInsufficient), commit = true)) } register.expectNoMessage(100 millis) @@ -427,8 +427,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl incoming.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(TemporaryNodeFailure), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(TemporaryNodeFailure), commit = true)) } register.expectNoMessage(100 millis) @@ -450,8 +450,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl incomingMultiPart.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(TrampolineFeeInsufficient), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(TrampolineFeeInsufficient), commit = true)) } register.expectNoMessage(100 millis) @@ -472,8 +472,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl incomingMultiPart.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(FinalIncorrectHtlcAmount(42 msat)), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(FinalIncorrectHtlcAmount(42 msat)), commit = true)) } register.expectNoMessage(100 millis) @@ -488,9 +488,9 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl val routeRequest = router.expectMessageType[RouteRequest] val routeParams = routeRequest.routeParams - assert(routeParams.boundaries.maxFeeProportional === 0) // should be disabled - assert(routeParams.boundaries.maxFeeFlat === incomingAmount - outgoingAmount) - assert(routeParams.boundaries.maxCltv === incomingSinglePart.add.cltvExpiry - outgoingExpiry) + assert(routeParams.boundaries.maxFeeProportional == 0) // should be disabled + assert(routeParams.boundaries.maxFeeFlat == incomingAmount - outgoingAmount) + assert(routeParams.boundaries.maxCltv == incomingSinglePart.add.cltvExpiry - outgoingExpiry) assert(routeParams.includeLocalChannelCost) } @@ -515,8 +515,8 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayerAdapters ! PreimageReceived(paymentHash, paymentPreimage) incomingMultiPart.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FULFILL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FULFILL_HTLC(p.add.id, paymentPreimage, commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FULFILL_HTLC(p.add.id, paymentPreimage, commit = true)) } // If the payment FSM sends us duplicate preimage events, we should not fulfill a second time upstream. @@ -527,7 +527,7 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayerAdapters ! createSuccessEvent() val relayEvent = eventListener.expectMessageType[TrampolinePaymentRelayed] validateRelayEvent(relayEvent) - assert(relayEvent.incoming.toSet === incomingMultiPart.map(i => PaymentRelayed.Part(i.add.amountMsat, i.add.channelId)).toSet) + assert(relayEvent.incoming.toSet == incomingMultiPart.map(i => PaymentRelayed.Part(i.add.amountMsat, i.add.channelId)).toSet) assert(relayEvent.outgoing.nonEmpty) parent.expectMessageType[NodeRelayer.RelayComplete] register.expectNoMessage(100 millis) @@ -550,13 +550,13 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl nodeRelayerAdapters ! PreimageReceived(paymentHash, paymentPreimage) val incomingAdd = incomingSinglePart.add val fwd = register.expectMessageType[Register.Forward[CMD_FULFILL_HTLC]] - assert(fwd.channelId === incomingAdd.channelId) - assert(fwd.message === CMD_FULFILL_HTLC(incomingAdd.id, paymentPreimage, commit = true)) + assert(fwd.channelId == incomingAdd.channelId) + assert(fwd.message == CMD_FULFILL_HTLC(incomingAdd.id, paymentPreimage, commit = true)) nodeRelayerAdapters ! createSuccessEvent() val relayEvent = eventListener.expectMessageType[TrampolinePaymentRelayed] validateRelayEvent(relayEvent) - assert(relayEvent.incoming === Seq(PaymentRelayed.Part(incomingSinglePart.add.amountMsat, incomingSinglePart.add.channelId))) + assert(relayEvent.incoming == Seq(PaymentRelayed.Part(incomingSinglePart.add.amountMsat, incomingSinglePart.add.channelId))) assert(relayEvent.outgoing.nonEmpty) parent.expectMessageType[NodeRelayer.RelayComplete] register.expectNoMessage(100 millis) @@ -578,27 +578,27 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl val outgoingCfg = mockPayFSM.expectMessageType[SendPaymentConfig] validateOutgoingCfg(outgoingCfg, Upstream.Trampoline(incomingMultiPart.map(_.add))) val outgoingPayment = mockPayFSM.expectMessageType[SendMultiPartPayment] - assert(outgoingPayment.paymentSecret === invoice.paymentSecret.get) // we should use the provided secret - assert(outgoingPayment.paymentMetadata === invoice.paymentMetadata) // we should use the provided metadata - assert(outgoingPayment.totalAmount === outgoingAmount) - assert(outgoingPayment.targetExpiry === outgoingExpiry) - assert(outgoingPayment.targetNodeId === outgoingNodeId) - assert(outgoingPayment.additionalTlvs === Nil) - assert(outgoingPayment.assistedRoutes === hints) + assert(outgoingPayment.paymentSecret == invoice.paymentSecret.get) // we should use the provided secret + assert(outgoingPayment.paymentMetadata == invoice.paymentMetadata) // we should use the provided metadata + assert(outgoingPayment.totalAmount == outgoingAmount) + assert(outgoingPayment.targetExpiry == outgoingExpiry) + assert(outgoingPayment.targetNodeId == outgoingNodeId) + assert(outgoingPayment.additionalTlvs == Nil) + assert(outgoingPayment.assistedRoutes == hints) // those are adapters for pay-fsm messages val nodeRelayerAdapters = outgoingPayment.replyTo nodeRelayerAdapters ! PreimageReceived(paymentHash, paymentPreimage) incomingMultiPart.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FULFILL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FULFILL_HTLC(p.add.id, paymentPreimage, commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FULFILL_HTLC(p.add.id, paymentPreimage, commit = true)) } nodeRelayerAdapters ! createSuccessEvent() val relayEvent = eventListener.expectMessageType[TrampolinePaymentRelayed] validateRelayEvent(relayEvent) - assert(relayEvent.incoming === incomingMultiPart.map(i => PaymentRelayed.Part(i.add.amountMsat, i.add.channelId))) + assert(relayEvent.incoming == incomingMultiPart.map(i => PaymentRelayed.Part(i.add.amountMsat, i.add.channelId))) assert(relayEvent.outgoing.nonEmpty) parent.expectMessageType[NodeRelayer.RelayComplete] register.expectNoMessage(100 millis) @@ -620,26 +620,26 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl val outgoingCfg = mockPayFSM.expectMessageType[SendPaymentConfig] validateOutgoingCfg(outgoingCfg, Upstream.Trampoline(incomingMultiPart.map(_.add))) val outgoingPayment = mockPayFSM.expectMessageType[SendPaymentToNode] - assert(outgoingPayment.finalPayload.amount === outgoingAmount) - assert(outgoingPayment.finalPayload.expiry === outgoingExpiry) - assert(outgoingPayment.finalPayload.paymentMetadata === invoice.paymentMetadata) // we should use the provided metadata - assert(outgoingPayment.targetNodeId === outgoingNodeId) - assert(outgoingPayment.assistedRoutes === hints) + assert(outgoingPayment.finalPayload.amount == outgoingAmount) + assert(outgoingPayment.finalPayload.expiry == outgoingExpiry) + assert(outgoingPayment.finalPayload.paymentMetadata == invoice.paymentMetadata) // we should use the provided metadata + assert(outgoingPayment.targetNodeId == outgoingNodeId) + assert(outgoingPayment.assistedRoutes == hints) // those are adapters for pay-fsm messages val nodeRelayerAdapters = outgoingPayment.replyTo nodeRelayerAdapters ! PreimageReceived(paymentHash, paymentPreimage) incomingMultiPart.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FULFILL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FULFILL_HTLC(p.add.id, paymentPreimage, commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FULFILL_HTLC(p.add.id, paymentPreimage, commit = true)) } nodeRelayerAdapters ! createSuccessEvent() val relayEvent = eventListener.expectMessageType[TrampolinePaymentRelayed] validateRelayEvent(relayEvent) - assert(relayEvent.incoming === incomingMultiPart.map(i => PaymentRelayed.Part(i.add.amountMsat, i.add.channelId))) - assert(relayEvent.outgoing.length === 1) + assert(relayEvent.incoming == incomingMultiPart.map(i => PaymentRelayed.Part(i.add.amountMsat, i.add.channelId))) + assert(relayEvent.outgoing.length == 1) parent.expectMessageType[NodeRelayer.RelayComplete] register.expectNoMessage(100 millis) } @@ -659,34 +659,34 @@ class NodeRelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("appl incomingMultiPart.foreach { p => val fwd = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]] - assert(fwd.channelId === p.add.channelId) - assert(fwd.message === CMD_FAIL_HTLC(p.add.id, Right(InvalidOnionPayload(UInt64(8), 0)), commit = true)) + assert(fwd.channelId == p.add.channelId) + assert(fwd.message == CMD_FAIL_HTLC(p.add.id, Right(InvalidOnionPayload(UInt64(8), 0)), commit = true)) } } def validateOutgoingCfg(outgoingCfg: SendPaymentConfig, upstream: Upstream): Unit = { assert(!outgoingCfg.publishEvent) assert(!outgoingCfg.storeInDb) - assert(outgoingCfg.paymentHash === paymentHash) - assert(outgoingCfg.invoice === None) - assert(outgoingCfg.recipientAmount === outgoingAmount) - assert(outgoingCfg.recipientNodeId === outgoingNodeId) - assert(outgoingCfg.upstream === upstream) + assert(outgoingCfg.paymentHash == paymentHash) + assert(outgoingCfg.invoice == None) + assert(outgoingCfg.recipientAmount == outgoingAmount) + assert(outgoingCfg.recipientNodeId == outgoingNodeId) + assert(outgoingCfg.upstream == upstream) } def validateOutgoingPayment(outgoingPayment: SendMultiPartPayment): Unit = { assert(outgoingPayment.paymentSecret !== incomingSecret) // we should generate a new outgoing secret - assert(outgoingPayment.totalAmount === outgoingAmount) - assert(outgoingPayment.targetExpiry === outgoingExpiry) - assert(outgoingPayment.targetNodeId === outgoingNodeId) - assert(outgoingPayment.additionalTlvs === Seq(OnionPaymentPayloadTlv.TrampolineOnion(nextTrampolinePacket))) - assert(outgoingPayment.assistedRoutes === Nil) + assert(outgoingPayment.totalAmount == outgoingAmount) + assert(outgoingPayment.targetExpiry == outgoingExpiry) + assert(outgoingPayment.targetNodeId == outgoingNodeId) + assert(outgoingPayment.additionalTlvs == Seq(OnionPaymentPayloadTlv.TrampolineOnion(nextTrampolinePacket))) + assert(outgoingPayment.assistedRoutes == Nil) } def validateRelayEvent(e: TrampolinePaymentRelayed): Unit = { - assert(e.amountIn === incomingAmount) + assert(e.amountIn == incomingAmount) assert(e.amountOut >= outgoingAmount) // outgoingAmount + routing fees - assert(e.paymentHash === paymentHash) + assert(e.paymentHash == paymentHash) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/RelayerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/RelayerSpec.scala index 12d477466f..0df90707cb 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/RelayerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/payment/relay/RelayerSpec.scala @@ -102,8 +102,8 @@ class RelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("applicat relayer ! RelayForward(add_ab) val fp = paymentHandler.expectMessageType[FinalPacket] - assert(fp.add === add_ab) - assert(fp.payload === PaymentOnion.createSinglePartPayload(finalAmount, finalExpiry, paymentSecret, None)) + assert(fp.add == add_ab) + assert(fp.payload == PaymentOnion.createSinglePartPayload(finalAmount, finalExpiry, paymentSecret, None)) register.expectNoMessage(50 millis) } @@ -117,21 +117,21 @@ class RelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("applicat val totalAmount = finalAmount * 3 val trampolineHops = NodeHop(a, b, channelUpdate_ab.cltvExpiryDelta, 0 msat) :: Nil val Success((trampolineAmount, trampolineExpiry, trampolineOnion)) = OutgoingPaymentPacket.buildTrampolinePacket(paymentHash, trampolineHops, PaymentOnion.createMultiPartPayload(finalAmount, totalAmount, finalExpiry, paymentSecret, None)) - assert(trampolineAmount === finalAmount) - assert(trampolineExpiry === finalExpiry) + assert(trampolineAmount == finalAmount) + assert(trampolineExpiry == finalExpiry) val Success((cmd, _)) = buildCommand(ActorRef.noSender, Upstream.Local(UUID.randomUUID()), paymentHash, channelHopFromUpdate(a, b, channelUpdate_ab) :: Nil, PaymentOnion.createTrampolinePayload(trampolineAmount, trampolineAmount, trampolineExpiry, randomBytes32(), trampolineOnion.packet)) - assert(cmd.amount === finalAmount) - assert(cmd.cltvExpiry === finalExpiry) + assert(cmd.amount == finalAmount) + assert(cmd.cltvExpiry == finalExpiry) val add_ab = UpdateAddHtlc(channelId = channelId_ab, id = 123456, cmd.amount, cmd.paymentHash, cmd.cltvExpiry, cmd.onion) relayer ! RelayForward(add_ab) val fp = paymentHandler.expectMessageType[FinalPacket] - assert(fp.add === add_ab) - assert(fp.payload.amount === finalAmount) - assert(fp.payload.totalAmount === totalAmount) - assert(fp.payload.expiry === finalExpiry) - assert(fp.payload.paymentSecret === paymentSecret) + assert(fp.add == add_ab) + assert(fp.payload.amount == finalAmount) + assert(fp.payload.totalAmount == totalAmount) + assert(fp.payload.expiry == finalExpiry) + assert(fp.payload.paymentSecret == paymentSecret) register.expectNoMessage(50 millis) } @@ -147,9 +147,9 @@ class RelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("applicat relayer ! RelayForward(add_ab) val fail = register.expectMessageType[Register.Forward[CMD_FAIL_MALFORMED_HTLC]].message - assert(fail.id === add_ab.id) + assert(fail.id == add_ab.id) assert(fail.onionHash == Sphinx.hash(add_ab.onionRoutingPacket)) - assert(fail.failureCode === (FailureMessageCodecs.BADONION | FailureMessageCodecs.PERM | 5)) + assert(fail.failureCode == (FailureMessageCodecs.BADONION | FailureMessageCodecs.PERM | 5)) register.expectNoMessage(50 millis) } @@ -170,7 +170,7 @@ class RelayerSpec extends ScalaTestWithActorTestKit(ConfigFactory.load("applicat relayer ! RelayForward(add_ab) val fail = register.expectMessageType[Register.Forward[CMD_FAIL_HTLC]].message - assert(fail.id === add_ab.id) + assert(fail.id == add_ab.id) assert(fail.reason == Right(RequiredNodeFeatureMissing)) register.expectNoMessage(50 millis) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/router/AnnouncementsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/router/AnnouncementsSpec.scala index b92e5f022e..b7e4b52f35 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/router/AnnouncementsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/router/AnnouncementsSpec.scala @@ -50,7 +50,7 @@ class AnnouncementsSpec extends AnyFunSuite { val bitcoin_b_sig = Announcements.signChannelAnnouncement(witness, bitcoin_b) val ann = makeChannelAnnouncement(Block.RegtestGenesisBlock.hash, ShortChannelId(42L), node_a.publicKey, node_b.publicKey, bitcoin_a.publicKey, bitcoin_b.publicKey, node_a_sig, node_b_sig, bitcoin_a_sig, bitcoin_b_sig) assert(checkSigs(ann)) - assert(checkSigs(ann.copy(nodeId1 = randomKey().publicKey)) === false) + assert(checkSigs(ann.copy(nodeId1 = randomKey().publicKey)) == false) } test("create valid signed node announcement") { @@ -66,7 +66,7 @@ class AnnouncementsSpec extends AnyFunSuite { ) val ann = makeNodeAnnouncement(Alice.nodeParams.privateKey, Alice.nodeParams.alias, Alice.nodeParams.color, Alice.nodeParams.publicAddresses, features.nodeAnnouncementFeatures()) // Features should be filtered to only include node_announcement related features. - assert(ann.features === Features( + assert(ann.features == Features( Features.DataLossProtect -> FeatureSupport.Optional, Features.ChannelRangeQueries -> FeatureSupport.Optional, Features.ChannelRangeQueriesExtended -> FeatureSupport.Optional, @@ -75,7 +75,7 @@ class AnnouncementsSpec extends AnyFunSuite { Features.BasicMultiPartPayment -> FeatureSupport.Optional, )) assert(checkSig(ann)) - assert(checkSig(ann.copy(timestamp = 153 unixsec)) === false) + assert(checkSig(ann.copy(timestamp = 153 unixsec)) == false) } test("sort node announcement addresses") { @@ -87,7 +87,7 @@ class AnnouncementsSpec extends AnyFunSuite { ) val ann = makeNodeAnnouncement(Alice.nodeParams.privateKey, Alice.nodeParams.alias, Alice.nodeParams.color, addresses, Alice.nodeParams.features.nodeAnnouncementFeatures()) assert(checkSig(ann)) - assert(ann.addresses === List( + assert(ann.addresses == List( NodeAddress.fromParts("140.82.121.4", 9735).get, NodeAddress.fromParts("2620:1ec:c11:0:0:0:0:200", 9735).get, NodeAddress.fromParts("hsmithsxurybd7uh.onion", 9735).get, @@ -96,13 +96,13 @@ class AnnouncementsSpec extends AnyFunSuite { } test("nodeParams.nodeId equals nodeParams.privateKey.publicKey") { - assert(Alice.nodeParams.nodeId === Alice.nodeParams.privateKey.publicKey) + assert(Alice.nodeParams.nodeId == Alice.nodeParams.privateKey.publicKey) } test("create valid signed channel update announcement") { val ann = makeChannelUpdate(Block.RegtestGenesisBlock.hash, Alice.nodeParams.privateKey, randomKey().publicKey, ShortChannelId(45561L), Alice.nodeParams.channelConf.expiryDelta, Alice.nodeParams.channelConf.htlcMinimum, Alice.nodeParams.relayParams.publicChannelFees.feeBase, Alice.nodeParams.relayParams.publicChannelFees.feeProportionalMillionths, 500000000 msat) assert(checkSig(ann, Alice.nodeParams.nodeId)) - assert(checkSig(ann, randomKey().publicKey) === false) + assert(checkSig(ann, randomKey().publicKey) == false) } test("check flags") { @@ -135,6 +135,6 @@ class AnnouncementsSpec extends AnyFunSuite { val ann = nodeAnnouncementCodec.decode(encoded.bits).require.value assert(ann.features.hasFeature(Features.PaymentMetadata)) assert(checkSig(ann)) - assert(nodeAnnouncementCodec.encode(ann).require.bytes === encoded) + assert(nodeAnnouncementCodec.encode(ann).require.bytes == encoded) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/router/BaseRouterSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/router/BaseRouterSpec.scala index 155df8c7dd..625f814d44 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/router/BaseRouterSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/router/BaseRouterSpec.scala @@ -108,13 +108,13 @@ abstract class BaseRouterSpec extends TestKitBaseClass with FixtureAnyFunSuiteLi // and e --(4)--> f (we are a) within(30 seconds) { // first we make sure that we correctly resolve channelId+direction to nodeId - assert(ChannelDesc(update_ab, chan_ab) === ChannelDesc(chan_ab.shortChannelId, a, b)) - assert(ChannelDesc(update_bc, chan_bc) === ChannelDesc(chan_bc.shortChannelId, b, c)) - assert(ChannelDesc(update_cd, chan_cd) === ChannelDesc(chan_cd.shortChannelId, c, d)) - assert(ChannelDesc(update_ef, chan_ef) === ChannelDesc(chan_ef.shortChannelId, e, f)) - assert(ChannelDesc(update_ag_private, PrivateChannel(scid_ag_private, channelId_ag_private, a, g, None, None, ChannelMeta(1000 msat, 2000 msat))) === ChannelDesc(scid_ag_private, a, g)) - assert(ChannelDesc(update_ag_private, PrivateChannel(scid_ag_private, channelId_ag_private, g, a, None, None, ChannelMeta(2000 msat, 1000 msat))) === ChannelDesc(scid_ag_private, a, g)) - assert(ChannelDesc(update_gh, chan_gh) === ChannelDesc(chan_gh.shortChannelId, g, h)) + assert(ChannelDesc(update_ab, chan_ab) == ChannelDesc(chan_ab.shortChannelId, a, b)) + assert(ChannelDesc(update_bc, chan_bc) == ChannelDesc(chan_bc.shortChannelId, b, c)) + assert(ChannelDesc(update_cd, chan_cd) == ChannelDesc(chan_cd.shortChannelId, c, d)) + assert(ChannelDesc(update_ef, chan_ef) == ChannelDesc(chan_ef.shortChannelId, e, f)) + assert(ChannelDesc(update_ag_private, PrivateChannel(scid_ag_private, channelId_ag_private, a, g, None, None, ChannelMeta(1000 msat, 2000 msat))) == ChannelDesc(scid_ag_private, a, g)) + assert(ChannelDesc(update_ag_private, PrivateChannel(scid_ag_private, channelId_ag_private, g, a, None, None, ChannelMeta(2000 msat, 1000 msat))) == ChannelDesc(scid_ag_private, a, g)) + assert(ChannelDesc(update_gh, chan_gh) == ChannelDesc(chan_gh.shortChannelId, g, h)) // let's set up the router val sender = TestProbe() @@ -153,11 +153,11 @@ abstract class BaseRouterSpec extends TestKitBaseClass with FixtureAnyFunSuiteLi // then private channels sender.send(router, LocalChannelUpdate(sender.ref, channelId_ag_private, scid_ag_private, g, None, update_ag_private, CommitmentsSpec.makeCommitments(30000000 msat, 8000000 msat, a, g, announceChannel = false))) // watcher receives the get tx requests - assert(watcher.expectMsgType[ValidateRequest].ann === chan_ab) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_bc) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_cd) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_ef) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_gh) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_ab) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_bc) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_cd) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_ef) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_gh) // and answers with valid scripts watcher.send(router, ValidateResult(chan_ab, Right((Transaction(version = 0, txIn = Nil, txOut = TxOut(publicChannelCapacity, write(pay2wsh(Scripts.multiSig2of2(funding_a, funding_b)))) :: Nil, lockTime = 0), UtxoStatus.Unspent)))) watcher.send(router, ValidateResult(chan_bc, Right((Transaction(version = 0, txIn = Nil, txOut = TxOut(publicChannelCapacity, write(pay2wsh(Scripts.multiSig2of2(funding_b, funding_c)))) :: Nil, lockTime = 0), UtxoStatus.Unspent)))) @@ -172,7 +172,7 @@ abstract class BaseRouterSpec extends TestKitBaseClass with FixtureAnyFunSuiteLi watcher.expectMsgType[WatchExternalChannelSpent].shortChannelId, watcher.expectMsgType[WatchExternalChannelSpent].shortChannelId, ) - assert(watchedShortChannelIds === Set(scid_ab, scid_bc, scid_cd, scid_ef, scid_gh)) + assert(watchedShortChannelIds == Set(scid_ab, scid_bc, scid_cd, scid_ef, scid_gh)) // all messages are acked peerConnection.expectMsgAllOf( GossipDecision.Accepted(chan_ab), @@ -205,7 +205,7 @@ abstract class BaseRouterSpec extends TestKitBaseClass with FixtureAnyFunSuiteLi val channels = sender.expectMsgType[Iterable[ChannelAnnouncement]] sender.send(router, GetChannelUpdates) val updates = sender.expectMsgType[Iterable[ChannelUpdate]] - nodes.size === 8 && channels.size === 5 && updates.size === 11 + nodes.size == 8 && channels.size == 5 && updates.size == 11 }, max = 10 seconds, interval = 1 second) withFixture(test.toNoArgTest(FixtureParam(nodeParams, router, watcher))) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/router/ChannelRangeQueriesSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/router/ChannelRangeQueriesSpec.scala index 50aea8114d..15cbbc832f 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/router/ChannelRangeQueriesSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/router/ChannelRangeQueriesSpec.scala @@ -109,25 +109,25 @@ class ChannelRangeQueriesSpec extends AnyFunSuite { assert(getChannelDigestInfo(channels)(ab.shortChannelId) == (Timestamps(now, now), Checksums(1697591108L, 3692323747L))) // no extended info but we know the channel: we ask for the updates - assert(computeFlag(channels)(ab.shortChannelId, None, None, includeNodeAnnouncements = false) === (INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2)) - assert(computeFlag(channels)(ab.shortChannelId, None, None, includeNodeAnnouncements = true) === (INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) + assert(computeFlag(channels)(ab.shortChannelId, None, None, includeNodeAnnouncements = false) == (INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2)) + assert(computeFlag(channels)(ab.shortChannelId, None, None, includeNodeAnnouncements = true) == (INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) // same checksums, newer timestamps: we don't ask anything - assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now + 1, now + 1)), Some(Checksums(1697591108L, 3692323747L)), includeNodeAnnouncements = true) === 0) + assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now + 1, now + 1)), Some(Checksums(1697591108L, 3692323747L)), includeNodeAnnouncements = true) == 0) // different checksums, newer timestamps: we ask for the updates - assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now + 1, now)), Some(Checksums(154654604, 3692323747L)), includeNodeAnnouncements = true) === (INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) - assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now, now + 1)), Some(Checksums(1697591108L, 45664546)), includeNodeAnnouncements = true) === (INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) - assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now + 1, now + 1)), Some(Checksums(154654604, 45664546 + 6)), includeNodeAnnouncements = true) === (INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) + assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now + 1, now)), Some(Checksums(154654604, 3692323747L)), includeNodeAnnouncements = true) == (INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) + assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now, now + 1)), Some(Checksums(1697591108L, 45664546)), includeNodeAnnouncements = true) == (INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) + assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now + 1, now + 1)), Some(Checksums(154654604, 45664546 + 6)), includeNodeAnnouncements = true) == (INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) // different checksums, older timestamps: we don't ask anything - assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now - 1, now)), Some(Checksums(154654604, 3692323747L)), includeNodeAnnouncements = true) === 0) - assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now, now - 1)), Some(Checksums(1697591108L, 45664546)), includeNodeAnnouncements = true) === 0) - assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now - 1, now - 1)), Some(Checksums(154654604, 45664546)), includeNodeAnnouncements = true) === 0) + assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now - 1, now)), Some(Checksums(154654604, 3692323747L)), includeNodeAnnouncements = true) == 0) + assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now, now - 1)), Some(Checksums(1697591108L, 45664546)), includeNodeAnnouncements = true) == 0) + assert(computeFlag(channels)(ab.shortChannelId, Some(Timestamps(now - 1, now - 1)), Some(Checksums(154654604, 45664546)), includeNodeAnnouncements = true) == 0) // missing channel update: we ask for it - assert(computeFlag(channels)(cd.shortChannelId, Some(Timestamps(now, now)), Some(Checksums(3297511804L, 3297511804L)), includeNodeAnnouncements = true) === (INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) + assert(computeFlag(channels)(cd.shortChannelId, Some(Timestamps(now, now)), Some(Checksums(3297511804L, 3297511804L)), includeNodeAnnouncements = true) == (INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) // unknown channel: we ask everything - assert(computeFlag(channels)(ef.shortChannelId, None, None, includeNodeAnnouncements = false) === (INCLUDE_CHANNEL_ANNOUNCEMENT | INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2)) - assert(computeFlag(channels)(ef.shortChannelId, None, None, includeNodeAnnouncements = true) === (INCLUDE_CHANNEL_ANNOUNCEMENT | INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) + assert(computeFlag(channels)(ef.shortChannelId, None, None, includeNodeAnnouncements = false) == (INCLUDE_CHANNEL_ANNOUNCEMENT | INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2)) + assert(computeFlag(channels)(ef.shortChannelId, None, None, includeNodeAnnouncements = true) == (INCLUDE_CHANNEL_ANNOUNCEMENT | INCLUDE_CHANNEL_UPDATE_1 | INCLUDE_CHANNEL_UPDATE_2 | INCLUDE_NODE_ANNOUNCEMENT_1 | INCLUDE_NODE_ANNOUNCEMENT_2)) } def makeShortChannelIds(height: BlockHeight, count: Int): List[ShortChannelId] = { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/router/ChannelRouterIntegrationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/router/ChannelRouterIntegrationSpec.scala index ad98627e6f..daa0d8ed65 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/router/ChannelRouterIntegrationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/router/ChannelRouterIntegrationSpec.scala @@ -39,7 +39,7 @@ class ChannelRouterIntegrationSpec extends TestKitBaseClass with FixtureAnyFunSu reachNormal(channels, testTags) - awaitAssert(router.stateData.privateChannels.size === 1) + awaitAssert(router.stateData.privateChannels.size == 1) { // only the local channel_update is known (bob won't send his before the channel is deeply buried) @@ -69,7 +69,7 @@ class ChannelRouterIntegrationSpec extends TestKitBaseClass with FixtureAnyFunSu val fundingTx = reachNormal(channels, testTags) - awaitAssert(router.stateData.privateChannels.size === 1) + awaitAssert(router.stateData.privateChannels.size == 1) { val pc = router.stateData.privateChannels.values.head diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/router/GraphSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/router/GraphSpec.scala index 9cac18440f..942ede4076 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/router/GraphSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/router/GraphSpec.scala @@ -62,10 +62,10 @@ class GraphSpec extends AnyFunSuite { .addVertex(e) assert(graph.containsVertex(a) && graph.containsVertex(e)) - assert(graph.vertexSet().size === 5) + assert(graph.vertexSet().size == 5) val otherGraph = graph.addVertex(a) // adding the same vertex twice! - assert(otherGraph.vertexSet().size === 5) + assert(otherGraph.vertexSet().size == 5) // add some edges to the graph val edgeAB = makeEdge(1L, a, b, 0 msat, 0) @@ -81,14 +81,14 @@ class GraphSpec extends AnyFunSuite { .addEdge(edgeDC) .addEdge(edgeCE) - assert(graphWithEdges.edgesOf(a).size === 2) - assert(graphWithEdges.edgesOf(b).size === 1) - assert(graphWithEdges.edgesOf(c).size === 1) - assert(graphWithEdges.edgesOf(d).size === 1) - assert(graphWithEdges.edgesOf(e).size === 0) + assert(graphWithEdges.edgesOf(a).size == 2) + assert(graphWithEdges.edgesOf(b).size == 1) + assert(graphWithEdges.edgesOf(c).size == 1) + assert(graphWithEdges.edgesOf(d).size == 1) + assert(graphWithEdges.edgesOf(e).size == 0) val withRemovedEdges = graphWithEdges.removeEdge(edgeAD.desc) - assert(withRemovedEdges.edgesOf(d).size === 1) + assert(withRemovedEdges.edgesOf(d).size == 1) } test("instantiate a graph adding edges only") { @@ -106,10 +106,10 @@ class GraphSpec extends AnyFunSuite { .addEdge(edgeCE) .addEdge(edgeBE) - assert(graph.vertexSet().size === 5) - assert(graph.edgesOf(c).size === 1) - assert(graph.getIncomingEdgesOf(c).size === 2) - assert(graph.edgeSet().size === 6) + assert(graph.vertexSet().size == 5) + assert(graph.edgesOf(c).size == 1) + assert(graph.getIncomingEdgesOf(c).size == 2) + assert(graph.edgeSet().size == 6) } test("containsEdge should return true if the graph contains that edge, false otherwise") { @@ -139,14 +139,14 @@ class GraphSpec extends AnyFunSuite { val edgeAD = makeEdge(3L, a, d, 0 msat, 0) val edgeDC = makeEdge(4L, d, c, 0 msat, 0) - assert(graph.edgeSet().size === 6) + assert(graph.edgeSet().size == 6) assert(graph.containsEdge(edgeBE.desc)) val withRemovedEdge = graph.removeEdge(edgeBE.desc) - assert(withRemovedEdge.edgeSet().size === 5) + assert(withRemovedEdge.edgeSet().size == 5) val withRemovedList = graph.removeEdges(Seq(edgeAD.desc, edgeDC.desc)) - assert(withRemovedList.edgeSet().size === 4) + assert(withRemovedList.edgeSet().size == 4) val withoutAnyIncomingEdgeInE = graph.removeEdges(Seq(edgeBE.desc, edgeCE.desc)) assert(withoutAnyIncomingEdgeInE.containsVertex(e)) @@ -161,19 +161,19 @@ class GraphSpec extends AnyFunSuite { )) val edgesAB = graph.getEdgesBetween(a, b) - assert(edgesAB.size === 1) // there should be an edge a --> b - assert(edgesAB.head.desc.a === a) - assert(edgesAB.head.desc.b === b) + assert(edgesAB.size == 1) // there should be an edge a --> b + assert(edgesAB.head.desc.a == a) + assert(edgesAB.head.desc.b == b) val bIncoming = graph.getIncomingEdgesOf(b) - assert(bIncoming.size === 1) - assert(bIncoming.exists(_.desc.a === a)) // there should be an edge a --> b - assert(bIncoming.exists(_.desc.b === b)) + assert(bIncoming.size == 1) + assert(bIncoming.exists(_.desc.a == a)) // there should be an edge a --> b + assert(bIncoming.exists(_.desc.b == b)) val bOutgoing = graph.edgesOf(b) - assert(bOutgoing.size === 1) - assert(bOutgoing.exists(_.desc.a === b)) - assert(bOutgoing.exists(_.desc.b === c)) + assert(bOutgoing.size == 1) + assert(bOutgoing.exists(_.desc.a == b)) + assert(bOutgoing.exists(_.desc.b == c)) } test("there can be multiple edges between the same vertices") { @@ -192,13 +192,13 @@ class GraphSpec extends AnyFunSuite { val mutatedGraph2 = mutatedGraph.addEdge(edgeForTheSameChannel) assert(mutatedGraph2.edgesOf(a).size == 3) // A --> B , A --> B , A --> D - assert(mutatedGraph2.getEdgesBetween(a, b).size === 2) - assert(mutatedGraph2.getEdge(edgeForTheSameChannel).get.params.relayFees.feeBase === 30.msat) + assert(mutatedGraph2.getEdgesBetween(a, b).size == 2) + assert(mutatedGraph2.getEdge(edgeForTheSameChannel).get.params.relayFees.feeBase == 30.msat) } test("remove a vertex with incoming edges and check those edges are removed too") { val graph = makeTestGraph() - assert(graph.vertexSet().size === 5) + assert(graph.vertexSet().size == 5) assert(graph.containsVertex(e)) assert(graph.containsEdge(descFromNodes(5, c, e))) assert(graph.containsEdge(descFromNodes(6, b, e))) @@ -206,7 +206,7 @@ class GraphSpec extends AnyFunSuite { // E has 2 incoming edges val withoutE = graph.removeVertex(e) - assert(withoutE.vertexSet().size === 4) + assert(withoutE.vertexSet().size == 4) assert(!withoutE.containsVertex(e)) assert(!withoutE.containsEdge(descFromNodes(5, c, e))) assert(!withoutE.containsEdge(descFromNodes(6, b, e))) @@ -219,19 +219,19 @@ class GraphSpec extends AnyFunSuite { val edgeDC = makeEdge(4L, d, c, 0 msat, 0, capacity = 800 sat, balance_opt = Some(50000 msat)) val graph = DirectedGraph(Seq(edgeAB, edgeAD, edgeBC, edgeDC)) - assert(graph.edgesOf(a).toSet === Set(edgeAB, edgeAD)) - assert(graph.getIncomingEdgesOf(a) === Nil) - assert(graph.edgesOf(c) === Nil) - assert(graph.getIncomingEdgesOf(c).toSet === Set(edgeBC, edgeDC)) + assert(graph.edgesOf(a).toSet == Set(edgeAB, edgeAD)) + assert(graph.getIncomingEdgesOf(a) == Nil) + assert(graph.edgesOf(c) == Nil) + assert(graph.getIncomingEdgesOf(c).toSet == Set(edgeBC, edgeDC)) val edgeAB1 = edgeAB.copy(balance_opt = Some(200000 msat)) val edgeBC1 = edgeBC.copy(balance_opt = Some(150000 msat)) val graph1 = graph.addEdge(edgeAB1).addEdge(edgeBC1) - assert(graph1.edgesOf(a).toSet === Set(edgeAB1, edgeAD)) - assert(graph1.getIncomingEdgesOf(a) === Nil) - assert(graph1.edgesOf(c) === Nil) - assert(graph1.getIncomingEdgesOf(c).toSet === Set(edgeBC1, edgeDC)) + assert(graph1.edgesOf(a).toSet == Set(edgeAB1, edgeAD)) + assert(graph1.getIncomingEdgesOf(a) == Nil) + assert(graph1.edgesOf(c) == Nil) + assert(graph1.getIncomingEdgesOf(c).toSet == Set(edgeBC1, edgeDC)) } def descFromNodes(shortChannelId: Long, a: PublicKey, b: PublicKey): ChannelDesc = makeEdge(shortChannelId, a, b, 0 msat, 0).desc diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/router/RouteCalculationSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/router/RouteCalculationSpec.scala index 43816d2074..a44a9afb14 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/router/RouteCalculationSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/router/RouteCalculationSpec.scala @@ -57,7 +57,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route) == 1 :: 2 :: 3 :: 4 :: Nil) } test("check fee against max pct properly") { @@ -78,7 +78,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, maxFee, numRoutes = 1, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route) == 1 :: 2 :: 3 :: 4 :: Nil) } test("calculate the shortest path (correct fees)") { @@ -122,9 +122,9 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(route :: Nil) = findRoute(graph, a, d, amount, maxFee = 7 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) val weightedPath = Graph.pathWeight(a, route2Edges(route), amount, BlockHeight(0), Left(NO_WEIGHT_RATIOS), includeLocalChannelCost = false) - assert(route2Ids(route) === 4 :: 5 :: 6 :: Nil) - assert(weightedPath.length === 3) - assert(weightedPath.amount === expectedCost) + assert(route2Ids(route) == 4 :: 5 :: 6 :: Nil) + assert(weightedPath.length == 3) + assert(weightedPath.amount == expectedCost) // update channel 5 so that it can route the final amount (10000) but not the amount + fees (10002) val graph1 = graph.addEdge(makeEdge(5L, e, f, feeBase = 1 msat, feeProportionalMillionth = 400, minHtlc = 0 msat, maxHtlc = Some(10001 msat))) @@ -132,7 +132,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val graph3 = graph.addEdge(makeEdge(5L, e, f, feeBase = 1 msat, feeProportionalMillionth = 400, minHtlc = 0 msat, balance_opt = Some(10001 msat))) for (g <- Seq(graph1, graph2, graph3)) { val Success(route1 :: Nil) = findRoute(g, a, d, amount, maxFee = 10 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route1) === 1 :: 2 :: 3 :: Nil) + assert(route2Ids(route1) == 1 :: 2 :: 3 :: Nil) } } @@ -146,7 +146,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 2 :: 5 :: Nil) + assert(route2Ids(route) == 2 :: 5 :: Nil) } test("calculate simple route (add and remove edges") { @@ -158,11 +158,11 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route1 :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route1) === 1 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route1) == 1 :: 2 :: 3 :: 4 :: Nil) val graphWithRemovedEdge = g.removeEdge(ChannelDesc(ShortChannelId(3L), c, d)) val route2 = findRoute(graphWithRemovedEdge, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2 === Failure(RouteNotFound)) + assert(route2 == Failure(RouteNotFound)) } test("calculate the shortest path (hardcoded nodes)") { @@ -181,7 +181,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(graph, f, i, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 4 :: 3 :: Nil) + assert(route2Ids(route) == 4 :: 3 :: Nil) } test("calculate the shortest path (select direct channel)") { @@ -200,8 +200,8 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route1 :: route2 :: Nil) = findRoute(graph, f, i, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 2, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route1) === 4 :: Nil) - assert(route2Ids(route2) === 1 :: 2 :: 3 :: Nil) + assert(route2Ids(route1) == 4 :: Nil) + assert(route2Ids(route2) == 1 :: 2 :: 3 :: Nil) } test("find a route using channels with htlMaximumMsat close to the payment amount") { @@ -220,7 +220,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(graph, f, i, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: 2 :: 3 :: Nil) + assert(route2Ids(route) == 1 :: 2 :: 3 :: Nil) } test("find a route using channels with htlMinimumMsat close to the payment amount") { @@ -239,7 +239,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val route = findRoute(graph, f, i, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route === Failure(RouteNotFound)) + assert(route == Failure(RouteNotFound)) } test("if there are multiple channels between the same node, select the cheapest") { @@ -258,7 +258,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(graph, f, i, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: 6 :: 3 :: Nil) + assert(route2Ids(route) == 1 :: 6 :: 3 :: Nil) } test("if there are multiple channels between the same node, select one that has enough balance") { @@ -277,7 +277,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(graph, f, i, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: 2 :: 3 :: Nil) + assert(route2Ids(route) == 1 :: 2 :: 3 :: Nil) } test("calculate longer but cheaper route") { @@ -290,7 +290,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route) == 1 :: 2 :: 3 :: 4 :: Nil) } test("no local channels") { @@ -300,7 +300,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val route = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route === Failure(RouteNotFound)) + assert(route == Failure(RouteNotFound)) } test("route not found") { @@ -311,7 +311,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val route = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route === Failure(RouteNotFound)) + assert(route == Failure(RouteNotFound)) } test("route not found (source OR target node not connected)") { @@ -320,8 +320,8 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { makeEdge(4L, c, d, 0 msat, 0) )).addVertex(a).addVertex(e) - assert(findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) === Failure(RouteNotFound)) - assert(findRoute(g, b, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) === Failure(RouteNotFound)) + assert(findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) == Failure(RouteNotFound)) + assert(findRoute(g, b, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) == Failure(RouteNotFound)) } test("route not found (amount too high OR too low)") { @@ -343,8 +343,8 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val g = DirectedGraph(edgesHi) val g1 = DirectedGraph(edgesLo) - assert(findRoute(g, a, d, highAmount, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) === Failure(RouteNotFound)) - assert(findRoute(g1, a, d, lowAmount, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) === Failure(RouteNotFound)) + assert(findRoute(g, a, d, highAmount, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) == Failure(RouteNotFound)) + assert(findRoute(g1, a, d, lowAmount, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) == Failure(RouteNotFound)) } test("route not found (balance too low)") { @@ -373,7 +373,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { makeEdge(2L, b, c, 1 msat, 2, minHtlc = 10000 msat), makeEdge(3L, c, d, 1 msat, 2, minHtlc = 10000 msat) )) - Seq(g1, g2, g3).foreach(g => assert(findRoute(g, a, d, 15000 msat, 100 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) === Failure(RouteNotFound))) + Seq(g1, g2, g3).foreach(g => assert(findRoute(g, a, d, 15000 msat, 100 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) == Failure(RouteNotFound))) } test("route to self") { @@ -384,7 +384,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val route = findRoute(g, a, a, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route === Failure(CannotRouteToSelf)) + assert(route == Failure(CannotRouteToSelf)) } test("route to immediate neighbor") { @@ -396,7 +396,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(g, a, b, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: Nil) + assert(route2Ids(route) == 1 :: Nil) } test("directed graph") { @@ -409,10 +409,10 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route1 :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route1) === 1 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route1) == 1 :: 2 :: 3 :: 4 :: Nil) val route2 = findRoute(g, e, a, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2 === Failure(RouteNotFound)) + assert(route2 == Failure(RouteNotFound)) } test("calculate route and return metadata") { @@ -440,7 +440,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val g = DirectedGraph(edges) val Success(route :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route.hops === channelHopFromUpdate(a, b, uab) :: channelHopFromUpdate(b, c, ubc) :: channelHopFromUpdate(c, d, ucd) :: channelHopFromUpdate(d, e, ude) :: Nil) + assert(route.hops == channelHopFromUpdate(a, b, uab) :: channelHopFromUpdate(b, c, ubc) :: channelHopFromUpdate(c, d, ucd) :: channelHopFromUpdate(d, e, ude) :: Nil) } test("convert extra hops to assisted channels") { @@ -459,10 +459,10 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val amount = 90000 sat // below RoutingHeuristics.CAPACITY_CHANNEL_LOW val assistedChannels = toAssistedChannels(extraHops, e, amount.toMilliSatoshi) - assert(assistedChannels(extraHop4.shortChannelId) === AssistedChannel(e, ChannelRelayParams.FromHint(extraHop4, 100050.sat.toMilliSatoshi))) - assert(assistedChannels(extraHop3.shortChannelId) === AssistedChannel(d, ChannelRelayParams.FromHint(extraHop3, 100200.sat.toMilliSatoshi))) - assert(assistedChannels(extraHop2.shortChannelId) === AssistedChannel(c, ChannelRelayParams.FromHint(extraHop2, 100400.sat.toMilliSatoshi))) - assert(assistedChannels(extraHop1.shortChannelId) === AssistedChannel(b, ChannelRelayParams.FromHint(extraHop1, 101416.sat.toMilliSatoshi))) + assert(assistedChannels(extraHop4.shortChannelId) == AssistedChannel(e, ChannelRelayParams.FromHint(extraHop4, 100050.sat.toMilliSatoshi))) + assert(assistedChannels(extraHop3.shortChannelId) == AssistedChannel(d, ChannelRelayParams.FromHint(extraHop3, 100200.sat.toMilliSatoshi))) + assert(assistedChannels(extraHop2.shortChannelId) == AssistedChannel(c, ChannelRelayParams.FromHint(extraHop2, 100400.sat.toMilliSatoshi))) + assert(assistedChannels(extraHop1.shortChannelId) == AssistedChannel(b, ChannelRelayParams.FromHint(extraHop1, 101416.sat.toMilliSatoshi))) } test("blacklist routes") { @@ -474,7 +474,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val route1 = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, ignoredEdges = Set(ChannelDesc(ShortChannelId(3L), c, d)), routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route1 === Failure(RouteNotFound)) + assert(route1 == Failure(RouteNotFound)) // verify that we left the graph untouched assert(g.containsEdge(ChannelDesc(ShortChannelId(3), c, d))) @@ -483,7 +483,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { // make sure we can find a route if without the blacklist val Success(route2 :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route2) === 1 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route2) == 1 :: 2 :: 3 :: 4 :: Nil) } test("route to a destination that is not in the graph (with assisted routes)") { @@ -494,12 +494,12 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val route = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route === Failure(RouteNotFound)) + assert(route == Failure(RouteNotFound)) // now we add the missing edge to reach the destination val extraGraphEdges = Set(makeEdge(4L, d, e, 5 msat, 5)) val Success(route1 :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, extraEdges = extraGraphEdges, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route1) === 1 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route1) == 1 :: 2 :: 3 :: 4 :: Nil) } test("route from a source that is not in the graph (with assisted routes)") { @@ -509,12 +509,12 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val route = findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route === Failure(RouteNotFound)) + assert(route == Failure(RouteNotFound)) // now we add the missing starting edge val extraGraphEdges = Set(makeEdge(1L, a, b, 5 msat, 5)) val Success(route1 :: Nil) = findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, extraEdges = extraGraphEdges, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route1) === 1 :: 2 :: 3 :: Nil) + assert(route2Ids(route1) == 1 :: 2 :: 3 :: Nil) } test("verify that extra hops takes precedence over known channels") { @@ -526,13 +526,13 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route1 :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route1) === 1 :: 2 :: 3 :: 4 :: Nil) - assert(route1.hops(1).params.relayFees.feeBase === 10.msat) + assert(route2Ids(route1) == 1 :: 2 :: 3 :: 4 :: Nil) + assert(route1.hops(1).params.relayFees.feeBase == 10.msat) val extraGraphEdges = Set(makeEdge(2L, b, c, 5 msat, 5)) val Success(route2 :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, extraEdges = extraGraphEdges, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route2) === 1 :: 2 :: 3 :: 4 :: Nil) - assert(route2.hops(1).params.relayFees.feeBase === 5.msat) + assert(route2Ids(route2) == 1 :: 2 :: 3 :: 4 :: Nil) + assert(route2.hops(1).params.relayFees.feeBase == 5.msat) } test("compute ignored channels") { @@ -588,10 +588,10 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val g = DirectedGraph(edges) - assert(findRoute(g, nodes(0), nodes(18), DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)).map(r => route2Ids(r.head)) === Success(0 until 18)) - assert(findRoute(g, nodes(0), nodes(19), DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)).map(r => route2Ids(r.head)) === Success(0 until 19)) - assert(findRoute(g, nodes(0), nodes(20), DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)).map(r => route2Ids(r.head)) === Success(0 until 20)) - assert(findRoute(g, nodes(0), nodes(21), DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) === Failure(RouteNotFound)) + assert(findRoute(g, nodes(0), nodes(18), DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)).map(r => route2Ids(r.head)) == Success(0 until 18)) + assert(findRoute(g, nodes(0), nodes(19), DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)).map(r => route2Ids(r.head)) == Success(0 until 19)) + assert(findRoute(g, nodes(0), nodes(20), DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)).map(r => route2Ids(r.head)) == Success(0 until 20)) + assert(findRoute(g, nodes(0), nodes(21), DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) == Failure(RouteNotFound)) } test("ignore cheaper route when it has more than 20 hops") { @@ -607,7 +607,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val g = DirectedGraph(expensiveShortEdge :: edges) val Success(route :: Nil) = findRoute(g, nodes(0), nodes(49), DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 0 :: 1 :: 99 :: 48 :: Nil) + assert(route2Ids(route) == 0 :: 1 :: 99 :: 48 :: Nil) } test("ignore cheaper route when it has more than the requested CLTV") { @@ -622,7 +622,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.modify(_.boundaries.maxCltv).setTo(CltvExpiryDelta(28)), currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 4 :: 5 :: 6 :: Nil) + assert(route2Ids(route) == 4 :: 5 :: 6 :: Nil) } test("ignore cheaper route when it grows longer than the requested size") { @@ -637,7 +637,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(g, a, f, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.modify(_.boundaries.maxRouteLength).setTo(3), currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: 6 :: Nil) + assert(route2Ids(route) == 1 :: 6 :: Nil) } test("ignore loops") { @@ -650,7 +650,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: 2 :: 4 :: 5 :: Nil) + assert(route2Ids(route) == 1 :: 2 :: 4 :: 5 :: Nil) } test("ensure the route calculation terminates correctly when selecting 0-fees edges") { @@ -666,7 +666,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(route :: Nil) = findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Ids(route) === 1 :: 3 :: 5 :: Nil) + assert(route2Ids(route) == 1 :: 3 :: 5 :: Nil) } // +---+ +---+ +---+ @@ -699,19 +699,19 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val fourShortestPaths = Graph.yenKshortestPaths(g1, d, f, DEFAULT_AMOUNT_MSAT, Set.empty, Set.empty, Set.empty, pathsToFind = 4, Left(NO_WEIGHT_RATIOS), BlockHeight(0), noopBoundaries, includeLocalChannelCost = false) - assert(fourShortestPaths.size === 4) - assert(hops2Ids(fourShortestPaths(0).path.map(graphEdgeToHop)) === 2 :: 5 :: Nil) // D -> E -> F - assert(hops2Ids(fourShortestPaths(1).path.map(graphEdgeToHop)) === 1 :: 3 :: 5 :: Nil) // D -> A -> E -> F - assert(hops2Ids(fourShortestPaths(2).path.map(graphEdgeToHop)) === 2 :: 4 :: 6 :: 7 :: Nil) // D -> E -> B -> C -> F - assert(hops2Ids(fourShortestPaths(3).path.map(graphEdgeToHop)) === 1 :: 3 :: 4 :: 6 :: 7 :: Nil) // D -> A -> E -> B -> C -> F + assert(fourShortestPaths.size == 4) + assert(hops2Ids(fourShortestPaths(0).path.map(graphEdgeToHop)) == 2 :: 5 :: Nil) // D -> E -> F + assert(hops2Ids(fourShortestPaths(1).path.map(graphEdgeToHop)) == 1 :: 3 :: 5 :: Nil) // D -> A -> E -> F + assert(hops2Ids(fourShortestPaths(2).path.map(graphEdgeToHop)) == 2 :: 4 :: 6 :: 7 :: Nil) // D -> E -> B -> C -> F + assert(hops2Ids(fourShortestPaths(3).path.map(graphEdgeToHop)) == 1 :: 3 :: 4 :: 6 :: 7 :: Nil) // D -> A -> E -> B -> C -> F // Update balance D -> A to evict the last path (balance too low) val g2 = g1.addEdge(makeEdge(1L, d, a, 1 msat, 0, balance_opt = Some(DEFAULT_AMOUNT_MSAT + 3.msat))) val threeShortestPaths = Graph.yenKshortestPaths(g2, d, f, DEFAULT_AMOUNT_MSAT, Set.empty, Set.empty, Set.empty, pathsToFind = 4, Left(NO_WEIGHT_RATIOS), BlockHeight(0), noopBoundaries, includeLocalChannelCost = false) - assert(threeShortestPaths.size === 3) - assert(hops2Ids(threeShortestPaths(0).path.map(graphEdgeToHop)) === 2 :: 5 :: Nil) // D -> E -> F - assert(hops2Ids(threeShortestPaths(1).path.map(graphEdgeToHop)) === 1 :: 3 :: 5 :: Nil) // D -> A -> E -> F - assert(hops2Ids(threeShortestPaths(2).path.map(graphEdgeToHop)) === 2 :: 4 :: 6 :: 7 :: Nil) // D -> E -> B -> C -> F + assert(threeShortestPaths.size == 3) + assert(hops2Ids(threeShortestPaths(0).path.map(graphEdgeToHop)) == 2 :: 5 :: Nil) // D -> E -> F + assert(hops2Ids(threeShortestPaths(1).path.map(graphEdgeToHop)) == 1 :: 3 :: 5 :: Nil) // D -> A -> E -> F + assert(hops2Ids(threeShortestPaths(2).path.map(graphEdgeToHop)) == 2 :: 4 :: 6 :: 7 :: Nil) // D -> E -> B -> C -> F } test("find the k shortest path (wikipedia example)") { @@ -738,12 +738,12 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val twoShortestPaths = Graph.yenKshortestPaths(graph, c, h, DEFAULT_AMOUNT_MSAT, Set.empty, Set.empty, Set.empty, pathsToFind = 2, Left(NO_WEIGHT_RATIOS), BlockHeight(0), noopBoundaries, includeLocalChannelCost = false) - assert(twoShortestPaths.size === 2) + assert(twoShortestPaths.size == 2) val shortest = twoShortestPaths(0) - assert(hops2Ids(shortest.path.map(graphEdgeToHop)) === 10 :: 50 :: 80 :: Nil) // C -> E -> F -> H + assert(hops2Ids(shortest.path.map(graphEdgeToHop)) == 10 :: 50 :: 80 :: Nil) // C -> E -> F -> H val secondShortest = twoShortestPaths(1) - assert(hops2Ids(secondShortest.path.map(graphEdgeToHop)) === 10 :: 60 :: 90 :: Nil) // C -> E -> G -> H + assert(hops2Ids(secondShortest.path.map(graphEdgeToHop)) == 10 :: 60 :: 90 :: Nil) // C -> E -> G -> H } test("terminate looking for k-shortest path if there are no more alternative paths than k, must not consider routes going back on their steps") { @@ -768,9 +768,9 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { // we ask for 3 shortest paths but only 2 can be found val foundPaths = Graph.yenKshortestPaths(graph, a, f, DEFAULT_AMOUNT_MSAT, Set.empty, Set.empty, Set.empty, pathsToFind = 3, Left(NO_WEIGHT_RATIOS), BlockHeight(0), noopBoundaries, includeLocalChannelCost = false) - assert(foundPaths.size === 2) - assert(hops2Ids(foundPaths(0).path.map(graphEdgeToHop)) === 1 :: 2 :: 3 :: Nil) // A -> B -> C -> F - assert(hops2Ids(foundPaths(1).path.map(graphEdgeToHop)) === 1 :: 2 :: 4 :: 5 :: 6 :: Nil) // A -> B -> C -> D -> E -> F + assert(foundPaths.size == 2) + assert(hops2Ids(foundPaths(0).path.map(graphEdgeToHop)) == 1 :: 2 :: 3 :: Nil) // A -> B -> C -> F + assert(hops2Ids(foundPaths(1).path.map(graphEdgeToHop)) == 1 :: 2 :: 4 :: 5 :: 6 :: Nil) // A -> B -> C -> D -> E -> F } test("select a random route below the requested fee") { @@ -779,7 +779,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { .modify(_.boundaries.maxFeeProportional).setTo(0) .modify(_.randomize).setTo(true) val strictFee = strictFeeParams.getMaxFee(DEFAULT_AMOUNT_MSAT) - assert(strictFee === 7.msat) + assert(strictFee == 7.msat) // A -> B -> C -> D has total cost of 10000005 // A -> E -> C -> D has total cost of 10000103 !! @@ -796,12 +796,12 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { for (_ <- 0 to 10) { val Success(routes) = findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, strictFee, numRoutes = 3, routeParams = strictFeeParams, currentBlockHeight = BlockHeight(400000)) - assert(routes.length === 2, routes) + assert(routes.length == 2, routes) val weightedPath = Graph.pathWeight(a, route2Edges(routes.head), DEFAULT_AMOUNT_MSAT, BlockHeight(400000), Left(NO_WEIGHT_RATIOS), includeLocalChannelCost = false) val totalFees = weightedPath.amount - DEFAULT_AMOUNT_MSAT // over the three routes we could only get the 2 cheapest because the third is too expensive (over 7 msat of fees) - assert(totalFees === 5.msat || totalFees === 6.msat) - assert(weightedPath.length === 3) + assert(totalFees == 5.msat || totalFees == 6.msat) + assert(weightedPath.length == 3) } } @@ -823,7 +823,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val Success(routeFeeOptimized :: Nil) = findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(route2Nodes(routeFeeOptimized) === (a, b) :: (b, c) :: (c, d) :: Nil) + assert(route2Nodes(routeFeeOptimized) == (a, b) :: (b, c) :: (c, d) :: Nil) val Success(routeCltvOptimized :: Nil) = findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Left(WeightRatios( baseFactor = 0, @@ -832,7 +832,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { capacityFactor = 0, hopCost = RelayFees(0 msat, 0), ))), currentBlockHeight = BlockHeight(400000)) - assert(route2Nodes(routeCltvOptimized) === (a, e) :: (e, f) :: (f, d) :: Nil) + assert(route2Nodes(routeCltvOptimized) == (a, e) :: (e, f) :: (f, d) :: Nil) val Success(routeCapacityOptimized :: Nil) = findRoute(g, a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Left(WeightRatios( baseFactor = 0, @@ -841,7 +841,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { capacityFactor = 1, hopCost = RelayFees(0 msat, 0), ))), currentBlockHeight = BlockHeight(400000)) - assert(route2Nodes(routeCapacityOptimized) === (a, e) :: (e, c) :: (c, d) :: Nil) + assert(route2Nodes(routeCapacityOptimized) == (a, e) :: (e, c) :: (c, d) :: Nil) } test("prefer going through an older channel if fees and CLTV are the same") { @@ -864,7 +864,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { hopCost = RelayFees(0 msat, 0), ))), currentBlockHeight = currentBlockHeight) - assert(route2Nodes(routeScoreOptimized) === (a, b) :: (b, c) :: (c, d) :: Nil) + assert(route2Nodes(routeScoreOptimized) == (a, b) :: (b, c) :: (c, d) :: Nil) } test("prefer a route with a smaller total CLTV if fees and score are the same") { @@ -885,7 +885,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { hopCost = RelayFees(0 msat, 0), ))), currentBlockHeight = BlockHeight(400000)) - assert(route2Nodes(routeScoreOptimized) === (a, b) :: (b, c) :: (c, d) :: Nil) + assert(route2Nodes(routeScoreOptimized) == (a, b) :: (b, c) :: (c, d) :: Nil) } test("avoid a route that breaks off the max CLTV") { @@ -908,7 +908,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { hopCost = RelayFees(0 msat, 0), ))), currentBlockHeight = BlockHeight(400000)) - assert(route2Nodes(routeScoreOptimized) === (a, e) :: (e, f) :: (f, d) :: Nil) + assert(route2Nodes(routeScoreOptimized) == (a, e) :: (e, f) :: (f, d) :: Nil) } test("cost function is monotonic") { @@ -987,7 +987,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { val Success(routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) - assert(routes.length === 4, routes) + assert(routes.length == 4, routes) assert(routes.forall(_.length == 1), routes) checkRouteAmounts(routes, amount, 0 msat) } @@ -1000,7 +1000,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { // We set min-part-amount to a value that excludes channels 1 and 4. val failure = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = routeParams.copy(mpp = MultiPartParams(16500 msat, 3)), currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } } @@ -1014,9 +1014,9 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val amount = 25000 msat val Success(routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(routes.length === 1, routes) + assert(routes.length == 1, routes) checkRouteAmounts(routes, amount, 0 msat) - assert(route2Ids(routes.head) === 1L :: Nil) + assert(route2Ids(routes.head) == 1L :: Nil) } test("calculate multipart route to neighbor (many channels, some balance unknown)") { @@ -1030,7 +1030,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val amount = 65000 msat val Success(routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(routes.length === 4, routes) + assert(routes.length == 4, routes) assert(routes.forall(_.length == 1), routes) checkRouteAmounts(routes, amount, 0 msat) } @@ -1049,7 +1049,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { val Success(routes) = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(routes.length === 3, routes) + assert(routes.length == 3, routes) assert(routes.forall(_.length == 1), routes) checkIgnoredChannels(routes, 2L) checkRouteAmounts(routes, amount, 0 msat) @@ -1144,7 +1144,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val amount = 30000 msat val maxFeeTooLow = findMultiPartRoute(g, a, b, amount, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(maxFeeTooLow === Failure(RouteNotFound)) + assert(maxFeeTooLow == Failure(RouteNotFound)) val Success(routes) = findMultiPartRoute(g, a, b, amount, 20 msat, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) assert(routes.forall(_.length <= 2), routes) @@ -1162,11 +1162,11 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { val result = findMultiPartRoute(g, a, b, 40000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(result === Failure(RouteNotFound)) + assert(result == Failure(RouteNotFound)) } { val result = findMultiPartRoute(g, a, b, 40000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS.copy(randomize = true), currentBlockHeight = BlockHeight(400000)) - assert(result === Failure(RouteNotFound)) + assert(result == Failure(RouteNotFound)) } } @@ -1179,7 +1179,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { )) val result = findMultiPartRoute(g, a, b, 5000000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(result === Failure(RouteNotFound)) + assert(result == Failure(RouteNotFound)) } test("cannot find multipart route to neighbor (restricted htlc_minimum_msat)") { @@ -1191,11 +1191,11 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { val result = findMultiPartRoute(g, a, b, 10000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(result === Failure(RouteNotFound)) + assert(result == Failure(RouteNotFound)) } { val result = findMultiPartRoute(g, a, b, 10000 msat, 1 msat, routeParams = DEFAULT_ROUTE_PARAMS.copy(randomize = true), currentBlockHeight = BlockHeight(400000)) - assert(result === Failure(RouteNotFound)) + assert(result == Failure(RouteNotFound)) } } @@ -1219,14 +1219,14 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { val Success(routes) = findMultiPartRoute(g, a, e, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) checkRouteAmounts(routes, amount, maxFee) - assert(routes2Ids(routes) === Set(Seq(1L, 2L, 3L), Seq(4L, 6L), Seq(5L, 6L))) + assert(routes2Ids(routes) == Set(Seq(1L, 2L, 3L), Seq(4L, 6L), Seq(5L, 6L))) } { // Update A - B with unknown balance, capacity should be used instead. val g1 = g.addEdge(edge_ab.copy(capacity = 15 sat, balance_opt = None)) val Success(routes) = findMultiPartRoute(g1, a, e, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) checkRouteAmounts(routes, amount, maxFee) - assert(routes2Ids(routes) === Set(Seq(1L, 2L, 3L), Seq(4L, 6L), Seq(5L, 6L))) + assert(routes2Ids(routes) == Set(Seq(1L, 2L, 3L), Seq(4L, 6L), Seq(5L, 6L))) } { // Randomize routes. @@ -1237,19 +1237,19 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { // Update balance A - B to be too low. val g1 = g.addEdge(edge_ab.copy(balance_opt = Some(2000 msat))) val failure = findMultiPartRoute(g1, a, e, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } { // Update capacity A - B to be too low. val g1 = g.addEdge(edge_ab.copy(capacity = 5 sat, balance_opt = None)) val failure = findMultiPartRoute(g1, a, e, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } { // Try to find a route with a maxFee that's too low. val maxFeeTooLow = 100 msat val failure = findMultiPartRoute(g, a, e, amount, maxFeeTooLow, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } } @@ -1277,7 +1277,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { // But we don't want to split such tiny amounts. val (amount, maxFee) = (2000 msat, 150 msat) val failure = findMultiPartRoute(g, a, e, amount, maxFee, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } } @@ -1291,8 +1291,8 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(routes) = findMultiPartRoute(g, a, d, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) checkRouteAmounts(routes, amount, maxFee) - assert(routes.length === 1, "payment shouldn't be split when we have one path with enough capacity") - assert(routes2Ids(routes) === Set(Seq(1L, 2L, 3L))) + assert(routes.length == 1, "payment shouldn't be split when we have one path with enough capacity") + assert(routes2Ids(routes) == Set(Seq(1L, 2L, 3L))) } test("calculate multipart route to remote node (single local channel)") { @@ -1316,7 +1316,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { val Success(routes) = findMultiPartRoute(g, a, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) checkRouteAmounts(routes, amount, maxFee) - assert(routes2Ids(routes) === Set(Seq(1L, 2L, 3L, 5L), Seq(1L, 4L, 5L), Seq(1L, 6L, 7L))) + assert(routes2Ids(routes) == Set(Seq(1L, 2L, 3L, 5L), Seq(1L, 4L, 5L), Seq(1L, 6L, 7L))) } { // Randomize routes. @@ -1328,25 +1328,25 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val g1 = g.addEdge(edge_ab.copy(capacity = 500 sat, balance_opt = None)) val Success(routes) = findMultiPartRoute(g1, a, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) checkRouteAmounts(routes, amount, maxFee) - assert(routes2Ids(routes) === Set(Seq(1L, 2L, 3L, 5L), Seq(1L, 4L, 5L), Seq(1L, 6L, 7L))) + assert(routes2Ids(routes) == Set(Seq(1L, 2L, 3L, 5L), Seq(1L, 4L, 5L), Seq(1L, 6L, 7L))) } { // Update balance A - B to be too low to cover fees. val g1 = g.addEdge(edge_ab.copy(balance_opt = Some(400000 msat))) val failure = findMultiPartRoute(g1, a, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } { // Update capacity A - B to be too low to cover fees. val g1 = g.addEdge(edge_ab.copy(capacity = 400 sat, balance_opt = None)) val failure = findMultiPartRoute(g1, a, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } { // Try to find a route with a maxFee that's too low. val maxFeeTooLow = 100 msat val failure = findMultiPartRoute(g, a, f, amount, maxFeeTooLow, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } } @@ -1381,23 +1381,23 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val routeParams = DEFAULT_ROUTE_PARAMS.copy(randomize = false, mpp = MultiPartParams(50_000 msat, 5)) val Success(routes) = findMultiPartRoute(g, a, d, amount, maxFee, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) checkRouteAmounts(routes, amount, maxFee) - assert(routes2Ids(routes) === Set(Seq(100L, 101L))) + assert(routes2Ids(routes) == Set(Seq(100L, 101L))) } { val amount = 15_000_000 msat val maxFee = 10_000 msat // this fee is too low to go through the preferred route val routeParams = DEFAULT_ROUTE_PARAMS.copy(randomize = false, mpp = MultiPartParams(50_000 msat, 5)) val failure = findMultiPartRoute(g, a, d, amount, maxFee, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } { val amount = 5_000_000 msat val maxFee = 10_000 msat // this fee is enough to go through the preferred route, but the cheaper ones can handle it val routeParams = DEFAULT_ROUTE_PARAMS.copy(randomize = false, mpp = MultiPartParams(50_000 msat, 5)) val Success(routes) = findMultiPartRoute(g, a, d, amount, maxFee, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) - assert(routes.length === 5) + assert(routes.length == 5) routes.foreach(route => { - assert(route.length === 2) + assert(route.length == 2) assert(route.amount <= 1_200_000.msat) assert(!route.hops.flatMap(h => Seq(h.nodeId, h.nextNodeId)).contains(c)) }) @@ -1432,7 +1432,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val ignoredChannels = Set(ChannelDesc(ShortChannelId(2L), b, c)) val Success(routes) = findMultiPartRoute(g, a, f, amount, maxFee, ignoredEdges = ignoredChannels, ignoredVertices = ignoredNodes, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) checkRouteAmounts(routes, amount, maxFee) - assert(routes2Ids(routes) === Set(Seq(8L), Seq(9L, 10L))) + assert(routes2Ids(routes) == Set(Seq(8L), Seq(9L, 10L))) } test("calculate multipart route to remote node (restricted htlc_minimum_msat and htlc_maximum_msat)") { @@ -1461,7 +1461,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val maxFeeTooLow = 3 msat val failure = findMultiPartRoute(g, a, e, amount, maxFeeTooLow, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } test("calculate multipart route to remote node (complex graph)") { @@ -1498,7 +1498,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { val (amount, maxFee) = (25000 msat, 50 msat) val failure = findMultiPartRoute(g, d, f, amount, maxFee, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } { val (amount, maxFee) = (40000 msat, 100 msat) @@ -1513,7 +1513,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { val (amount, maxFee) = (40000 msat, 50 msat) val failure = findMultiPartRoute(g, d, f, amount, maxFee, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } } @@ -1545,7 +1545,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val maxFeeTooLow = 40 msat val failure = findMultiPartRoute(g, a, f, amount, maxFeeTooLow, extraEdges = extraEdges, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) - assert(failure === Failure(RouteNotFound)) + assert(failure == Failure(RouteNotFound)) } test("calculate multipart route to remote node (pending htlcs)") { @@ -1608,7 +1608,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { findMultiPartRoute(g, d, f, amount, maxFee, routeParams = DEFAULT_ROUTE_PARAMS.copy(randomize = true), currentBlockHeight = BlockHeight(400000)) match { case Success(routes) => checkRouteAmounts(routes, amount, maxFee) - case Failure(ex) => assert(ex === RouteNotFound) + case Failure(ex) => assert(ex == RouteNotFound) } } } @@ -1634,8 +1634,8 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(routes) = findRoute(g, a, e, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 3, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) assert(routes.length == 2) val route1 :: route2 :: Nil = routes - assert(route2Ids(route1) === 1 :: 5 :: Nil) - assert(route2Ids(route2) === 1 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route1) == 1 :: 5 :: Nil) + assert(route2Ids(route2) == 1 :: 2 :: 3 :: 4 :: Nil) } test("reversed loop trap") { @@ -1659,8 +1659,8 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(routes) = findRoute(g, e, a, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, numRoutes = 3, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) assert(routes.length == 2) val route1 :: route2 :: Nil = routes - assert(route2Ids(route1) === 5 :: 1 :: Nil) - assert(route2Ids(route2) === 4 :: 3 :: 2 :: 1 :: Nil) + assert(route2Ids(route1) == 5 :: 1 :: Nil) + assert(route2Ids(route2) == 4 :: 3 :: 2 :: 1 :: Nil) } test("k-shortest paths must be distinct") { @@ -1735,7 +1735,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { makeEdge(1L, a, b, 1000 msat, 7000), )) - assert(findRoute(g, a, b, 10000000 msat, 10000 msat, numRoutes = 3, routeParams = DEFAULT_ROUTE_PARAMS.copy(includeLocalChannelCost = true), currentBlockHeight = BlockHeight(400000)) === Failure(RouteNotFound)) + assert(findRoute(g, a, b, 10000000 msat, 10000 msat, numRoutes = 3, routeParams = DEFAULT_ROUTE_PARAMS.copy(includeLocalChannelCost = true), currentBlockHeight = BlockHeight(400000)) == Failure(RouteNotFound)) assert(findRoute(g, a, b, 10000000 msat, 100000 msat, numRoutes = 3, routeParams = DEFAULT_ROUTE_PARAMS.copy(includeLocalChannelCost = true), currentBlockHeight = BlockHeight(400000)).isSuccess) } @@ -1763,19 +1763,19 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(routes) = findRoute(g, start, b, DEFAULT_AMOUNT_MSAT, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS, currentBlockHeight = BlockHeight(400000)) assert(routes.distinct.length == 1) val route :: Nil = routes - assert(route2Ids(route) === 0 :: 2 :: 5 :: 6 :: 7 :: 4 :: Nil) + assert(route2Ids(route) == 0 :: 2 :: 5 :: 6 :: 7 :: 4 :: Nil) } { // small base hop cost val Success(routes) = findRoute(g, start, b, DEFAULT_AMOUNT_MSAT, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Left(WeightRatios(1, 0, 0, 0, RelayFees(100 msat, 0)))), currentBlockHeight = BlockHeight(400000)) assert(routes.distinct.length == 1) val route :: Nil = routes - assert(route2Ids(route) === 0 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route) == 0 :: 2 :: 3 :: 4 :: Nil) } { // large proportional hop cost val Success(routes) = findRoute(g, start, b, DEFAULT_AMOUNT_MSAT, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Left(WeightRatios(1, 0, 0, 0, RelayFees(0 msat, 200)))), currentBlockHeight = BlockHeight(400000)) assert(routes.distinct.length == 1) val route :: Nil = routes - assert(route2Ids(route) === 0 :: 1 :: Nil) + assert(route2Ids(route) == 0 :: 1 :: Nil) } } @@ -1803,7 +1803,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(routes) = findRoute(g, start, b, DEFAULT_AMOUNT_MSAT, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Right(hc)), currentBlockHeight = BlockHeight(400000)) assert(routes.distinct.length == 1) val route :: Nil = routes - assert(route2Ids(route) === 0 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route) == 0 :: 2 :: 3 :: 4 :: Nil) } @@ -1817,7 +1817,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(routes) = findRoute(g, start, b, DEFAULT_AMOUNT_MSAT, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Right(hc)), currentBlockHeight = BlockHeight(400000)) assert(routes.distinct.length == 1) val route :: Nil = routes - assert(route2Ids(route) === 0 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route) == 0 :: 2 :: 3 :: 4 :: Nil) } } @@ -1844,7 +1844,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(routes) = findRoute(g, start, b, DEFAULT_AMOUNT_MSAT, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Right(hc)), currentBlockHeight = BlockHeight(400000)) assert(routes.distinct.length == 1) val route :: Nil = routes - assert(route2Ids(route) === 0 :: 2 :: 3 :: 4 :: Nil) + assert(route2Ids(route) == 0 :: 2 :: 3 :: 4 :: Nil) } test("edge too small to relay payment is ignored") { @@ -1864,7 +1864,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(routes) = findRoute(g, a, c, DEFAULT_AMOUNT_MSAT, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Right(hc)), currentBlockHeight = BlockHeight(400000)) assert(routes.distinct.length == 1) val route :: Nil = routes - assert(route2Ids(route) === 1 :: 2 :: Nil) + assert(route2Ids(route) == 1 :: 2 :: Nil) } test("use direct channel when available") { @@ -1887,7 +1887,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { val Success(routes) = findRoute(g, a, c, DEFAULT_AMOUNT_MSAT, 100_000_000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Left(wr)), currentBlockHeight = BlockHeight(400000)) assert(routes.distinct.length == 1) val route :: Nil = routes - assert(route2Ids(route) === recentChannelId :: Nil) + assert(route2Ids(route) == recentChannelId :: Nil) } test("trampoline relay with direct channel to target") { @@ -1896,7 +1896,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { { val routeParams = DEFAULT_ROUTE_PARAMS.copy(includeLocalChannelCost = true, boundaries = SearchBoundaries(100_999 msat, 0.0, 6, CltvExpiryDelta(576))) - assert(findMultiPartRoute(g, a, b, amount, 100_999 msat, Set.empty, Set.empty, Set.empty, Nil, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) === Failure(RouteNotFound)) + assert(findMultiPartRoute(g, a, b, amount, 100_999 msat, Set.empty, Set.empty, Set.empty, Nil, routeParams = routeParams, currentBlockHeight = BlockHeight(400000)) == Failure(RouteNotFound)) } { val routeParams = DEFAULT_ROUTE_PARAMS.copy(includeLocalChannelCost = true, boundaries = SearchBoundaries(101_000 msat, 0.0, 6, CltvExpiryDelta(576))) @@ -1905,7 +1905,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { } test("small local edge with liquidity is better than big remote edge") { - // A === B === C -- D + // A == B == C -- D // \_________/ val g = DirectedGraph(List( makeEdge(1L, a, b, 100 msat, 100, minHtlc = 1000 msat, capacity = 100000000 sat, balance_opt = Some(10000000 msat)), @@ -1923,7 +1923,7 @@ class RouteCalculationSpec extends AnyFunSuite with ParallelTestExecution { ) val Success(routes) = findRoute(g, a, d, 50000 msat, 100000000 msat, numRoutes = 1, routeParams = DEFAULT_ROUTE_PARAMS.copy(heuristics = Left(wr), includeLocalChannelCost = true), currentBlockHeight = BlockHeight(400000)) val route :: Nil = routes - assert(route2Ids(route) === 3 :: 4 :: Nil) + assert(route2Ids(route) == 3 :: 4 :: Nil) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/router/RouterSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/router/RouterSpec.scala index f433335c63..d5dfcd1850 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/router/RouterSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/router/RouterSpec.scala @@ -59,12 +59,12 @@ class RouterSpec extends BaseRouterSpec { val node_c = makeNodeAnnouncement(priv_c, "node-C", Color(123, 100, -40), Nil, TestConstants.Bob.nodeParams.features.nodeAnnouncementFeatures(), timestamp = TimestampSecond.now() + 1) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, chan_ac)) peerConnection.expectNoMessage(100 millis) // we don't immediately acknowledge the announcement (back pressure) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_ac) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_ac) watcher.send(router, ValidateResult(chan_ac, Right(Transaction(version = 0, txIn = Nil, txOut = TxOut(1000000 sat, write(pay2wsh(Scripts.multiSig2of2(funding_a, funding_c)))) :: Nil, lockTime = 0), UtxoStatus.Unspent))) peerConnection.expectMsg(TransportHandler.ReadAck(chan_ac)) peerConnection.expectMsg(GossipDecision.Accepted(chan_ac)) assert(peerConnection.sender() == router) - assert(watcher.expectMsgType[WatchExternalChannelSpent].shortChannelId === chan_ac.shortChannelId) + assert(watcher.expectMsgType[WatchExternalChannelSpent].shortChannelId == chan_ac.shortChannelId) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, update_ac)) peerConnection.expectMsg(TransportHandler.ReadAck(update_ac)) peerConnection.expectMsg(GossipDecision.Accepted(update_ac)) @@ -89,7 +89,7 @@ class RouterSpec extends BaseRouterSpec { val node_u = makeNodeAnnouncement(priv_u, "node-U", Color(-120, -20, 60), Nil, Features.empty) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, chan_uc)) peerConnection.expectNoMessage(200 millis) // we don't immediately acknowledge the announcement (back pressure) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_uc) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_uc) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, update_uc)) peerConnection.expectMsg(TransportHandler.ReadAck(update_uc)) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, node_u)) @@ -98,7 +98,7 @@ class RouterSpec extends BaseRouterSpec { peerConnection.expectMsg(TransportHandler.ReadAck(chan_uc)) peerConnection.expectMsg(GossipDecision.Accepted(chan_uc)) assert(peerConnection.sender() == router) - assert(watcher.expectMsgType[WatchExternalChannelSpent].shortChannelId === chan_uc.shortChannelId) + assert(watcher.expectMsgType[WatchExternalChannelSpent].shortChannelId == chan_uc.shortChannelId) peerConnection.expectMsg(GossipDecision.Accepted(update_uc)) peerConnection.expectMsg(GossipDecision.Accepted(node_u)) eventListener.expectMsg(ChannelsDiscovered(SingleChannelDiscovered(chan_uc, 2000000 sat, None, None) :: Nil)) @@ -194,7 +194,7 @@ class RouterSpec extends BaseRouterSpec { val update_ay = makeChannelUpdate(Block.RegtestGenesisBlock.hash, priv_a, priv_y.publicKey, chan_ay.shortChannelId, CltvExpiryDelta(7), 0 msat, 766000 msat, 10, htlcMaximum) val node_y = makeNodeAnnouncement(priv_y, "node-Y", Color(123, 100, -40), Nil, TestConstants.Bob.nodeParams.features.nodeAnnouncementFeatures()) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, chan_ay)) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_ay) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_ay) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, update_ay)) peerConnection.expectMsg(TransportHandler.ReadAck(update_ay)) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, node_y)) @@ -214,7 +214,7 @@ class RouterSpec extends BaseRouterSpec { val priv_x = randomKey() val chan_ax = channelAnnouncement(ShortChannelId(42001), priv_a, priv_x, priv_funding_a, randomKey()) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, chan_ax)) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_ax) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_ax) watcher.send(router, ValidateResult(chan_ax, Left(new RuntimeException("funding tx not found")))) peerConnection.expectMsg(TransportHandler.ReadAck(chan_ax)) peerConnection.expectMsg(GossipDecision.ValidationFailure(chan_ax)) @@ -229,7 +229,7 @@ class RouterSpec extends BaseRouterSpec { val priv_funding_z = randomKey() val chan_az = channelAnnouncement(ShortChannelId(42003), priv_a, priv_z, priv_funding_a, priv_funding_z) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, chan_az)) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_az) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_az) watcher.send(router, ValidateResult(chan_az, Right(Transaction(version = 0, txIn = Nil, txOut = TxOut(1000000 sat, write(pay2wsh(Scripts.multiSig2of2(funding_a, priv_funding_z.publicKey)))) :: Nil, lockTime = 0), UtxoStatus.Spent(spendingTxConfirmed = false)))) peerConnection.expectMsg(TransportHandler.ReadAck(chan_az)) peerConnection.expectMsg(GossipDecision.ChannelClosing(chan_az)) @@ -244,7 +244,7 @@ class RouterSpec extends BaseRouterSpec { val priv_funding_z = randomKey() val chan_az = channelAnnouncement(ShortChannelId(42003), priv_a, priv_z, priv_funding_a, priv_funding_z) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, chan_az)) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_az) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_az) watcher.send(router, ValidateResult(chan_az, Right(Transaction(version = 0, txIn = Nil, txOut = TxOut(1000000 sat, write(pay2wsh(Scripts.multiSig2of2(funding_a, priv_funding_z.publicKey)))) :: Nil, lockTime = 0), UtxoStatus.Spent(spendingTxConfirmed = true)))) peerConnection.expectMsg(TransportHandler.ReadAck(chan_az)) peerConnection.expectMsg(GossipDecision.ChannelClosed(chan_az)) @@ -340,13 +340,13 @@ class RouterSpec extends BaseRouterSpec { val sender = TestProbe() sender.send(router, RouteRequest(a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, routeParams = DEFAULT_ROUTE_PARAMS)) val res = sender.expectMsgType[RouteResponse] - assert(res.routes.head.hops.map(_.nodeId).toList === a :: b :: c :: Nil) - assert(res.routes.head.hops.last.nextNodeId === d) + assert(res.routes.head.hops.map(_.nodeId).toList == a :: b :: c :: Nil) + assert(res.routes.head.hops.last.nextNodeId == d) sender.send(router, RouteRequest(a, h, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, routeParams = DEFAULT_ROUTE_PARAMS)) val res1 = sender.expectMsgType[RouteResponse] - assert(res1.routes.head.hops.map(_.nodeId).toList === a :: g :: Nil) - assert(res1.routes.head.hops.last.nextNodeId === h) + assert(res1.routes.head.hops.map(_.nodeId).toList == a :: g :: Nil) + assert(res1.routes.head.hops.last.nextNodeId == h) } test("route found (with extra routing info)") { fixture => @@ -360,8 +360,8 @@ class RouterSpec extends BaseRouterSpec { val extraHop_yz = ExtraHop(y, ShortChannelId(3), 20 msat, 21, CltvExpiryDelta(22)) sender.send(router, RouteRequest(a, z, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, assistedRoutes = Seq(extraHop_cx :: extraHop_xy :: extraHop_yz :: Nil), routeParams = DEFAULT_ROUTE_PARAMS)) val res = sender.expectMsgType[RouteResponse] - assert(res.routes.head.hops.map(_.nodeId).toList === a :: b :: c :: x :: y :: Nil) - assert(res.routes.head.hops.last.nextNodeId === z) + assert(res.routes.head.hops.map(_.nodeId).toList == a :: b :: c :: x :: y :: Nil) + assert(res.routes.head.hops.last.nextNodeId == z) } test("route not found (channel disabled)") { fixture => @@ -370,8 +370,8 @@ class RouterSpec extends BaseRouterSpec { val peerConnection = TestProbe() sender.send(router, RouteRequest(a, d, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, routeParams = DEFAULT_ROUTE_PARAMS)) val res = sender.expectMsgType[RouteResponse] - assert(res.routes.head.hops.map(_.nodeId).toList === a :: b :: c :: Nil) - assert(res.routes.head.hops.last.nextNodeId === d) + assert(res.routes.head.hops.map(_.nodeId).toList == a :: b :: c :: Nil) + assert(res.routes.head.hops.last.nextNodeId == d) val channelUpdate_cd1 = makeChannelUpdate(Block.RegtestGenesisBlock.hash, priv_c, d, scid_cd, CltvExpiryDelta(3), 0 msat, 153000 msat, 4, htlcMaximum, enable = false) peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, channelUpdate_cd1)) @@ -385,8 +385,8 @@ class RouterSpec extends BaseRouterSpec { val sender = TestProbe() sender.send(router, RouteRequest(a, h, DEFAULT_AMOUNT_MSAT, DEFAULT_MAX_FEE, routeParams = DEFAULT_ROUTE_PARAMS)) val res = sender.expectMsgType[RouteResponse] - assert(res.routes.head.hops.map(_.nodeId).toList === a :: g :: Nil) - assert(res.routes.head.hops.last.nextNodeId === h) + assert(res.routes.head.hops.map(_.nodeId).toList == a :: g :: Nil) + assert(res.routes.head.hops.last.nextNodeId == h) val channelUpdate_ag1 = makeChannelUpdate(Block.RegtestGenesisBlock.hash, priv_a, g, scid_ag_private, CltvExpiryDelta(7), 0 msat, 10 msat, 10, htlcMaximum, enable = false) sender.send(router, LocalChannelUpdate(sender.ref, null, scid_ag_private, g, None, channelUpdate_ag1, CommitmentsSpec.makeCommitments(10000 msat, 15000 msat, a, g, announceChannel = false))) @@ -448,7 +448,7 @@ class RouterSpec extends BaseRouterSpec { assert(state.channels.size == 5) assert(state.nodes.size == 8) assert(state.channels.flatMap(c => c.update_1_opt.toSeq ++ c.update_2_opt.toSeq).size == 10) - state.channels.foreach(c => assert(c.capacity === publicChannelCapacity)) + state.channels.foreach(c => assert(c.capacity == publicChannelCapacity)) } test("given a pre-defined nodes route add the proper channel updates") { fixture => @@ -460,9 +460,9 @@ class RouterSpec extends BaseRouterSpec { val response = sender.expectMsgType[RouteResponse] // the route hasn't changed (nodes are the same) - assert(response.routes.head.hops.map(_.nodeId) === preComputedRoute.nodes.dropRight(1)) - assert(response.routes.head.hops.map(_.nextNodeId) === preComputedRoute.nodes.drop(1)) - assert(response.routes.head.hops.map(_.params) === Seq(ChannelRelayParams.FromAnnouncement(update_ab), ChannelRelayParams.FromAnnouncement(update_bc), ChannelRelayParams.FromAnnouncement(update_cd))) + assert(response.routes.head.hops.map(_.nodeId) == preComputedRoute.nodes.dropRight(1)) + assert(response.routes.head.hops.map(_.nextNodeId) == preComputedRoute.nodes.drop(1)) + assert(response.routes.head.hops.map(_.params) == Seq(ChannelRelayParams.FromAnnouncement(update_ab), ChannelRelayParams.FromAnnouncement(update_bc), ChannelRelayParams.FromAnnouncement(update_cd))) } test("given a pre-defined channels route add the proper channel updates") { fixture => @@ -474,9 +474,9 @@ class RouterSpec extends BaseRouterSpec { val response = sender.expectMsgType[RouteResponse] // the route hasn't changed (nodes are the same) - assert(response.routes.head.hops.map(_.nodeId) === Seq(a, b, c)) - assert(response.routes.head.hops.map(_.nextNodeId) === Seq(b, c, d)) - assert(response.routes.head.hops.map(_.params) === Seq(ChannelRelayParams.FromAnnouncement(update_ab), ChannelRelayParams.FromAnnouncement(update_bc), ChannelRelayParams.FromAnnouncement(update_cd))) + assert(response.routes.head.hops.map(_.nodeId) == Seq(a, b, c)) + assert(response.routes.head.hops.map(_.nextNodeId) == Seq(b, c, d)) + assert(response.routes.head.hops.map(_.params) == Seq(ChannelRelayParams.FromAnnouncement(update_ab), ChannelRelayParams.FromAnnouncement(update_bc), ChannelRelayParams.FromAnnouncement(update_cd))) } test("given a pre-defined private channels route add the proper channel updates") { fixture => @@ -487,21 +487,21 @@ class RouterSpec extends BaseRouterSpec { val preComputedRoute = PredefinedChannelRoute(g, Seq(scid_ag_private)) sender.send(router, FinalizeRoute(10000 msat, preComputedRoute)) val response = sender.expectMsgType[RouteResponse] - assert(response.routes.length === 1) + assert(response.routes.length == 1) val route = response.routes.head - assert(route.hops.map(_.params) === Seq(ChannelRelayParams.FromAnnouncement(update_ag_private))) - assert(route.hops.head.nodeId === a) - assert(route.hops.head.nextNodeId === g) + assert(route.hops.map(_.params) == Seq(ChannelRelayParams.FromAnnouncement(update_ag_private))) + assert(route.hops.head.nodeId == a) + assert(route.hops.head.nextNodeId == g) } { val preComputedRoute = PredefinedChannelRoute(h, Seq(scid_ag_private, scid_gh)) sender.send(router, FinalizeRoute(10000 msat, preComputedRoute)) val response = sender.expectMsgType[RouteResponse] - assert(response.routes.length === 1) + assert(response.routes.length == 1) val route = response.routes.head - assert(route.hops.map(_.nodeId) === Seq(a, g)) - assert(route.hops.map(_.nextNodeId) === Seq(g, h)) - assert(route.hops.map(_.params) === Seq(ChannelRelayParams.FromAnnouncement(update_ag_private), ChannelRelayParams.FromAnnouncement(update_gh))) + assert(route.hops.map(_.nodeId) == Seq(a, g)) + assert(route.hops.map(_.nextNodeId) == Seq(g, h)) + assert(route.hops.map(_.params) == Seq(ChannelRelayParams.FromAnnouncement(update_ag_private), ChannelRelayParams.FromAnnouncement(update_gh))) } } @@ -518,12 +518,12 @@ class RouterSpec extends BaseRouterSpec { assert(amount < RoutingHeuristics.CAPACITY_CHANNEL_LOW) sender.send(router, FinalizeRoute(amount, preComputedRoute, assistedRoutes = Seq(Seq(invoiceRoutingHint)))) val response = sender.expectMsgType[RouteResponse] - assert(response.routes.length === 1) + assert(response.routes.length == 1) val route = response.routes.head - assert(route.hops.map(_.nodeId) === Seq(a, b)) - assert(route.hops.map(_.nextNodeId) === Seq(b, targetNodeId)) - assert(route.hops.head.params === ChannelRelayParams.FromAnnouncement(update_ab)) - assert(route.hops.last.params === ChannelRelayParams.FromHint(invoiceRoutingHint, RoutingHeuristics.CAPACITY_CHANNEL_LOW + nodeFee(invoiceRoutingHint.feeBase, invoiceRoutingHint.feeProportionalMillionths, RoutingHeuristics.CAPACITY_CHANNEL_LOW))) + assert(route.hops.map(_.nodeId) == Seq(a, b)) + assert(route.hops.map(_.nextNodeId) == Seq(b, targetNodeId)) + assert(route.hops.head.params == ChannelRelayParams.FromAnnouncement(update_ab)) + assert(route.hops.last.params == ChannelRelayParams.FromHint(invoiceRoutingHint, RoutingHeuristics.CAPACITY_CHANNEL_LOW + nodeFee(invoiceRoutingHint.feeBase, invoiceRoutingHint.feeProportionalMillionths, RoutingHeuristics.CAPACITY_CHANNEL_LOW))) } { val invoiceRoutingHint = ExtraHop(h, ShortChannelId(BlockHeight(420000), 516, 1105), 10 msat, 150, CltvExpiryDelta(96)) @@ -533,12 +533,12 @@ class RouterSpec extends BaseRouterSpec { assert(amount > RoutingHeuristics.CAPACITY_CHANNEL_LOW) sender.send(router, FinalizeRoute(amount, preComputedRoute, assistedRoutes = Seq(Seq(invoiceRoutingHint)))) val response = sender.expectMsgType[RouteResponse] - assert(response.routes.length === 1) + assert(response.routes.length == 1) val route = response.routes.head - assert(route.hops.map(_.nodeId) === Seq(a, g, h)) - assert(route.hops.map(_.nextNodeId) === Seq(g, h, targetNodeId)) - assert(route.hops.map(_.params).dropRight(1) === Seq(ChannelRelayParams.FromAnnouncement(update_ag_private), ChannelRelayParams.FromAnnouncement(update_gh))) - assert(route.hops.last.params === ChannelRelayParams.FromHint(invoiceRoutingHint, amount + nodeFee(invoiceRoutingHint.feeBase, invoiceRoutingHint.feeProportionalMillionths, amount))) + assert(route.hops.map(_.nodeId) == Seq(a, g, h)) + assert(route.hops.map(_.nextNodeId) == Seq(g, h, targetNodeId)) + assert(route.hops.map(_.params).dropRight(1) == Seq(ChannelRelayParams.FromAnnouncement(update_ag_private), ChannelRelayParams.FromAnnouncement(update_gh))) + assert(route.hops.last.params == ChannelRelayParams.FromHint(invoiceRoutingHint, amount + nodeFee(invoiceRoutingHint.feeBase, invoiceRoutingHint.feeProportionalMillionths, amount))) } } @@ -605,7 +605,7 @@ class RouterSpec extends BaseRouterSpec { val sender = TestProbe() sender.send(router, GetRoutingState) val channel_ab = sender.expectMsgType[RoutingState].channels.find(_.ann == chan_ab).get - assert(channel_ab.meta_opt === None) + assert(channel_ab.meta_opt == None) { // When the local channel comes back online, it will send a LocalChannelUpdate to the router. @@ -614,7 +614,7 @@ class RouterSpec extends BaseRouterSpec { sender.send(router, LocalChannelUpdate(sender.ref, null, scid_ab, b, Some(chan_ab), update_ab, commitments)) sender.send(router, GetRoutingState) val channel_ab = sender.expectMsgType[RoutingState].channels.find(_.ann == chan_ab).get - assert(Set(channel_ab.meta_opt.map(_.balance1), channel_ab.meta_opt.map(_.balance2)) === balances) + assert(Set(channel_ab.meta_opt.map(_.balance1), channel_ab.meta_opt.map(_.balance2)) == balances) // And the graph should be updated too. sender.send(router, Router.GetRouterData) val g = sender.expectMsgType[Data].graph @@ -622,7 +622,7 @@ class RouterSpec extends BaseRouterSpec { val edge_ba = g.getEdge(ChannelDesc(scid_ab, b, a)).get assert(edge_ab.capacity == channel_ab.capacity && edge_ba.capacity == channel_ab.capacity) assert(balances.contains(edge_ab.balance_opt)) - assert(edge_ba.balance_opt === None) + assert(edge_ba.balance_opt == None) } { @@ -637,7 +637,7 @@ class RouterSpec extends BaseRouterSpec { sender.send(router, LocalChannelUpdate(sender.ref, null, scid_ab, b, Some(chan_ab), update_ab, commitments)) sender.send(router, GetRoutingState) val channel_ab = sender.expectMsgType[RoutingState].channels.find(_.ann == chan_ab).get - assert(Set(channel_ab.meta_opt.map(_.balance1), channel_ab.meta_opt.map(_.balance2)) === balances) + assert(Set(channel_ab.meta_opt.map(_.balance1), channel_ab.meta_opt.map(_.balance2)) == balances) // And the graph should be updated too. sender.send(router, Router.GetRouterData) val g = sender.expectMsgType[Data].graph @@ -645,7 +645,7 @@ class RouterSpec extends BaseRouterSpec { val edge_ba = g.getEdge(ChannelDesc(scid_ab, b, a)).get assert(edge_ab.capacity == channel_ab.capacity && edge_ba.capacity == channel_ab.capacity) assert(balances.contains(edge_ab.balance_opt)) - assert(edge_ba.balance_opt === None) + assert(edge_ba.balance_opt == None) } { @@ -655,7 +655,7 @@ class RouterSpec extends BaseRouterSpec { sender.send(router, AvailableBalanceChanged(sender.ref, null, scid_ab, commitments)) sender.send(router, GetRoutingState) val channel_ab = sender.expectMsgType[RoutingState].channels.find(_.ann == chan_ab).get - assert(Set(channel_ab.meta_opt.map(_.balance1), channel_ab.meta_opt.map(_.balance2)) === balances) + assert(Set(channel_ab.meta_opt.map(_.balance1), channel_ab.meta_opt.map(_.balance2)) == balances) // And the graph should be updated too. sender.send(router, Router.GetRouterData) val g = sender.expectMsgType[Data].graph @@ -663,7 +663,7 @@ class RouterSpec extends BaseRouterSpec { val edge_ba = g.getEdge(ChannelDesc(scid_ab, b, a)).get assert(edge_ab.capacity == channel_ab.capacity && edge_ba.capacity == channel_ab.capacity) assert(balances.contains(edge_ab.balance_opt)) - assert(edge_ba.balance_opt === None) + assert(edge_ba.balance_opt == None) } { @@ -674,11 +674,11 @@ class RouterSpec extends BaseRouterSpec { sender.send(router, Router.GetRouterData) val data = sender.expectMsgType[Data] val channel_ag = data.privateChannels(channelId_ag_private) - assert(Set(channel_ag.meta.balance1, channel_ag.meta.balance2) === balances) + assert(Set(channel_ag.meta.balance1, channel_ag.meta.balance2) == balances) // And the graph should be updated too. val edge_ag = data.graph.getEdge(ChannelDesc(scid_ag_private, a, g)).get assert(edge_ag.capacity == channel_ag.capacity) - assert(edge_ag.balance_opt === Some(33000000 msat)) + assert(edge_ag.balance_opt == Some(33000000 msat)) } } @@ -702,7 +702,7 @@ class RouterSpec extends BaseRouterSpec { false case RoutingStateStreamingUpToDate => true } - assert(nodes.size === 8 && channels.size === 5 && updates.size === 10) // public channels only + assert(nodes.size == 8 && channels.size == 5 && updates.size == 10) // public channels only // just making sure that we have been subscribed to network events, otherwise there is a possible race condition awaitCond({ diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/router/RoutingSyncSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/router/RoutingSyncSpec.scala index b2e9dc3d4d..5abee91aba 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/router/RoutingSyncSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/router/RoutingSyncSpec.scala @@ -140,9 +140,9 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle val extendedQueryFlags_opt = None // tell alice to sync with bob - assert(BasicSyncResult(ranges = 1, queries = 0, channels = 0, updates = 0, nodes = 0) === sync(alice, bob, extendedQueryFlags_opt).counts) - awaitCond(alice.stateData.channels === bob.stateData.channels) - awaitCond(alice.stateData.nodes === bob.stateData.nodes) + assert(BasicSyncResult(ranges = 1, queries = 0, channels = 0, updates = 0, nodes = 0) == sync(alice, bob, extendedQueryFlags_opt).counts) + awaitCond(alice.stateData.channels == bob.stateData.channels) + awaitCond(alice.stateData.nodes == bob.stateData.nodes) // add some channels and updates to bob and resync fakeRoutingInfo.take(10).values.foreach { @@ -153,18 +153,18 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, na1)) sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, na2)) } - awaitCond(bob.stateData.channels.size === 10 && countUpdates(bob.stateData.channels) === 10) - assert(BasicSyncResult(ranges = 1, queries = 2, channels = 10, updates = 10, nodes = 10 * 2) === sync(alice, bob, extendedQueryFlags_opt).counts) - awaitCond(alice.stateData.channels === bob.stateData.channels) + awaitCond(bob.stateData.channels.size == 10 && countUpdates(bob.stateData.channels) == 10) + assert(BasicSyncResult(ranges = 1, queries = 2, channels = 10, updates = 10, nodes = 10 * 2) == sync(alice, bob, extendedQueryFlags_opt).counts) + awaitCond(alice.stateData.channels == bob.stateData.channels) // add some updates to bob and resync fakeRoutingInfo.take(10).values.foreach { case (pc, _, _) => sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, pc.update_2_opt.get)) } - awaitCond(bob.stateData.channels.size === 10 && countUpdates(bob.stateData.channels) === 10 * 2) - assert(BasicSyncResult(ranges = 1, queries = 2, channels = 10, updates = 10 * 2, nodes = 10 * 2) === sync(alice, bob, extendedQueryFlags_opt).counts) - awaitCond(alice.stateData.channels === bob.stateData.channels) + awaitCond(bob.stateData.channels.size == 10 && countUpdates(bob.stateData.channels) == 10 * 2) + assert(BasicSyncResult(ranges = 1, queries = 2, channels = 10, updates = 10 * 2, nodes = 10 * 2) == sync(alice, bob, extendedQueryFlags_opt).counts) + awaitCond(alice.stateData.channels == bob.stateData.channels) // add everything (duplicates will be ignored) fakeRoutingInfo.values.foreach { @@ -175,9 +175,9 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, na1)) sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, na2)) } - awaitCond(bob.stateData.channels.size === fakeRoutingInfo.size && countUpdates(bob.stateData.channels) === 2 * fakeRoutingInfo.size, max = 60 seconds) - assert(BasicSyncResult(ranges = 3, queries = 13, channels = fakeRoutingInfo.size, updates = 2 * fakeRoutingInfo.size, nodes = 2 * fakeRoutingInfo.size) === sync(alice, bob, extendedQueryFlags_opt).counts) - awaitCond(alice.stateData.channels === bob.stateData.channels, max = 60 seconds) + awaitCond(bob.stateData.channels.size == fakeRoutingInfo.size && countUpdates(bob.stateData.channels) == 2 * fakeRoutingInfo.size, max = 60 seconds) + assert(BasicSyncResult(ranges = 3, queries = 13, channels = fakeRoutingInfo.size, updates = 2 * fakeRoutingInfo.size, nodes = 2 * fakeRoutingInfo.size) == sync(alice, bob, extendedQueryFlags_opt).counts) + awaitCond(alice.stateData.channels == bob.stateData.channels, max = 60 seconds) } def syncWithExtendedQueries(requestNodeAnnouncements: Boolean): Unit = { @@ -189,8 +189,8 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle val extendedQueryFlags_opt = Some(QueryChannelRangeTlv.QueryFlags(QueryChannelRangeTlv.QueryFlags.WANT_ALL)) // tell alice to sync with bob - assert(BasicSyncResult(ranges = 1, queries = 0, channels = 0, updates = 0, nodes = 0) === sync(alice, bob, extendedQueryFlags_opt).counts) - awaitCond(alice.stateData.channels === bob.stateData.channels) + assert(BasicSyncResult(ranges = 1, queries = 0, channels = 0, updates = 0, nodes = 0) == sync(alice, bob, extendedQueryFlags_opt).counts) + awaitCond(alice.stateData.channels == bob.stateData.channels) // add some channels and updates to bob and resync fakeRoutingInfo.take(10).values.foreach { @@ -201,19 +201,19 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, na1)) sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, na2)) } - awaitCond(bob.stateData.channels.size === 10 && countUpdates(bob.stateData.channels) === 10) - assert(BasicSyncResult(ranges = 1, queries = 2, channels = 10, updates = 10, nodes = if (requestNodeAnnouncements) 10 * 2 else 0) === sync(alice, bob, extendedQueryFlags_opt).counts) - awaitCond(alice.stateData.channels === bob.stateData.channels, max = 60 seconds) - if (requestNodeAnnouncements) awaitCond(alice.stateData.nodes === bob.stateData.nodes) + awaitCond(bob.stateData.channels.size == 10 && countUpdates(bob.stateData.channels) == 10) + assert(BasicSyncResult(ranges = 1, queries = 2, channels = 10, updates = 10, nodes = if (requestNodeAnnouncements) 10 * 2 else 0) == sync(alice, bob, extendedQueryFlags_opt).counts) + awaitCond(alice.stateData.channels == bob.stateData.channels, max = 60 seconds) + if (requestNodeAnnouncements) awaitCond(alice.stateData.nodes == bob.stateData.nodes) // add some updates to bob and resync fakeRoutingInfo.take(10).values.foreach { case (pc, _, _) => sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, pc.update_2_opt.get)) } - awaitCond(bob.stateData.channels.size === 10 && countUpdates(bob.stateData.channels) === 10 * 2) - assert(BasicSyncResult(ranges = 1, queries = 2, channels = 0, updates = 10, nodes = if (requestNodeAnnouncements) 10 * 2 else 0) === sync(alice, bob, extendedQueryFlags_opt).counts) - awaitCond(alice.stateData.channels === bob.stateData.channels, max = 60 seconds) + awaitCond(bob.stateData.channels.size == 10 && countUpdates(bob.stateData.channels) == 10 * 2) + assert(BasicSyncResult(ranges = 1, queries = 2, channels = 0, updates = 10, nodes = if (requestNodeAnnouncements) 10 * 2 else 0) == sync(alice, bob, extendedQueryFlags_opt).counts) + awaitCond(alice.stateData.channels == bob.stateData.channels, max = 60 seconds) // add everything (duplicates will be ignored) fakeRoutingInfo.values.foreach { @@ -224,9 +224,9 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, na1)) sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, na2)) } - awaitCond(bob.stateData.channels.size === fakeRoutingInfo.size && countUpdates(bob.stateData.channels) === 2 * fakeRoutingInfo.size, max = 60 seconds) - assert(BasicSyncResult(ranges = 3, queries = 11, channels = fakeRoutingInfo.size - 10, updates = 2 * (fakeRoutingInfo.size - 10), nodes = if (requestNodeAnnouncements) 2 * (fakeRoutingInfo.size - 10) else 0) === sync(alice, bob, extendedQueryFlags_opt).counts) - awaitCond(alice.stateData.channels === bob.stateData.channels, max = 60 seconds) + awaitCond(bob.stateData.channels.size == fakeRoutingInfo.size && countUpdates(bob.stateData.channels) == 2 * fakeRoutingInfo.size, max = 60 seconds) + assert(BasicSyncResult(ranges = 3, queries = 11, channels = fakeRoutingInfo.size - 10, updates = 2 * (fakeRoutingInfo.size - 10), nodes = if (requestNodeAnnouncements) 2 * (fakeRoutingInfo.size - 10) else 0) == sync(alice, bob, extendedQueryFlags_opt).counts) + awaitCond(alice.stateData.channels == bob.stateData.channels, max = 60 seconds) // bump random channel_updates def touchUpdate(shortChannelId: Int, side: Boolean) = { @@ -236,9 +236,9 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle val bumpedUpdates = (List(0, 3, 7).map(touchUpdate(_, side = true)) ++ List(1, 3, 9).map(touchUpdate(_, side = false))).toSet bumpedUpdates.foreach(c => sender.send(bob, PeerRoutingMessage(sender.ref, charlieId, c))) - assert(BasicSyncResult(ranges = 3, queries = 1, channels = 0, updates = bumpedUpdates.size, nodes = if (requestNodeAnnouncements) 5 * 2 else 0) === sync(alice, bob, extendedQueryFlags_opt).counts) - awaitCond(alice.stateData.channels === bob.stateData.channels, max = 60 seconds) - if (requestNodeAnnouncements) awaitCond(alice.stateData.nodes === bob.stateData.nodes) + assert(BasicSyncResult(ranges = 3, queries = 1, channels = 0, updates = bumpedUpdates.size, nodes = if (requestNodeAnnouncements) 5 * 2 else 0) == sync(alice, bob, extendedQueryFlags_opt).counts) + awaitCond(alice.stateData.channels == bob.stateData.channels, max = 60 seconds) + if (requestNodeAnnouncements) awaitCond(alice.stateData.nodes == bob.stateData.nodes) } test("sync with extended channel queries (don't request node announcements)") { @@ -263,12 +263,12 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle sender.send(router, SendChannelQuery(params.chainHash, remoteNodeId, sender.ref, replacePrevious = true, None)) val QueryChannelRange(chainHash, firstBlockNum, numberOfBlocks, _) = sender.expectMsgType[QueryChannelRange] sender.expectMsgType[GossipTimestampFilter] - assert(router.stateData.sync.get(remoteNodeId) === Some(Syncing(Nil, 0))) + assert(router.stateData.sync.get(remoteNodeId) == Some(Syncing(Nil, 0))) // ask router to send another channel range query sender.send(router, SendChannelQuery(params.chainHash, remoteNodeId, sender.ref, replacePrevious = false, None)) sender.expectNoMessage(100 millis) // it's a duplicate and should be ignored - assert(router.stateData.sync.get(remoteNodeId) === Some(Syncing(Nil, 0))) + assert(router.stateData.sync.get(remoteNodeId) == Some(Syncing(Nil, 0))) val block1 = ReplyChannelRange(chainHash, firstBlockNum, numberOfBlocks, 1, EncodedShortChannelIds(EncodingType.UNCOMPRESSED, fakeRoutingInfo.take(params.routerConf.channelQueryChunkSize).keys.toList), None, None) @@ -276,7 +276,7 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle peerConnection.send(router, PeerRoutingMessage(peerConnection.ref, remoteNodeId, block1)) // router should ask for our first block of ids - assert(peerConnection.expectMsgType[QueryShortChannelIds] === QueryShortChannelIds(chainHash, block1.shortChannelIds, TlvStream.empty)) + assert(peerConnection.expectMsgType[QueryShortChannelIds] == QueryShortChannelIds(chainHash, block1.shortChannelIds, TlvStream.empty)) // router should think that it is missing 100 channels, in one request val Some(sync) = router.stateData.sync.get(remoteNodeId) assert(sync.remainingQueries.isEmpty) // the request was sent already @@ -286,7 +286,7 @@ class RoutingSyncSpec extends TestKitBaseClass with AnyFunSuiteLike with Paralle sender.send(router, SendChannelQuery(params.chainHash, remoteNodeId, sender.ref, replacePrevious = true, None)) sender.expectMsgType[QueryChannelRange] sender.expectMsgType[GossipTimestampFilter] - assert(router.stateData.sync.get(remoteNodeId) === Some(Syncing(Nil, 0))) + assert(router.stateData.sync.get(remoteNodeId) == Some(Syncing(Nil, 0))) } test("reject unsolicited sync") { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/tor/TorProtocolHandlerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/tor/TorProtocolHandlerSpec.scala index 9b342051e5..056866728d 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/tor/TorProtocolHandlerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/tor/TorProtocolHandlerSpec.scala @@ -101,9 +101,9 @@ class TorProtocolHandlerSpec extends TestKitBaseClass expectMsg(Some(Tor2("z4zif3fy7fe7bpg3", 9999))) val address = Await.result(promiseOnionAddress.future, 3 seconds) - assert(address === Tor2("z4zif3fy7fe7bpg3", 9999)) + assert(address == Tor2("z4zif3fy7fe7bpg3", 9999)) - assert(readString(PkFilePath) === "RSA1024:private-key") + assert(readString(PkFilePath) == "RSA1024:private-key") } test("happy path v3") { @@ -142,9 +142,9 @@ class TorProtocolHandlerSpec extends TestKitBaseClass expectMsg(Some(Tor3("mrl2d3ilhctt2vw4qzvmz3etzjvpnc6dczliq5chrxetthgbuczuggyd", 9999))) val address = Await.result(promiseOnionAddress.future, 3 seconds) - assert(address === Tor3("mrl2d3ilhctt2vw4qzvmz3etzjvpnc6dczliq5chrxetthgbuczuggyd", 9999)) + assert(address == Tor3("mrl2d3ilhctt2vw4qzvmz3etzjvpnc6dczliq5chrxetthgbuczuggyd", 9999)) - assert(readString(PkFilePath) === "ED25519-V3:private-key") + assert(readString(PkFilePath) == "ED25519-V3:private-key") } test("v2/v3 compatibility check against tor version") { @@ -179,7 +179,7 @@ class TorProtocolHandlerSpec extends TestKitBaseClass assert(intercept[TorException] { Await.result(promiseOnionAddress.future, 3 seconds) - } === TorException("cannot use authentication 'password', supported methods are 'COOKIE,SAFECOOKIE'")) + } == TorException("cannot use authentication 'password', supported methods are 'COOKIE,SAFECOOKIE'")) } test("invalid server hash") { @@ -211,7 +211,7 @@ class TorProtocolHandlerSpec extends TestKitBaseClass assert(intercept[TorException] { Await.result(promiseOnionAddress.future, 3 seconds) - } === TorException("unexpected server hash")) + } == TorException("unexpected server hash")) } @@ -249,7 +249,7 @@ class TorProtocolHandlerSpec extends TestKitBaseClass assert(intercept[TorException] { Await.result(promiseOnionAddress.future, 3 seconds) - } === TorException("server returned error: 515 Authentication failed: Safe cookie response did not match expected value.")) + } == TorException("server returned error: 515 Authentication failed: Safe cookie response did not match expected value.")) } test("ADD_ONION failure") { @@ -295,7 +295,7 @@ class TorProtocolHandlerSpec extends TestKitBaseClass assert(intercept[TorException] { Await.result(promiseOnionAddress.future, 3 seconds) - } === TorException("server returned error: 513 Invalid argument")) + } == TorException("server returned error: 513 Invalid argument")) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/transactions/CommitmentSpecSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/transactions/CommitmentSpecSpec.scala index 443e3ecdbf..6d5a6f8ae6 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/transactions/CommitmentSpecSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/transactions/CommitmentSpecSpec.scala @@ -31,19 +31,19 @@ class CommitmentSpecSpec extends AnyFunSuite { val add1 = UpdateAddHtlc(ByteVector32.Zeroes, 1, (2000 * 1000) msat, H, CltvExpiry(400), TestConstants.emptyOnionPacket) val spec1 = CommitmentSpec.reduce(spec, add1 :: Nil, Nil) - assert(spec1 === spec.copy(htlcs = Set(OutgoingHtlc(add1)), toLocal = 3000000 msat)) + assert(spec1 == spec.copy(htlcs = Set(OutgoingHtlc(add1)), toLocal = 3000000 msat)) val add2 = UpdateAddHtlc(ByteVector32.Zeroes, 2, (1000 * 1000) msat, H, CltvExpiry(400), TestConstants.emptyOnionPacket) val spec2 = CommitmentSpec.reduce(spec1, add2 :: Nil, Nil) - assert(spec2 === spec1.copy(htlcs = Set(OutgoingHtlc(add1), OutgoingHtlc(add2)), toLocal = 2000000 msat)) + assert(spec2 == spec1.copy(htlcs = Set(OutgoingHtlc(add1), OutgoingHtlc(add2)), toLocal = 2000000 msat)) val ful1 = UpdateFulfillHtlc(ByteVector32.Zeroes, add1.id, R) val spec3 = CommitmentSpec.reduce(spec2, Nil, ful1 :: Nil) - assert(spec3 === spec2.copy(htlcs = Set(OutgoingHtlc(add2)), toRemote = 2000000 msat)) + assert(spec3 == spec2.copy(htlcs = Set(OutgoingHtlc(add2)), toRemote = 2000000 msat)) val fail1 = UpdateFailHtlc(ByteVector32.Zeroes, add2.id, R) val spec4 = CommitmentSpec.reduce(spec3, Nil, fail1 :: Nil) - assert(spec4 === spec3.copy(htlcs = Set(), toLocal = 3000000 msat)) + assert(spec4 == spec3.copy(htlcs = Set(), toLocal = 3000000 msat)) } test("add, fulfill and fail htlcs from the receiver side") { @@ -53,26 +53,26 @@ class CommitmentSpecSpec extends AnyFunSuite { val add1 = UpdateAddHtlc(ByteVector32.Zeroes, 1, (2000 * 1000) msat, H, CltvExpiry(400), TestConstants.emptyOnionPacket) val spec1 = CommitmentSpec.reduce(spec, Nil, add1 :: Nil) - assert(spec1 === spec.copy(htlcs = Set(IncomingHtlc(add1)), toRemote = 3000 * 1000 msat)) + assert(spec1 == spec.copy(htlcs = Set(IncomingHtlc(add1)), toRemote = 3000 * 1000 msat)) val add2 = UpdateAddHtlc(ByteVector32.Zeroes, 2, (1000 * 1000) msat, H, CltvExpiry(400), TestConstants.emptyOnionPacket) val spec2 = CommitmentSpec.reduce(spec1, Nil, add2 :: Nil) - assert(spec2 === spec1.copy(htlcs = Set(IncomingHtlc(add1), IncomingHtlc(add2)), toRemote = (2000 * 1000) msat)) + assert(spec2 == spec1.copy(htlcs = Set(IncomingHtlc(add1), IncomingHtlc(add2)), toRemote = (2000 * 1000) msat)) val ful1 = UpdateFulfillHtlc(ByteVector32.Zeroes, add1.id, R) val spec3 = CommitmentSpec.reduce(spec2, ful1 :: Nil, Nil) - assert(spec3 === spec2.copy(htlcs = Set(IncomingHtlc(add2)), toLocal = (2000 * 1000) msat)) + assert(spec3 == spec2.copy(htlcs = Set(IncomingHtlc(add2)), toLocal = (2000 * 1000) msat)) val fail1 = UpdateFailHtlc(ByteVector32.Zeroes, add2.id, R) val spec4 = CommitmentSpec.reduce(spec3, fail1 :: Nil, Nil) - assert(spec4 === spec3.copy(htlcs = Set(), toRemote = (3000 * 1000) msat)) + assert(spec4 == spec3.copy(htlcs = Set(), toRemote = (3000 * 1000) msat)) } test("compute htlc tx feerate based on commitment format") { val spec = CommitmentSpec(htlcs = Set(), commitTxFeerate = FeeratePerKw(2500 sat), toLocal = (5000 * 1000) msat, toRemote = (2500 * 1000) msat) - assert(spec.htlcTxFeerate(Transactions.DefaultCommitmentFormat) === FeeratePerKw(2500 sat)) - assert(spec.htlcTxFeerate(Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) === FeeratePerKw(2500 sat)) - assert(spec.htlcTxFeerate(Transactions.ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) === FeeratePerKw(0 sat)) + assert(spec.htlcTxFeerate(Transactions.DefaultCommitmentFormat) == FeeratePerKw(2500 sat)) + assert(spec.htlcTxFeerate(Transactions.UnsafeLegacyAnchorOutputsCommitmentFormat) == FeeratePerKw(2500 sat)) + assert(spec.htlcTxFeerate(Transactions.ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) == FeeratePerKw(0 sat)) } def createHtlc(amount: MilliSatoshi): UpdateAddHtlc = { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/transactions/TestVectorsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/transactions/TestVectorsSpec.scala index 604680a45e..5761570969 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/transactions/TestVectorsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/transactions/TestVectorsSpec.scala @@ -125,7 +125,7 @@ trait TestVectorsSpec extends AnyFunSuite with Logging { val commitmentInput = Funding.makeFundingInputInfo(fundingTx.hash, 0, fundingAmount, Local.funding_pubkey, Remote.funding_pubkey) val obscured_tx_number = Transactions.obscuredCommitTxNumber(42, isInitiator = true, Local.payment_basepoint, Remote.payment_basepoint) - assert(obscured_tx_number === (0x2bb038521914L ^ 42L)) + assert(obscured_tx_number == (0x2bb038521914L ^ 42L)) logger.info(s"local_payment_basepoint: ${Local.payment_basepoint}") logger.info(s"remote_payment_basepoint: ${Remote.payment_basepoint}") @@ -227,7 +227,7 @@ trait TestVectorsSpec extends AnyFunSuite with Logging { } }) - assert(Transactions.getCommitTxNumber(commitTx.tx, isInitiator = true, Local.payment_basepoint, Remote.payment_basepoint) === Local.commitTxNumber) + assert(Transactions.getCommitTxNumber(commitTx.tx, isInitiator = true, Local.payment_basepoint, Remote.payment_basepoint) == Local.commitTxNumber) Transaction.correctlySpends(commitTx.tx, Seq(fundingTx), ScriptFlags.STANDARD_SCRIPT_VERIFY_FLAGS) logger.info(s"output commit_tx: ${commitTx.tx}") @@ -276,7 +276,7 @@ trait TestVectorsSpec extends AnyFunSuite with Logging { val check = (0 to 4).flatMap(i => tests(name).get(s"htlc_success_tx (htlc #$i)").toSeq ++ tests(name).get(s"htlc_timeout_tx (htlc #$i)").toSeq ).toSet.map((tx: String) => Transaction.read(tx)) - assert(htlcTxs.map(_.tx).toSet === check) + assert(htlcTxs.map(_.tx).toSet == check) } test("simple commitment tx with no HTLCs") { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/transactions/TransactionsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/transactions/TransactionsSpec.scala index ca5c56aab4..b124808a6c 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/transactions/TransactionsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/transactions/TransactionsSpec.scala @@ -72,8 +72,8 @@ class TransactionsSpec extends AnyFunSuite with Logging { parentTxId2 -> 4, parentTxId3 -> 5, ) - assert(expected === Scripts.csvTimeouts(tx)) - assert(BlockHeight(10) === Scripts.cltvTimeout(tx)) + assert(expected == Scripts.csvTimeouts(tx)) + assert(BlockHeight(10) == Scripts.cltvTimeout(tx)) } test("encode/decode sequence and lockTime (one example)") { @@ -106,7 +106,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { ) val spec = CommitmentSpec(htlcs, FeeratePerKw(5000 sat), toLocal = 0 msat, toRemote = 0 msat) val fee = commitTxFeeMsat(546 sat, spec, DefaultCommitmentFormat) - assert(fee === 5340000.msat) + assert(fee == 5340000.msat) } test("check pre-computed transaction weights") { @@ -200,7 +200,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { val commitTx = Transaction(version = 0, txIn = Nil, txOut = TxOut(anchorAmount, pubKeyScript) :: Nil, lockTime = 0) val Right(claimAnchorOutputTx) = makeClaimLocalAnchorOutputTx(commitTx, localFundingPriv.publicKey, BlockHeight(1105)) assert(claimAnchorOutputTx.tx.txOut.isEmpty) - assert(claimAnchorOutputTx.confirmBefore === BlockHeight(1105)) + assert(claimAnchorOutputTx.confirmBefore == BlockHeight(1105)) // we will always add at least one input and one output to be able to set our desired feerate // we use dummy signatures to compute the weight val p2wpkhWitness = ScriptWitness(Seq(Scripts.der(PlaceHolderSig), PlaceHolderPubKey.value)) @@ -209,7 +209,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { txOut = Seq(TxOut(1500 sat, Script.pay2wpkh(randomKey().publicKey))) )) val weight = Transaction.weight(addSigs(claimAnchorOutputTxWithFees, PlaceHolderSig).tx) - assert(weight === 717) + assert(weight == 717) assert(weight >= claimAnchorOutputMinWeight) } } @@ -223,26 +223,26 @@ class TransactionsSpec extends AnyFunSuite with Logging { { val toRemoteFundeeBelowDust = spec.copy(toRemote = belowDust) val outputs = makeCommitTxOutputs(localIsInitiator = true, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, toRemoteFundeeBelowDust, DefaultCommitmentFormat) - assert(outputs.map(_.commitmentOutput) === Seq(CommitmentOutput.ToLocal)) - assert(outputs.head.output.amount.toMilliSatoshi === toRemoteFundeeBelowDust.toLocal - commitFee) + assert(outputs.map(_.commitmentOutput) == Seq(CommitmentOutput.ToLocal)) + assert(outputs.head.output.amount.toMilliSatoshi == toRemoteFundeeBelowDust.toLocal - commitFee) } { val toLocalFunderBelowDust = spec.copy(toLocal = belowDustWithFee) val outputs = makeCommitTxOutputs(localIsInitiator = true, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, toLocalFunderBelowDust, DefaultCommitmentFormat) - assert(outputs.map(_.commitmentOutput) === Seq(CommitmentOutput.ToRemote)) - assert(outputs.head.output.amount.toMilliSatoshi === toLocalFunderBelowDust.toRemote) + assert(outputs.map(_.commitmentOutput) == Seq(CommitmentOutput.ToRemote)) + assert(outputs.head.output.amount.toMilliSatoshi == toLocalFunderBelowDust.toRemote) } { val toRemoteFunderBelowDust = spec.copy(toRemote = belowDustWithFee) val outputs = makeCommitTxOutputs(localIsInitiator = false, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, toRemoteFunderBelowDust, DefaultCommitmentFormat) - assert(outputs.map(_.commitmentOutput) === Seq(CommitmentOutput.ToLocal)) - assert(outputs.head.output.amount.toMilliSatoshi === toRemoteFunderBelowDust.toLocal) + assert(outputs.map(_.commitmentOutput) == Seq(CommitmentOutput.ToLocal)) + assert(outputs.head.output.amount.toMilliSatoshi == toRemoteFunderBelowDust.toLocal) } { val toLocalFundeeBelowDust = spec.copy(toLocal = belowDust) val outputs = makeCommitTxOutputs(localIsInitiator = false, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, toLocalFundeeBelowDust, DefaultCommitmentFormat) - assert(outputs.map(_.commitmentOutput) === Seq(CommitmentOutput.ToRemote)) - assert(outputs.head.output.amount.toMilliSatoshi === toLocalFundeeBelowDust.toRemote - commitFee) + assert(outputs.map(_.commitmentOutput) == Seq(CommitmentOutput.ToRemote)) + assert(outputs.head.output.amount.toMilliSatoshi == toLocalFundeeBelowDust.toRemote - commitFee) } { val allBelowDust = spec.copy(toLocal = belowDust, toRemote = belowDust) @@ -300,15 +300,15 @@ class TransactionsSpec extends AnyFunSuite with Logging { } val htlcTxs = makeHtlcTxs(commitTx.tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, spec.htlcTxFeerate(DefaultCommitmentFormat), outputs, DefaultCommitmentFormat) - assert(htlcTxs.length === 4) + assert(htlcTxs.length == 4) val confirmationTargets = htlcTxs.map(tx => tx.htlcId -> tx.confirmBefore.toLong).toMap - assert(confirmationTargets === Map(0 -> 300, 1 -> 310, 2 -> 295, 3 -> 300)) + assert(confirmationTargets == Map(0 -> 300, 1 -> 310, 2 -> 295, 3 -> 300)) val htlcSuccessTxs = htlcTxs.collect { case tx: HtlcSuccessTx => tx } val htlcTimeoutTxs = htlcTxs.collect { case tx: HtlcTimeoutTx => tx } assert(htlcTimeoutTxs.size == 2) // htlc1 and htlc3 - assert(htlcTimeoutTxs.map(_.htlcId).toSet === Set(0, 2)) + assert(htlcTimeoutTxs.map(_.htlcId).toSet == Set(0, 2)) assert(htlcSuccessTxs.size == 2) // htlc2 and htlc4 - assert(htlcSuccessTxs.map(_.htlcId).toSet === Set(1, 3)) + assert(htlcSuccessTxs.map(_.htlcId).toSet == Set(1, 3)) { // either party spends local->remote htlc output with htlc timeout tx @@ -327,7 +327,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { assert(checkSpendable(signedTx).isSuccess) // local can't claim delayed output of htlc3 timeout tx because it is below the dust limit val htlcDelayed1 = makeHtlcDelayedTx(htlcTimeoutTxs(0).tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localPaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(htlcDelayed1 === Left(OutputNotFound)) + assert(htlcDelayed1 == Left(OutputNotFound)) } { // remote spends local->remote htlc1/htlc3 output directly in case of success @@ -357,7 +357,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { assert(checkSpendable(signedTx).isSuccess) // local can't claim delayed output of htlc4 success tx because it is below the dust limit val htlcDelayed1 = makeHtlcDelayedTx(htlcSuccessTxs(0).tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(htlcDelayed1 === Left(AmountBelowDustLimit)) + assert(htlcDelayed1 == Left(AmountBelowDustLimit)) } { // local spends main delayed output @@ -395,7 +395,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { assert(checkSpendable(signed).isSuccess) // remote can't claim revoked output of htlc3's htlc-timeout tx because it is below the dust limit val claimHtlcDelayedPenaltyTx1 = makeClaimHtlcDelayedOutputPenaltyTxs(htlcTimeoutTxs(0).tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(claimHtlcDelayedPenaltyTx1 === Seq(Left(AmountBelowDustLimit))) + assert(claimHtlcDelayedPenaltyTx1 == Seq(Left(AmountBelowDustLimit))) } { // remote spends offered HTLC output with revocation key @@ -417,7 +417,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { assert(checkSpendable(signed).isSuccess) // remote can't claim revoked output of htlc4's htlc-success tx because it is below the dust limit val claimHtlcDelayedPenaltyTx1 = makeClaimHtlcDelayedOutputPenaltyTxs(htlcSuccessTxs(0).tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(claimHtlcDelayedPenaltyTx1 === Seq(Left(AmountBelowDustLimit))) + assert(claimHtlcDelayedPenaltyTx1 == Seq(Left(AmountBelowDustLimit))) } { // remote spends received HTLC output with revocation key @@ -441,39 +441,39 @@ class TransactionsSpec extends AnyFunSuite with Logging { { val outputs = makeCommitTxOutputs(localIsInitiator = true, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, spec, UnsafeLegacyAnchorOutputsCommitmentFormat) - assert(outputs.map(_.commitmentOutput).toSet === Set(CommitmentOutput.ToLocal, CommitmentOutput.ToRemote, CommitmentOutput.ToLocalAnchor, CommitmentOutput.ToRemoteAnchor)) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocalAnchor).get.output.amount === anchorAmount) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemoteAnchor).get.output.amount === anchorAmount) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocal).get.output.amount.toMilliSatoshi === spec.toLocal - commitFeeAndAnchorCost) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemote).get.output.amount.toMilliSatoshi === spec.toRemote) + assert(outputs.map(_.commitmentOutput).toSet == Set(CommitmentOutput.ToLocal, CommitmentOutput.ToRemote, CommitmentOutput.ToLocalAnchor, CommitmentOutput.ToRemoteAnchor)) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocalAnchor).get.output.amount == anchorAmount) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemoteAnchor).get.output.amount == anchorAmount) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocal).get.output.amount.toMilliSatoshi == spec.toLocal - commitFeeAndAnchorCost) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemote).get.output.amount.toMilliSatoshi == spec.toRemote) } { val toRemoteFundeeBelowDust = spec.copy(toRemote = belowDust) val outputs = makeCommitTxOutputs(localIsInitiator = true, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, toRemoteFundeeBelowDust, UnsafeLegacyAnchorOutputsCommitmentFormat) - assert(outputs.map(_.commitmentOutput).toSet === Set(CommitmentOutput.ToLocal, CommitmentOutput.ToLocalAnchor)) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocalAnchor).get.output.amount === anchorAmount) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocal).get.output.amount.toMilliSatoshi === spec.toLocal - commitFeeAndAnchorCost) + assert(outputs.map(_.commitmentOutput).toSet == Set(CommitmentOutput.ToLocal, CommitmentOutput.ToLocalAnchor)) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocalAnchor).get.output.amount == anchorAmount) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocal).get.output.amount.toMilliSatoshi == spec.toLocal - commitFeeAndAnchorCost) } { val toLocalFunderBelowDust = spec.copy(toLocal = belowDustWithFeeAndAnchors) val outputs = makeCommitTxOutputs(localIsInitiator = true, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, toLocalFunderBelowDust, UnsafeLegacyAnchorOutputsCommitmentFormat) - assert(outputs.map(_.commitmentOutput).toSet === Set(CommitmentOutput.ToRemote, CommitmentOutput.ToRemoteAnchor)) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemoteAnchor).get.output.amount === anchorAmount) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemote).get.output.amount.toMilliSatoshi === spec.toRemote) + assert(outputs.map(_.commitmentOutput).toSet == Set(CommitmentOutput.ToRemote, CommitmentOutput.ToRemoteAnchor)) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemoteAnchor).get.output.amount == anchorAmount) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemote).get.output.amount.toMilliSatoshi == spec.toRemote) } { val toRemoteFunderBelowDust = spec.copy(toRemote = belowDustWithFeeAndAnchors) val outputs = makeCommitTxOutputs(localIsInitiator = false, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, toRemoteFunderBelowDust, UnsafeLegacyAnchorOutputsCommitmentFormat) - assert(outputs.map(_.commitmentOutput).toSet === Set(CommitmentOutput.ToLocal, CommitmentOutput.ToLocalAnchor)) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocalAnchor).get.output.amount === anchorAmount) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocal).get.output.amount.toMilliSatoshi === spec.toLocal) + assert(outputs.map(_.commitmentOutput).toSet == Set(CommitmentOutput.ToLocal, CommitmentOutput.ToLocalAnchor)) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocalAnchor).get.output.amount == anchorAmount) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToLocal).get.output.amount.toMilliSatoshi == spec.toLocal) } { val toLocalFundeeBelowDust = spec.copy(toLocal = belowDust) val outputs = makeCommitTxOutputs(localIsInitiator = false, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, toLocalFundeeBelowDust, UnsafeLegacyAnchorOutputsCommitmentFormat) - assert(outputs.map(_.commitmentOutput).toSet === Set(CommitmentOutput.ToRemote, CommitmentOutput.ToRemoteAnchor)) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemoteAnchor).get.output.amount === anchorAmount) - assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemote).get.output.amount.toMilliSatoshi === spec.toRemote - commitFeeAndAnchorCost) + assert(outputs.map(_.commitmentOutput).toSet == Set(CommitmentOutput.ToRemote, CommitmentOutput.ToRemoteAnchor)) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemoteAnchor).get.output.amount == anchorAmount) + assert(outputs.find(_.commitmentOutput == CommitmentOutput.ToRemote).get.output.amount.toMilliSatoshi == spec.toRemote - commitFeeAndAnchorCost) } { val allBelowDust = spec.copy(toLocal = belowDust, toRemote = belowDust) @@ -528,30 +528,30 @@ class TransactionsSpec extends AnyFunSuite with Logging { val commitTx = Transactions.addSigs(txInfo, localFundingPriv.publicKey, remoteFundingPriv.publicKey, localSig, remoteSig) val htlcTxs = makeHtlcTxs(commitTx.tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, spec.htlcTxFeerate(UnsafeLegacyAnchorOutputsCommitmentFormat), outputs, UnsafeLegacyAnchorOutputsCommitmentFormat) - assert(htlcTxs.length === 5) + assert(htlcTxs.length == 5) val confirmationTargets = htlcTxs.map(tx => tx.htlcId -> tx.confirmBefore.toLong).toMap - assert(confirmationTargets === Map(0 -> 300, 1 -> 310, 2 -> 310, 3 -> 295, 4 -> 300)) + assert(confirmationTargets == Map(0 -> 300, 1 -> 310, 2 -> 310, 3 -> 295, 4 -> 300)) val htlcSuccessTxs = htlcTxs.collect { case tx: HtlcSuccessTx => tx } val htlcTimeoutTxs = htlcTxs.collect { case tx: HtlcTimeoutTx => tx } assert(htlcTimeoutTxs.size == 2) // htlc1 and htlc3 - assert(htlcTimeoutTxs.map(_.htlcId).toSet === Set(0, 3)) + assert(htlcTimeoutTxs.map(_.htlcId).toSet == Set(0, 3)) assert(htlcSuccessTxs.size == 3) // htlc2a, htlc2b and htlc4 - assert(htlcSuccessTxs.map(_.htlcId).toSet === Set(1, 2, 4)) + assert(htlcSuccessTxs.map(_.htlcId).toSet == Set(1, 2, 4)) val zeroFeeOutputs = makeCommitTxOutputs(localIsInitiator = true, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, remotePaymentPriv.publicKey, localHtlcPriv.publicKey, remoteHtlcPriv.publicKey, localFundingPriv.publicKey, remoteFundingPriv.publicKey, spec, ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) val zeroFeeCommitTx = makeCommitTx(commitInput, commitTxNumber, localPaymentPriv.publicKey, remotePaymentPriv.publicKey, localIsInitiator = true, zeroFeeOutputs) val zeroFeeHtlcTxs = makeHtlcTxs(zeroFeeCommitTx.tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, spec.htlcTxFeerate(ZeroFeeHtlcTxAnchorOutputsCommitmentFormat), zeroFeeOutputs, ZeroFeeHtlcTxAnchorOutputsCommitmentFormat) - assert(zeroFeeHtlcTxs.length === 7) + assert(zeroFeeHtlcTxs.length == 7) val zeroFeeConfirmationTargets = zeroFeeHtlcTxs.map(tx => tx.htlcId -> tx.confirmBefore.toLong).toMap - assert(zeroFeeConfirmationTargets === Map(0 -> 300, 1 -> 310, 2 -> 310, 3 -> 295, 4 -> 300, 7 -> 300, 8 -> 302)) + assert(zeroFeeConfirmationTargets == Map(0 -> 300, 1 -> 310, 2 -> 310, 3 -> 295, 4 -> 300, 7 -> 300, 8 -> 302)) val zeroFeeHtlcSuccessTxs = zeroFeeHtlcTxs.collect { case tx: HtlcSuccessTx => tx } val zeroFeeHtlcTimeoutTxs = zeroFeeHtlcTxs.collect { case tx: HtlcTimeoutTx => tx } - zeroFeeHtlcSuccessTxs.foreach(tx => assert(tx.fee === 0.sat)) - zeroFeeHtlcTimeoutTxs.foreach(tx => assert(tx.fee === 0.sat)) + zeroFeeHtlcSuccessTxs.foreach(tx => assert(tx.fee == 0.sat)) + zeroFeeHtlcTimeoutTxs.foreach(tx => assert(tx.fee == 0.sat)) assert(zeroFeeHtlcTimeoutTxs.size == 3) // htlc1, htlc3 and htlc7 - assert(zeroFeeHtlcTimeoutTxs.map(_.htlcId).toSet === Set(0, 3, 7)) + assert(zeroFeeHtlcTimeoutTxs.map(_.htlcId).toSet == Set(0, 3, 7)) assert(zeroFeeHtlcSuccessTxs.size == 4) // htlc2a, htlc2b, htlc4 and htlc8 - assert(zeroFeeHtlcSuccessTxs.map(_.htlcId).toSet === Set(1, 2, 4, 8)) + assert(zeroFeeHtlcSuccessTxs.map(_.htlcId).toSet == Set(1, 2, 4, 8)) (commitTx, outputs, htlcTimeoutTxs, htlcSuccessTxs) } @@ -566,7 +566,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { { // remote cannot spend main output with default commitment format val Left(failure) = makeClaimP2WPKHOutputTx(commitTx.tx, localDustLimit, remotePaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(failure === OutputNotFound) + assert(failure == OutputNotFound) } { // remote spends main delayed output @@ -622,7 +622,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { assert(checkSpendable(signedTx).isSuccess) // local can't claim delayed output of htlc3 timeout tx because it is below the dust limit val htlcDelayed1 = makeHtlcDelayedTx(htlcTimeoutTxs(0).tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localPaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(htlcDelayed1 === Left(OutputNotFound)) + assert(htlcDelayed1 == Left(OutputNotFound)) } { // local spends offered htlc with HTLC-success tx @@ -654,7 +654,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { } // local can't claim delayed output of htlc4 success tx because it is below the dust limit val claimHtlcDelayed1 = makeClaimLocalDelayedOutputTx(htlcSuccessTxs(0).tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(claimHtlcDelayed1 === Left(AmountBelowDustLimit)) + assert(claimHtlcDelayed1 == Left(AmountBelowDustLimit)) } { // remote spends local->remote htlc outputs directly in case of success @@ -673,7 +673,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { assert(checkSpendable(signed).isSuccess) // remote can't claim revoked output of htlc3's htlc-timeout tx because it is below the dust limit val claimHtlcDelayedPenaltyTx1 = makeClaimHtlcDelayedOutputPenaltyTxs(htlcTimeoutTxs(0).tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(claimHtlcDelayedPenaltyTx1 === Seq(Left(AmountBelowDustLimit))) + assert(claimHtlcDelayedPenaltyTx1 == Seq(Left(AmountBelowDustLimit))) } { // remote spends remote->local htlc output directly in case of timeout @@ -695,7 +695,7 @@ class TransactionsSpec extends AnyFunSuite with Logging { } // remote can't claim revoked output of htlc4's htlc-success tx because it is below the dust limit val claimHtlcDelayedPenaltyTx1 = makeClaimHtlcDelayedOutputPenaltyTxs(htlcSuccessTxs(0).tx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(claimHtlcDelayedPenaltyTx1 === Seq(Left(AmountBelowDustLimit))) + assert(claimHtlcDelayedPenaltyTx1 == Seq(Left(AmountBelowDustLimit))) } { // remote spends all htlc txs aggregated in a single tx @@ -703,13 +703,13 @@ class TransactionsSpec extends AnyFunSuite with Logging { val txOut = htlcTimeoutTxs.flatMap(_.tx.txOut) ++ htlcSuccessTxs.flatMap(_.tx.txOut) val aggregatedHtlcTx = Transaction(2, txIn, txOut, 0) val claimHtlcDelayedPenaltyTxs = makeClaimHtlcDelayedOutputPenaltyTxs(aggregatedHtlcTx, localDustLimit, localRevocationPriv.publicKey, toLocalDelay, localDelayedPaymentPriv.publicKey, finalPubKeyScript, feeratePerKw) - assert(claimHtlcDelayedPenaltyTxs.size === 5) + assert(claimHtlcDelayedPenaltyTxs.size == 5) val skipped = claimHtlcDelayedPenaltyTxs.collect { case Left(reason) => reason } - assert(skipped.size === 2) - assert(skipped.toSet === Set(AmountBelowDustLimit)) + assert(skipped.size == 2) + assert(skipped.toSet == Set(AmountBelowDustLimit)) val claimed = claimHtlcDelayedPenaltyTxs.collect { case Right(tx) => tx } - assert(claimed.size === 3) - assert(claimed.map(_.input.outPoint).toSet.size === 3) + assert(claimed.size == 3) + assert(claimed.map(_.input.outPoint).toSet.size == 3) } { // remote spends offered htlc output with revocation key @@ -795,10 +795,10 @@ class TransactionsSpec extends AnyFunSuite with Logging { } // htlc3 and htlc4 are completely identical, their relative order can't be enforced. - assert(htlcTxs.length === 5) + assert(htlcTxs.length == 5) htlcTxs.foreach(tx => assert(tx.isInstanceOf[HtlcTimeoutTx])) val htlcIds = htlcTxs.sortBy(_.input.outPoint.index).map(_.htlcId) - assert(htlcIds === Seq(1, 2, 3, 4, 5) || htlcIds === Seq(1, 2, 4, 3, 5)) + assert(htlcIds == Seq(1, 2, 3, 4, 5) || htlcIds == Seq(1, 2, 4, 3, 5)) assert(htlcOut2.publicKeyScript.toHex < htlcOut3.publicKeyScript.toHex) assert(outputs.find(_.commitmentOutput == OutHtlc(OutgoingHtlc(htlc2))).map(_.output.publicKeyScript).contains(htlcOut2.publicKeyScript)) @@ -816,23 +816,23 @@ class TransactionsSpec extends AnyFunSuite with Logging { // Different amounts, both outputs untrimmed, local is funder: val spec = CommitmentSpec(Set.empty, feeratePerKw, 150_000_000 msat, 250_000_000 msat) val closingTx = makeClosingTx(commitInput, localPubKeyScript, remotePubKeyScript, localIsInitiator = true, localDustLimit, 1000 sat, spec) - assert(closingTx.tx.txOut.length === 2) + assert(closingTx.tx.txOut.length == 2) assert(closingTx.toLocalOutput !== None) val toLocal = closingTx.toLocalOutput.get - assert(toLocal.publicKeyScript === localPubKeyScript) - assert(toLocal.amount === 149_000.sat) // funder pays the fee + assert(toLocal.publicKeyScript == localPubKeyScript) + assert(toLocal.amount == 149_000.sat) // funder pays the fee val toRemoteIndex = (toLocal.index + 1) % 2 - assert(closingTx.tx.txOut(toRemoteIndex.toInt).amount === 250_000.sat) + assert(closingTx.tx.txOut(toRemoteIndex.toInt).amount == 250_000.sat) } { // Same amounts, both outputs untrimmed, local is fundee: val spec = CommitmentSpec(Set.empty, feeratePerKw, 150_000_000 msat, 150_000_000 msat) val closingTx = makeClosingTx(commitInput, localPubKeyScript, remotePubKeyScript, localIsInitiator = false, localDustLimit, 1000 sat, spec) - assert(closingTx.tx.txOut.length === 2) + assert(closingTx.tx.txOut.length == 2) assert(closingTx.toLocalOutput !== None) val toLocal = closingTx.toLocalOutput.get - assert(toLocal.publicKeyScript === localPubKeyScript) - assert(toLocal.amount === 150_000.sat) + assert(toLocal.publicKeyScript == localPubKeyScript) + assert(toLocal.amount == 150_000.sat) val toRemoteIndex = (toLocal.index + 1) % 2 assert(closingTx.tx.txOut(toRemoteIndex.toInt).amount < 150_000.sat) } @@ -840,26 +840,26 @@ class TransactionsSpec extends AnyFunSuite with Logging { // Their output is trimmed: val spec = CommitmentSpec(Set.empty, feeratePerKw, 150_000_000 msat, 1_000 msat) val closingTx = makeClosingTx(commitInput, localPubKeyScript, remotePubKeyScript, localIsInitiator = false, localDustLimit, 1000 sat, spec) - assert(closingTx.tx.txOut.length === 1) + assert(closingTx.tx.txOut.length == 1) assert(closingTx.toLocalOutput !== None) val toLocal = closingTx.toLocalOutput.get - assert(toLocal.publicKeyScript === localPubKeyScript) - assert(toLocal.amount === 150_000.sat) - assert(toLocal.index === 0) + assert(toLocal.publicKeyScript == localPubKeyScript) + assert(toLocal.amount == 150_000.sat) + assert(toLocal.index == 0) } { // Our output is trimmed: val spec = CommitmentSpec(Set.empty, feeratePerKw, 50_000 msat, 150_000_000 msat) val closingTx = makeClosingTx(commitInput, localPubKeyScript, remotePubKeyScript, localIsInitiator = true, localDustLimit, 1000 sat, spec) - assert(closingTx.tx.txOut.length === 1) - assert(closingTx.toLocalOutput === None) + assert(closingTx.tx.txOut.length == 1) + assert(closingTx.toLocalOutput == None) } { // Both outputs are trimmed: val spec = CommitmentSpec(Set.empty, feeratePerKw, 50_000 msat, 10_000 msat) val closingTx = makeClosingTx(commitInput, localPubKeyScript, remotePubKeyScript, localIsInitiator = true, localDustLimit, 1000 sat, spec) assert(closingTx.tx.txOut.isEmpty) - assert(closingTx.toLocalOutput === None) + assert(closingTx.toLocalOutput == None) } } @@ -900,11 +900,11 @@ class TransactionsSpec extends AnyFunSuite with Logging { TestVector(name, CommitmentSpec(htlcs, FeeratePerKw(feerate_per_kw.toLong.sat), MilliSatoshi(to_local_msat.toLong), MilliSatoshi(to_remote_msat.toLong)), Satoshi(fee.toLong)) }).toSeq - assert(tests.size === 30, "there were 15 tests at b201efe0546120c14bf154ce5f4e18da7243fe7a") // simple non-reg to make sure we are not missing tests + assert(tests.size == 30, "there were 15 tests at b201efe0546120c14bf154ce5f4e18da7243fe7a") // simple non-reg to make sure we are not missing tests tests.foreach(test => { logger.info(s"running BOLT 3 test: '${test.name}'") val fee = commitTxTotalCost(dustLimit, test.spec, DefaultCommitmentFormat) - assert(fee === test.expectedFee) + assert(fee == test.expectedFee) }) } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/CommandCodecsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/CommandCodecsSpec.scala index d7fcaefc78..592dc1d54a 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/CommandCodecsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/CommandCodecsSpec.scala @@ -44,7 +44,7 @@ class CommandCodecsSpec extends AnyFunSuite { msg => val encoded = CommandCodecs.cmdCodec.encode(msg).require val decoded = CommandCodecs.cmdCodec.decode(encoded).require - assert(msg === decoded.value) + assert(msg == decoded.value) } } @@ -57,14 +57,14 @@ class CommandCodecsSpec extends AnyFunSuite { (("id" | int64) :: ("r" | bytes32) :: ("commit" | provide(false))) - assert(CommandCodecs.cmdFulfillCodec.decode(legacyCmdFulfillCodec.encode(42 :: data32 :: true :: HNil).require).require === + assert(CommandCodecs.cmdFulfillCodec.decode(legacyCmdFulfillCodec.encode(42 :: data32 :: true :: HNil).require).require == DecodeResult(CMD_FULFILL_HTLC(42, data32, commit = false, None), BitVector.empty)) val legacyCmdFailCodec = (("id" | int64) :: ("reason" | either(bool, varsizebinarydata, failureMessageCodec)) :: ("commit" | provide(false))) - assert(CommandCodecs.cmdFailCodec.decode(legacyCmdFailCodec.encode(42 :: Left(data123) :: true :: HNil).require).require === + assert(CommandCodecs.cmdFailCodec.decode(legacyCmdFailCodec.encode(42 :: Left(data123) :: true :: HNil).require).require == DecodeResult(CMD_FAIL_HTLC(42, Left(data123), commit = false, None), BitVector.empty)) val legacyCmdFailMalformedCodec = @@ -72,7 +72,7 @@ class CommandCodecsSpec extends AnyFunSuite { ("onionHash" | bytes32) :: ("failureCode" | uint16) :: ("commit" | provide(false))) - assert(CommandCodecs.cmdFailMalformedCodec.decode(legacyCmdFailMalformedCodec.encode(42 :: data32 :: 456 :: true :: HNil).require).require === + assert(CommandCodecs.cmdFailMalformedCodec.decode(legacyCmdFailMalformedCodec.encode(42 :: data32 :: 456 :: true :: HNil).require).require == DecodeResult(CMD_FAIL_MALFORMED_HTLC(42, data32, 456, commit = false, None), BitVector.empty)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/ChannelCodecsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/ChannelCodecsSpec.scala index 1112ea9903..fe3e7663f7 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/ChannelCodecsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/ChannelCodecsSpec.scala @@ -71,13 +71,13 @@ class ChannelCodecsSpec extends AnyFunSuite { .htlcTxsAndRemoteSigs .map(data => Scripts.der(data.remoteSig)) - assert(ref === sigs) + assert(ref == sigs) } test("nonreg for channel flags codec") { // make sure that we correctly decode data encoded with the previous standard 'byte' codec - assert(CommonCodecs.channelflags.decode(byte.encode(0).require).require === DecodeResult(ChannelFlags(announceChannel = false), BitVector.empty)) - assert(CommonCodecs.channelflags.decode(byte.encode(1).require).require === DecodeResult(ChannelFlags(announceChannel = true), BitVector.empty)) + assert(CommonCodecs.channelflags.decode(byte.encode(0).require).require == DecodeResult(ChannelFlags(announceChannel = false), BitVector.empty)) + assert(CommonCodecs.channelflags.decode(byte.encode(1).require).require == DecodeResult(ChannelFlags(announceChannel = true), BitVector.empty)) } test("backward compatibility DATA_WAIT_FOR_FUNDING_CONFIRMED_COMPAT_01_Codec") { @@ -87,7 +87,7 @@ class ChannelCodecsSpec extends AnyFunSuite { assert(bin_old.startsWith(hex"000001")) // let's decode the old data (this will use the old codec that provides default values for new fields) val data_new = channelDataCodec.decode(bin_old.toBitVector).require.value - assert(data_new.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].fundingTx === None) + assert(data_new.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].fundingTx == None) assert(TimestampSecond.now().toLong - data_new.asInstanceOf[DATA_WAIT_FOR_FUNDING_CONFIRMED].waitingSince.toLong < 3600) // we just set this to current time // and re-encode it with the new codec val bin_new = ByteVector(channelDataCodec.encode(data_new).require.toByteVector.toArray) @@ -96,7 +96,7 @@ class ChannelCodecsSpec extends AnyFunSuite { // now let's decode it again val data_new2 = channelDataCodec.decode(bin_new.toBitVector).require.value // data should match perfectly - assert(data_new === data_new2) + assert(data_new == data_new2) } test("backward compatibility DATA_NORMAL_COMPAT_03_Codec (roundtrip)") { @@ -127,7 +127,7 @@ class ChannelCodecsSpec extends AnyFunSuite { assert(newbin.startsWith(hex"030007")) // make sure that round-trip yields the same data val newnormal = channelDataCodec.decode(newbin.bits).require.value - assert(newnormal === oldnormal) + assert(newnormal == oldnormal) } } @@ -152,8 +152,8 @@ class ChannelCodecsSpec extends AnyFunSuite { // finally we check that the actual data is the same as before (we just remove the new json field) val oldjson = Serialization.write(oldnormal)(JsonSerializers.formats) val newjson = Serialization.write(newnormal)(JsonSerializers.formats) - assert(oldjson === refjson) - assert(newjson === refjson) + assert(oldjson == refjson) + assert(newjson == refjson) } } @@ -178,38 +178,38 @@ class ChannelCodecsSpec extends AnyFunSuite { assert(newBin.startsWith(hex"0300")) // make sure that round-trip yields the same data val decoded2 = channelDataCodec.decode(newBin.bits).require.value - assert(decoded1 === decoded2) + assert(decoded1 == decoded2) }) val negotiating = channelDataCodec.decode(dataNegotiating.bits).require.value.asInstanceOf[DATA_NEGOTIATING] assert(negotiating.bestUnpublishedClosingTx_opt.nonEmpty) - negotiating.bestUnpublishedClosingTx_opt.foreach(tx => assert(tx.toLocalOutput === None)) + negotiating.bestUnpublishedClosingTx_opt.foreach(tx => assert(tx.toLocalOutput == None)) assert(negotiating.closingTxProposed.flatten.nonEmpty) - negotiating.closingTxProposed.flatten.foreach(tx => assert(tx.unsignedTx.toLocalOutput === None)) + negotiating.closingTxProposed.flatten.foreach(tx => assert(tx.unsignedTx.toLocalOutput == None)) val normal = channelDataCodec.decode(dataNormal.bits).require.value.asInstanceOf[DATA_NORMAL] assert(normal.commitments.localCommit.htlcTxsAndRemoteSigs.nonEmpty) - normal.commitments.localCommit.htlcTxsAndRemoteSigs.foreach(tx => assert(tx.htlcTx.htlcId === 0)) + normal.commitments.localCommit.htlcTxsAndRemoteSigs.foreach(tx => assert(tx.htlcTx.htlcId == 0)) val closingLocal = channelDataCodec.decode(dataClosingLocal.bits).require.value.asInstanceOf[DATA_CLOSING] assert(closingLocal.localCommitPublished.nonEmpty) - assert(closingLocal.localCommitPublished.get.commitTx.txOut.size === 6) - assert(closingLocal.localCommitPublished.get.htlcTxs.size === 4) - assert(closingLocal.localCommitPublished.get.claimHtlcDelayedTxs.size === 4) + assert(closingLocal.localCommitPublished.get.commitTx.txOut.size == 6) + assert(closingLocal.localCommitPublished.get.htlcTxs.size == 4) + assert(closingLocal.localCommitPublished.get.claimHtlcDelayedTxs.size == 4) assert(closingLocal.localCommitPublished.get.irrevocablySpent.isEmpty) val closingRemote = channelDataCodec.decode(dataClosingRemote.bits).require.value.asInstanceOf[DATA_CLOSING] assert(closingRemote.remoteCommitPublished.nonEmpty) - assert(closingRemote.remoteCommitPublished.get.commitTx.txOut.size === 7) - assert(closingRemote.remoteCommitPublished.get.commitTx.txOut.count(_.amount === AnchorOutputsCommitmentFormat.anchorAmount) === 2) - assert(closingRemote.remoteCommitPublished.get.claimHtlcTxs.size === 3) + assert(closingRemote.remoteCommitPublished.get.commitTx.txOut.size == 7) + assert(closingRemote.remoteCommitPublished.get.commitTx.txOut.count(_.amount == AnchorOutputsCommitmentFormat.anchorAmount) == 2) + assert(closingRemote.remoteCommitPublished.get.claimHtlcTxs.size == 3) assert(closingRemote.remoteCommitPublished.get.irrevocablySpent.isEmpty) val closingRevoked = channelDataCodec.decode(dataClosingRevoked.bits).require.value.asInstanceOf[DATA_CLOSING] - assert(closingRevoked.revokedCommitPublished.size === 1) - assert(closingRevoked.revokedCommitPublished.head.commitTx.txOut.size === 6) - assert(closingRevoked.revokedCommitPublished.head.htlcPenaltyTxs.size === 4) - assert(closingRevoked.revokedCommitPublished.head.claimHtlcDelayedPenaltyTxs.size === 2) + assert(closingRevoked.revokedCommitPublished.size == 1) + assert(closingRevoked.revokedCommitPublished.head.commitTx.txOut.size == 6) + assert(closingRevoked.revokedCommitPublished.head.htlcPenaltyTxs.size == 4) + assert(closingRevoked.revokedCommitPublished.head.claimHtlcDelayedPenaltyTxs.size == 2) assert(closingRevoked.revokedCommitPublished.head.irrevocablySpent.isEmpty) } @@ -236,7 +236,7 @@ class ChannelCodecsSpec extends AnyFunSuite { val newbin = channelDataCodec.encode(oldnormal).require.bytes // make sure that round-trip yields the same data val newnormal = channelDataCodec.decode(newbin.bits).require.value - assert(newnormal === oldnormal) + assert(newnormal == oldnormal) // make sure that we have stripped sigs from the transactions assert(newnormal.commitments.localCommit.commitTxAndRemoteSig.commitTx.tx.txIn.forall(_.witness.stack.isEmpty)) assert(newnormal.commitments.localCommit.htlcTxsAndRemoteSigs.forall(_.htlcTx.tx.txIn.forall(_.witness.stack.isEmpty))) diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version0/ChannelCodecs0Spec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version0/ChannelCodecs0Spec.scala index 82c086eed4..24fe9f5e89 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version0/ChannelCodecs0Spec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version0/ChannelCodecs0Spec.scala @@ -22,21 +22,21 @@ class ChannelCodecs0Spec extends AnyFunSuite { val current03 = hex"010000000103d5c030835d6a6248b2d1d4cac60813838011b995a66b6f78dcc9fb8b5c40c3f3" val current04 = hex"010000000303d5c030835d6a6248b2d1d4cac60813838011b995a66b6f78dcc9fb8b5c40c3f3" - assert(codec.decode(legacy02.bits) === Attempt.successful(DecodeResult(ChannelVersion.ZEROES, legacy02.bits))) - assert(codec.decode(legacy03.bits) === Attempt.successful(DecodeResult(ChannelVersion.ZEROES, legacy03.bits))) - assert(codec.decode(current02.bits) === Attempt.successful(DecodeResult(ChannelVersion.STANDARD, current02.drop(5).bits))) - assert(codec.decode(current03.bits) === Attempt.successful(DecodeResult(ChannelVersion.STANDARD, current03.drop(5).bits))) - assert(codec.decode(current04.bits) === Attempt.successful(DecodeResult(ChannelVersion.STATIC_REMOTEKEY, current04.drop(5).bits))) - - assert(codec.encode(ChannelVersion.STANDARD) === Attempt.successful(hex"0100000001".bits)) - assert(codec.encode(ChannelVersion.STATIC_REMOTEKEY) === Attempt.successful(hex"0100000003".bits)) + assert(codec.decode(legacy02.bits) == Attempt.successful(DecodeResult(ChannelVersion.ZEROES, legacy02.bits))) + assert(codec.decode(legacy03.bits) == Attempt.successful(DecodeResult(ChannelVersion.ZEROES, legacy03.bits))) + assert(codec.decode(current02.bits) == Attempt.successful(DecodeResult(ChannelVersion.STANDARD, current02.drop(5).bits))) + assert(codec.decode(current03.bits) == Attempt.successful(DecodeResult(ChannelVersion.STANDARD, current03.drop(5).bits))) + assert(codec.decode(current04.bits) == Attempt.successful(DecodeResult(ChannelVersion.STATIC_REMOTEKEY, current04.drop(5).bits))) + + assert(codec.encode(ChannelVersion.STANDARD) == Attempt.successful(hex"0100000001".bits)) + assert(codec.encode(ChannelVersion.STATIC_REMOTEKEY) == Attempt.successful(hex"0100000003".bits)) } test("backward compatibility local params with global features") { // Backwards-compatibility: decode localparams with global features. val withGlobalFeatures = hex"033b1d42aa7c6a1a3502cbcfe4d2787e9f96237465cd1ba675f50cadf0be17092500010000002a0000000026cb536b00000000568a2768000000004f182e8d0000000040dd1d3d10e3040d00422f82d368b09056d1dcb2d67c4e8cae516abbbc8932f2b7d8f93b3be8e8cc6b64bb164563d567189bad0e07e24e821795aaef2dcbb9e5c1ad579961680202b38de5dd5426c524c7523b1fcdcf8c600d47f4b96a6dd48516b8e0006e81c83464b2800db0f3f63ceeb23a81511d159bae9ad07d10c0d144ba2da6f0cff30e7154eb48c908e9000101000001044500" val withGlobalFeaturesDecoded = localParamsCodec(ChannelVersion.STANDARD).decode(withGlobalFeatures.bits).require.value - assert(withGlobalFeaturesDecoded.initFeatures.toByteVector === hex"0a8a") + assert(withGlobalFeaturesDecoded.initFeatures.toByteVector == hex"0a8a") } test("backward compatibility of htlc codec") { @@ -69,8 +69,8 @@ class ChannelCodecs0Spec extends AnyFunSuite { assert(r1 == remaining) assert(r2 == remaining) - assert(codec.encode(h1).require.bytes === encodedHtlc1) - assert(codec.encode(h2).require.bytes === encodedHtlc2) + assert(codec.encode(h1).require.bytes == encodedHtlc1) + assert(codec.encode(h2).require.bytes == encodedHtlc2) } test("tell channel_update length") { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version1/ChannelCodecs1Spec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version1/ChannelCodecs1Spec.scala index 6add1bdf43..545da0fdc5 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version1/ChannelCodecs1Spec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version1/ChannelCodecs1Spec.scala @@ -25,14 +25,14 @@ class ChannelCodecs1Spec extends AnyFunSuite { val keyPath = KeyPath(Seq(0L, 0L, 0L, 0L)) val encoded = keyPathCodec.encode(keyPath).require val decoded = keyPathCodec.decode(encoded).require - assert(keyPath === decoded.value) + assert(keyPath == decoded.value) } test("encode/decode key paths (all 1s)") { val keyPath = KeyPath(Seq(0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL)) val encoded = keyPathCodec.encode(keyPath).require val decoded = keyPathCodec.decode(encoded).require - assert(keyPath === decoded.value) + assert(keyPath == decoded.value) } test("encode/decode channel version") { @@ -41,21 +41,21 @@ class ChannelCodecs1Spec extends AnyFunSuite { val current04 = hex"0000000303d5c030835d6a6248b2d1d4cac60813838011b995a66b6f78dcc9fb8b5c40c3f3" val current05 = hex"0000000703d5c030835d6a6248b2d1d4cac60813838011b995a66b6f78dcc9fb8b5c40c3f3" - assert(channelVersionCodec.decode(current02.bits) === Attempt.successful(DecodeResult(ChannelVersion.STANDARD, current02.drop(4).bits))) - assert(channelVersionCodec.decode(current03.bits) === Attempt.successful(DecodeResult(ChannelVersion.STANDARD, current03.drop(4).bits))) - assert(channelVersionCodec.decode(current04.bits) === Attempt.successful(DecodeResult(ChannelVersion.STATIC_REMOTEKEY, current04.drop(4).bits))) - assert(channelVersionCodec.decode(current05.bits) === Attempt.successful(DecodeResult(ChannelVersion.ANCHOR_OUTPUTS, current05.drop(4).bits))) + assert(channelVersionCodec.decode(current02.bits) == Attempt.successful(DecodeResult(ChannelVersion.STANDARD, current02.drop(4).bits))) + assert(channelVersionCodec.decode(current03.bits) == Attempt.successful(DecodeResult(ChannelVersion.STANDARD, current03.drop(4).bits))) + assert(channelVersionCodec.decode(current04.bits) == Attempt.successful(DecodeResult(ChannelVersion.STATIC_REMOTEKEY, current04.drop(4).bits))) + assert(channelVersionCodec.decode(current05.bits) == Attempt.successful(DecodeResult(ChannelVersion.ANCHOR_OUTPUTS, current05.drop(4).bits))) - assert(channelVersionCodec.encode(ChannelVersion.STANDARD) === Attempt.successful(hex"00000001".bits)) - assert(channelVersionCodec.encode(ChannelVersion.STATIC_REMOTEKEY) === Attempt.successful(hex"00000003".bits)) - assert(channelVersionCodec.encode(ChannelVersion.ANCHOR_OUTPUTS) === Attempt.successful(hex"00000007".bits)) + assert(channelVersionCodec.encode(ChannelVersion.STANDARD) == Attempt.successful(hex"00000001".bits)) + assert(channelVersionCodec.encode(ChannelVersion.STATIC_REMOTEKEY) == Attempt.successful(hex"00000003".bits)) + assert(channelVersionCodec.encode(ChannelVersion.ANCHOR_OUTPUTS) == Attempt.successful(hex"00000007".bits)) } test("encode/decode local params") { def roundtrip(localParams: LocalParams, codec: Codec[LocalParams]) = { val encoded = codec.encode(localParams).require val decoded = codec.decode(encoded).require - assert(localParams === decoded.value) + assert(localParams == decoded.value) } val o = LocalParams( @@ -96,12 +96,12 @@ class ChannelCodecs1Spec extends AnyFunSuite { shutdownScript = None) val encoded = remoteParamsCodec.encode(o).require val decoded = remoteParamsCodec.decodeValue(encoded).require - assert(o === decoded) + assert(o == decoded) // Backwards-compatibility: decode remote params with global features. val withGlobalFeatures = hex"03c70c3b813815a8b79f41622b6f2c343fa24d94fb35fa7110bbb3d4d59cd9612e0000000059844cbc000000001b1524ea000000001503cbac000000006b75d3272e38777e029fa4e94066163024177311de7ba1befec2e48b473c387bbcee1484bf276a54460215e3dfb8e6f262222c5f343f5e38c5c9a43d2594c7f06dd7ac1a4326c665dd050347aba4d56d7007a7dcf03594423dccba9ed700d11e665d261594e1154203df31020d457ee336ba6eeb328d00f1b8bd8bfefb8a4dcd5af6db4c438b7ec5106c7edc0380df17e1beb0f238e51a39122ac4c6fb57f3c4f5b7bc9432f991b1ef4a8af3570002020000018a" val withGlobalFeaturesDecoded = remoteParamsCodec.decode(withGlobalFeatures.bits).require.value - assert(withGlobalFeaturesDecoded.initFeatures.toByteVector === hex"028a") + assert(withGlobalFeaturesDecoded.initFeatures.toByteVector == hex"028a") } test("encode/decode htlc") { @@ -114,8 +114,8 @@ class ChannelCodecs1Spec extends AnyFunSuite { onionRoutingPacket = TestConstants.emptyOnionPacket) val htlc1 = IncomingHtlc(add) val htlc2 = OutgoingHtlc(add) - assert(htlcCodec.decodeValue(htlcCodec.encode(htlc1).require).require === htlc1) - assert(htlcCodec.decodeValue(htlcCodec.encode(htlc2).require).require === htlc2) + assert(htlcCodec.decodeValue(htlcCodec.encode(htlc1).require).require == htlc1) + assert(htlcCodec.decodeValue(htlcCodec.encode(htlc2).require).require == htlc2) } test("encode/decode commitment spec") { @@ -136,7 +136,7 @@ class ChannelCodecs1Spec extends AnyFunSuite { val htlc1 = IncomingHtlc(add1) val htlc2 = OutgoingHtlc(add2) val htlcs = Set[DirectedHtlc](htlc1, htlc2) - assert(setCodec(htlcCodec).decodeValue(setCodec(htlcCodec).encode(htlcs).require).require === htlcs) + assert(setCodec(htlcCodec).decodeValue(setCodec(htlcCodec).encode(htlcs).require).require == htlcs) val o = CommitmentSpec( htlcs = Set(htlc1, htlc2), commitTxFeerate = FeeratePerKw(Random.nextInt(Int.MaxValue).sat), @@ -145,7 +145,7 @@ class ChannelCodecs1Spec extends AnyFunSuite { ) val encoded = commitmentSpecCodec.encode(o).require val decoded = commitmentSpecCodec.decode(encoded).require - assert(o === decoded.value) + assert(o == decoded.value) } test("encode/decode origin") { @@ -153,14 +153,14 @@ class ChannelCodecs1Spec extends AnyFunSuite { val localHot = Origin.LocalHot(replyTo, UUID.randomUUID()) val localCold = Origin.LocalCold(localHot.id) - assert(originCodec.decodeValue(originCodec.encode(localHot).require).require === localCold) - assert(originCodec.decodeValue(originCodec.encode(localCold).require).require === localCold) + assert(originCodec.decodeValue(originCodec.encode(localHot).require).require == localCold) + assert(originCodec.decodeValue(originCodec.encode(localCold).require).require == localCold) val add = UpdateAddHtlc(randomBytes32(), 4324, 11000000 msat, randomBytes32(), CltvExpiry(400000), TestConstants.emptyOnionPacket) val relayedHot = Origin.ChannelRelayedHot(replyTo, add, 11000000 msat) val relayedCold = Origin.ChannelRelayedCold(add.channelId, add.id, add.amountMsat, relayedHot.amountOut) - assert(originCodec.decodeValue(originCodec.encode(relayedHot).require).require === relayedCold) - assert(originCodec.decodeValue(originCodec.encode(relayedCold).require).require === relayedCold) + assert(originCodec.decodeValue(originCodec.encode(relayedHot).require).require == relayedCold) + assert(originCodec.decodeValue(originCodec.encode(relayedCold).require).require == relayedCold) val adds = Seq( UpdateAddHtlc(randomBytes32(), 1L, 1000 msat, randomBytes32(), CltvExpiry(400000), TestConstants.emptyOnionPacket), @@ -169,8 +169,8 @@ class ChannelCodecs1Spec extends AnyFunSuite { ) val trampolineRelayedHot = Origin.TrampolineRelayedHot(replyTo, adds) val trampolineRelayedCold = Origin.TrampolineRelayedCold(trampolineRelayedHot.htlcs) - assert(originCodec.decodeValue(originCodec.encode(trampolineRelayedHot).require).require === trampolineRelayedCold) - assert(originCodec.decodeValue(originCodec.encode(trampolineRelayedCold).require).require === trampolineRelayedCold) + assert(originCodec.decodeValue(originCodec.encode(trampolineRelayedHot).require).require == trampolineRelayedCold) + assert(originCodec.decodeValue(originCodec.encode(trampolineRelayedCold).require).require == trampolineRelayedCold) } test("encode/decode map of origins") { @@ -184,7 +184,7 @@ class ChannelCodecs1Spec extends AnyFunSuite { -32L -> Origin.ChannelRelayedCold(randomBytes32(), 54, 15000000 msat, 14000000 msat), -54L -> Origin.TrampolineRelayedCold((randomBytes32(), 1L) :: (randomBytes32(), 2L) :: Nil), -4L -> Origin.LocalCold(UUID.randomUUID())) - assert(originsMapCodec.decodeValue(originsMapCodec.encode(map).require).require === map) + assert(originsMapCodec.decodeValue(originsMapCodec.encode(map).require).require == map) } test("encode/decode map of spending txes") { @@ -194,7 +194,7 @@ class ChannelCodecs1Spec extends AnyFunSuite { OutPoint(randomBytes32(), 0) -> randomBytes32(), OutPoint(randomBytes32(), 454513) -> randomBytes32() ) - assert(spentMapCodec.decodeValue(spentMapCodec.encode(map).require).require === map) + assert(spentMapCodec.decodeValue(spentMapCodec.encode(map).require).require == map) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version2/ChannelCodecs2Spec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version2/ChannelCodecs2Spec.scala index 9072ec4de7..ca95bd323e 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version2/ChannelCodecs2Spec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version2/ChannelCodecs2Spec.scala @@ -20,7 +20,7 @@ class ChannelCodecs2Spec extends AnyFunSuite { OutPoint(randomBytes32(), 0) -> Transaction.read("02000000000101b8cefef62ea66f5178b9361b2371be0759cbc8c689bcfa7a8e6746d497ec221a040000000001000000010a060000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402203c3a699fb80a38112aafd73d6e3a9b7d40bc2c3ed8b7fbc182a20f43b215172202204e71821b984d1af52c4b8e2cd4c572578c12a965866130c2345f61e4c2d3fef48347304402205bcfa92f83c69289a412b0b6dd4f2a0fe0b0fc2d45bd74706e963257a09ea24902203783e47883e60b86240e877fcbf33d50b1742f65bc93b3162d1be26583b367ee012001010101010101010101010101010101010101010101010101010101010101018d76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a9144b6b2e5444c2639cc0fb7bcea5afba3f3cdce23988527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f501b175ac6851b2756800000000"), OutPoint(randomBytes32(), 454513) -> Transaction.read("02000000000101ab84ff284f162cfbfef241f853b47d4368d171f9e2a1445160cd591c4c7d882b00000000000000000001e8030000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e0500483045022100d9e29616b8f3959f1d3d7f7ce893ffedcdc407717d0de8e37d808c91d3a7c50d022078c3033f6d00095c8720a4bc943c1b45727818c082e4e3ddbc6d3116435b624b014730440220636de5682ef0c5b61f124ec74e8aa2461a69777521d6998295dcea36bc3338110220165285594b23c50b28b82df200234566628a27bcd17f7f14404bd865354eb3ce012000000000000000000000000000000000000000000000000000000000000000008a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc688527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f401b175ac686800000000") ) - assert(spentMapCodec.decodeValue(spentMapCodec.encode(map).require).require === map) + assert(spentMapCodec.decodeValue(spentMapCodec.encode(map).require).require == map) } test("remove signatures from commitment txs") { @@ -38,32 +38,32 @@ class ChannelCodecs2Spec extends AnyFunSuite { { // Standard channel val commitments = channelDataCodec.decode(dataNormal.bits).require.value.commitments - assert(commitments.channelConfig === ChannelConfig.standard) - assert(commitments.channelFeatures === ChannelFeatures()) + assert(commitments.channelConfig == ChannelConfig.standard) + assert(commitments.channelFeatures == ChannelFeatures()) } { val staticRemoteKeyChannel = hex"000200000003039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a358500092eaee758da6a5beab04167c5b889732a98ec556cf92689da41744b10159ace488000000000000000000003e8ffffffffffffffff0000000000004e2000000000000003e80090001e001600140a46fc26a4ef7b50aaf16759d2f0ca8b014fd0a6028feba10d0eafd0fad8fe20e6d9206e6bd30242826de05c63f459a00aced24b120000000302698203af0ed6052cf28d670665549bc86f4b721c9fdb309d40c58f5811f63966e005d0000000000000044c000000001dcd6500000000000000271000000000000000000090006402a87d8f1844a3809284885b41cfc9713a561780b2b784a7a027851f68aaa838730328e2fd423323abcd86b15335ff44679068acd4db71b8052f63a2a7f0b47432bd028feba10d0eafd0fad8fe20e6d9206e6bd30242826de05c63f459a00aced24b12025ee0984b83efe2369c23c3754e89d19905f8094a86486de3b241cf8735208292031163dfd4eee879b9a333290cf10e52eb010d1da45bd44efee6fab16d1035120c0000186b02000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000269820000000000000000010001fffd05aab125c87884677613fe191e097b3806667482e0ff7668c64bca637300fe02307200000000000000000000000002faf080a2fbf30338f78b739d2b0a0a806506d6877408a995791901c43f6ef98d8a7a2e00061b10000223bb38126f1131ad95b37e0b30adf0ae315f66f8cf7460afccba393fa848d036073b6577f39b0e54043691e2eec74f46b86584ffab7aa01d15e6a7ff5ff9d7c60d095c7952a19e263c267f94fbe0208fdd212b304fa8d3df1379017d184fbcce7ffd5175997774c9de7ef2f3733c7056a22888c9f302e4a9bac35f581d4f571a7ef29e6cf3b1d8a7cc05cd155a047ae498a18fccb6589338242d91e00493a86b2b78810de20644f0f065399894854bd7347927a0ce8f9c1102c9c7227ffba4b71c4325f301933397aa8f54a28d3844c71021d19b72795141af019c9a0abae3e2cc29033b7f8be8465ac8406d4c1d61d0bc3c87dee2faac4d649fc166917c81a1e237c91d5c8091f696a72241c67047cfcec893bb41e97753b3d362695bc31f776cd4a744bf09f2e428dc189fa4838f34d130d5fd4fc3d79bc7546d30d543ca99818a8c39f6c17e74ff45976c95fd6de261d68e2c5fc585d28fa9ae5abb1db475f24d16d9cb0562a589c6dec07f3b81a37b4c7f2c4642df1fabf5d7343e038706e786d2cea71f76663f57a88751287db3f8e9a7a896990374daf72eb776ee67c9ec61c1a10f164688ecbc88caa086e24daa79808899e3c3f6870ed326f5253fc038147774fa8795351f44cbadc53b67743822b89f27f0c03b2b0f4e4c774598db681cadde0e4e28f1f4edbbc8ec68649fe05e3c8cdbc46b07011c9b81b9cb3ad92ec08ddf8209a501ce064ee0bd9befce196c0c559cffcb3b0c447922ad50fbceb288037ec36abb17d93deebd40e83d8c197248b14ee12dcfe72e46f0826ef1e6e94700ad6428df77b54eb8ca767af1fd84507adc52beef32f48e3968c24d990d04cd8b35c87e270a04e2e8fc9d0ab6a6398c2168986321cc0dc297f8e0e4887226db20958e934bc35151de72d896511e3b850d548402a0e1f32fb01d5050a8ff9d7ba6818600a2dafa1c4b3ca11c0d091796190c05a1edc8146d7ef534d67bb39f76f37279dff6be5e053b7315c3f3406e9240c6b618b18545fccb46d668c007a1b640634c663bbd27c5d00a48f5c3702bac6202b55cce4212920be059ecf708db85f07c0fcc0f480fcd06aef1128fc491b2b384d89ce15120c81bd65c225d679f8cd38fb1b0ddb7d8edd3455506fa3406578f43ba4caab00593b6623b7b69c863409f0350b8b8783b9ee2ada9b9f410ab309527b7f67758f543261f52695da19e597f9457483d188e8a2bd7248a6ee5f2d01cccacd2561239959f0ce80cbb83503891a8b4e3ab88d3a02de5f8c784c0700e8bef68445615f25dd3d5baea34bc8e694a7282b054f99fa2b150af00ec62c2fd2227a23e0c0a36090b5986271f964e969cc9313ef42c3b7a9ff9e608342c73da023019e983ee6b6f630e12a02ae79802bfbee10ba20199895d7f1302d2c3b8d7ba6ad08cbb27265f9bb709bf6225a81bdabf7fc5fe9ee4794b00181038051cae0a52c08d8a7750ee46c99b7dd6cd452c52a347f12873dc697786b89ddd13e2d584aa3244cdbdb7809bc7a42728d756485070ff84aaba81b1506a7b20d2acfef11df724ee78e8b0f92376676d1e01aed7ad8d84919b8296684dafc152680b0f964db5a1b7ee4093f453fe24750c6857252e4befef3df2d648e32cc20c1ef48fd5865c242951cd359f92985680f0d626602f164b6285971a194a4baf4eb1d9a3e88841269b3e84a96e6784407f869bca5db2bb2d31e784c35e210dcaf5d3441edea9a4a348e3ead6c9b920e1ff8f1c76c41d564827cd3db006e741a8dbb5db9bdbe13033faac7e6b676bc1cf88677d10676ddca3e187caeeac52b69212503f7acca29a49c699d68f0d982c4c41806c8d9bbbc4e7d2d77a1a0655c73cfcd21b93d95e70d2bad6c306dc172b67120335bd2d03878b3d9e5967c54dd567d307c15e305b5200002710000000000bebc200000000002cb4178024b125c87884677613fe191e097b3806667482e0ff7668c64bca637300fe023072000000002b40420f000000000022002090750411c84891017ca3ab8e6212a198dbf957143d6753f7b48264c7faf45cf44752210257f2ca56049071462716385481d04d3c7c859d7e9b3f31c019b126aa0eeed1e82102a87d8f1844a3809284885b41cfc9713a561780b2b784a7a027851f68aaa8387352aefd018602000000000101b125c87884677613fe191e097b3806667482e0ff7668c64bca637300fe023072000000000036a2ab800350c300000000000022002042ee833f99ec58f28a3ffc13033c29d4e02f72f6169e0e8e039ad9323e912e30400d030000000000220020981c45edf62e238461337b25d5fd7de72a305e7f4c7755a693f877b1a564831cb04e0b0000000000160014761879f7b274ce995f87150a02e75cc0c037e8e30400483045022100dc11d7761cdf7c708ea2aaaed409a4d24697bb07948704e77b7cbe911d0268fd02204a81721e85bb1ff6cb34741ed5c5ee89c4ea8f5bb1515792625d32043682c14301483045022100af2d760500664483ea81ccaa3bc925c5587cd3cd4358ee27110f62929903c49602201ce1a97498227eaef1ab5c04da2eb9ea8114abe6af1bd35494d9cbb0e64da3e7014752210257f2ca56049071462716385481d04d3c7c859d7e9b3f31c019b126aa0eeed1e82102a87d8f1844a3809284885b41cfc9713a561780b2b784a7a027851f68aaa8387352aead678920000101241bfa1a637efc49b76b41be6ec36c47c546f69b1646a11e8420957a1dbf731487000000002b50c300000000000022002042ee833f99ec58f28a3ffc13033c29d4e02f72f6169e0e8e039ad9323e912e308b76a91420fe4794a7f993489c0477c442fed3be2c9294678763ac67210230714b6385889be70b5299603fbc508a01517a3b754d03e33e5bcf125104adc57c8201208763a914e5a9c4cf993e5053ca47ddd2a194a3c522c1fdc588527c2103bff704aae937cd0b98704a4791140cab835c5bd2406897104602c881352869ae52ae677503101b06b175ac68685e02000000011bfa1a637efc49b76b41be6ec36c47c546f69b1646a11e8420957a1dbf73148700000000000000000001daa7000000000000220020981c45edf62e238461337b25d5fd7de72a305e7f4c7755a693f877b1a564831c00000000a2fbf30338f78b739d2b0a0a806506d6877408a995791901c43f6ef98d8a7a2e000000000000000040c5c678fda30c1e23bbb68093b1d9a34169304ff3d36bfef74157f129df8d01e31ddcd8dd04f3ac9521ac13b7fed5d7997ce0c72c942054711d924ea197c7ab7640cd0045f41ffd38fa637cfc09679c628b29a8273223db1150e262d5159cf5d7852542c4ad7334f67d08ca835cd5b16b1df96544c454dff121856685471d2255300000000000000001000100fd05aab125c87884677613fe191e097b3806667482e0ff7668c64bca637300fe02307200000000000000000000000002faf080a2fbf30338f78b739d2b0a0a806506d6877408a995791901c43f6ef98d8a7a2e00061b10000223bb38126f1131ad95b37e0b30adf0ae315f66f8cf7460afccba393fa848d036073b6577f39b0e54043691e2eec74f46b86584ffab7aa01d15e6a7ff5ff9d7c60d095c7952a19e263c267f94fbe0208fdd212b304fa8d3df1379017d184fbcce7ffd5175997774c9de7ef2f3733c7056a22888c9f302e4a9bac35f581d4f571a7ef29e6cf3b1d8a7cc05cd155a047ae498a18fccb6589338242d91e00493a86b2b78810de20644f0f065399894854bd7347927a0ce8f9c1102c9c7227ffba4b71c4325f301933397aa8f54a28d3844c71021d19b72795141af019c9a0abae3e2cc29033b7f8be8465ac8406d4c1d61d0bc3c87dee2faac4d649fc166917c81a1e237c91d5c8091f696a72241c67047cfcec893bb41e97753b3d362695bc31f776cd4a744bf09f2e428dc189fa4838f34d130d5fd4fc3d79bc7546d30d543ca99818a8c39f6c17e74ff45976c95fd6de261d68e2c5fc585d28fa9ae5abb1db475f24d16d9cb0562a589c6dec07f3b81a37b4c7f2c4642df1fabf5d7343e038706e786d2cea71f76663f57a88751287db3f8e9a7a896990374daf72eb776ee67c9ec61c1a10f164688ecbc88caa086e24daa79808899e3c3f6870ed326f5253fc038147774fa8795351f44cbadc53b67743822b89f27f0c03b2b0f4e4c774598db681cadde0e4e28f1f4edbbc8ec68649fe05e3c8cdbc46b07011c9b81b9cb3ad92ec08ddf8209a501ce064ee0bd9befce196c0c559cffcb3b0c447922ad50fbceb288037ec36abb17d93deebd40e83d8c197248b14ee12dcfe72e46f0826ef1e6e94700ad6428df77b54eb8ca767af1fd84507adc52beef32f48e3968c24d990d04cd8b35c87e270a04e2e8fc9d0ab6a6398c2168986321cc0dc297f8e0e4887226db20958e934bc35151de72d896511e3b850d548402a0e1f32fb01d5050a8ff9d7ba6818600a2dafa1c4b3ca11c0d091796190c05a1edc8146d7ef534d67bb39f76f37279dff6be5e053b7315c3f3406e9240c6b618b18545fccb46d668c007a1b640634c663bbd27c5d00a48f5c3702bac6202b55cce4212920be059ecf708db85f07c0fcc0f480fcd06aef1128fc491b2b384d89ce15120c81bd65c225d679f8cd38fb1b0ddb7d8edd3455506fa3406578f43ba4caab00593b6623b7b69c863409f0350b8b8783b9ee2ada9b9f410ab309527b7f67758f543261f52695da19e597f9457483d188e8a2bd7248a6ee5f2d01cccacd2561239959f0ce80cbb83503891a8b4e3ab88d3a02de5f8c784c0700e8bef68445615f25dd3d5baea34bc8e694a7282b054f99fa2b150af00ec62c2fd2227a23e0c0a36090b5986271f964e969cc9313ef42c3b7a9ff9e608342c73da023019e983ee6b6f630e12a02ae79802bfbee10ba20199895d7f1302d2c3b8d7ba6ad08cbb27265f9bb709bf6225a81bdabf7fc5fe9ee4794b00181038051cae0a52c08d8a7750ee46c99b7dd6cd452c52a347f12873dc697786b89ddd13e2d584aa3244cdbdb7809bc7a42728d756485070ff84aaba81b1506a7b20d2acfef11df724ee78e8b0f92376676d1e01aed7ad8d84919b8296684dafc152680b0f964db5a1b7ee4093f453fe24750c6857252e4befef3df2d648e32cc20c1ef48fd5865c242951cd359f92985680f0d626602f164b6285971a194a4baf4eb1d9a3e88841269b3e84a96e6784407f869bca5db2bb2d31e784c35e210dcaf5d3441edea9a4a348e3ead6c9b920e1ff8f1c76c41d564827cd3db006e741a8dbb5db9bdbe13033faac7e6b676bc1cf88677d10676ddca3e187caeeac52b69212503f7acca29a49c699d68f0d982c4c41806c8d9bbbc4e7d2d77a1a0655c73cfcd21b93d95e70d2bad6c306dc172b67120335bd2d03878b3d9e5967c54dd567d307c15e305b5200002710000000002cb41780000000000bebc200b5c42b5c67eb6043b2776c0e9a8bd91d8ffdf7280b81dce825558ad5258746fb030d9b4186ad4f32aae9ca90701dc66e8df3f7b73e1f9590c0f6cd690aae8ad097000000000000000000000000000000000000000000000000000000010000ff0250b3cac5267f9448efcb8c2a89944f8bb4e4e7f1a3ae72d4961dfe187105b3f324b125c87884677613fe191e097b3806667482e0ff7668c64bca637300fe023072000000002b40420f000000000022002090750411c84891017ca3ab8e6212a198dbf957143d6753f7b48264c7faf45cf44752210257f2ca56049071462716385481d04d3c7c859d7e9b3f31c019b126aa0eeed1e82102a87d8f1844a3809284885b41cfc9713a561780b2b784a7a027851f68aaa8387352ae000100400000ffffffffffff0020b0e394cbe4d79e47a73926b89d17d8835e8f042d7adb244a84b6c30496c6355f80007fffffffffff80b125c87884677613fe191e097b3806667482e0ff7668c64bca637300fe023072061a8000002a00000000888bc37730827b0ccb54f13689babb8d211a6cbbec55113caad14a97f6bfce7d85313c9cefa398d15213abf841e3c9a8b88f62fa3fc742a6c746619d3e76aa71fb06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f061a8000002a000060e32b8d010000900000000000000000000854d00000000a000000003b9aca000000" val commitments = channelDataCodec.decode(staticRemoteKeyChannel.bits).require.value.commitments - assert(commitments.channelConfig === ChannelConfig.standard) - assert(commitments.channelFeatures === ChannelFeatures(Features.StaticRemoteKey)) + assert(commitments.channelConfig == ChannelConfig.standard) + assert(commitments.channelFeatures == ChannelFeatures(Features.StaticRemoteKey)) } { val anchorOutputsChannel = hex"00020000000703af0ed6052cf28d670665549bc86f4b721c9fdb309d40c58f5811f63966e005d000094b82816a3f15ab3e324ddf6f0f5a116cef8c3200a353240db684337d2dcaa81e80000001000000000000044c000000001dcd65000000000000002710000000000000000000900064ff160014f09f6f93de60c6af417ed31d52c2c883b6113f260000186b0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000225982039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a358500000000000003e8ffffffffffffffff0000000000004e2000000000000003e80090001e02e9cd12509fbc345c10e2b2e10427ae43eabbf0788bda8118b34344e5576d5d5002eb112dd8d61a02bf3434d5417e1020ed2d951e75bd1e14615d473dd5f1991b4402ca8b6891d6a53aea035259fa0d57a1e672d3cc59a2c696a96247d3557ee726cd030f2aa0ca0ae0e00d6da847d897cf7288ae286dd12037f06250937dc7b37fe0b5028d59e68c5799980a98b120acb891dabfd091e80c6596b0c2a7de57a298d48512000000032259820000000000000000000000000009c4000000002faf0800000000000bebc2002432e16e6e875d1f02a9512943ba2eb9309f4715390b52e4965dd6e39a2989ae63000000002b40420f00000000002200204de81ee2e9850dabdb9c364a12cc2dd75dd20c21d4ca0a809a2e6af3caeeaf9647522102e9cd12509fbc345c10e2b2e10427ae43eabbf0788bda8118b34344e5576d5d502103683425bf640d5e4338553ca6f6afea948ff2bf378eed1b3e9497a3f18f477d5352aefd01bc0200000000010132e16e6e875d1f02a9512943ba2eb9309f4715390b52e4965dd6e39a2989ae63000000000089273f80044a010000000000002200202102815a0b14d50a2a8c028cd47413e743f02ad5460151bd4ae5930639cbbd484a010000000000002200204e81bd6470c45c349068c2b0ad544934b718ef49c1615f2a0b0cd8766400b562400d0300000000002200208eadab92c95168438acfb73f2d3d92f56d6fc30d3f79fc4527f4e77df88b8add72270c0000000000220020895c0fef7efb7aa0e4805381434363b30386d31f6cb621abb0ca4a52b269fbc304004830450221009f09a584b1af9ba86f1618aad1ca9817324f97c3d3789b2490c3b9435c7bf1dd02205e4dcca3d7937f6b80a0ed39084e4ea9e9c531b80698ebd0c116fd9319a0db1201473044022001e4104ec25ba9bc43bf3f623d6e98f371434442b134255667ddeedd9cd9cd1b02201f057d2c15ee4e5d62a73f1db262846ca7ad35deaed2496abdb5b16cd91c5cb80147522102e9cd12509fbc345c10e2b2e10427ae43eabbf0788bda8118b34344e5576d5d502103683425bf640d5e4338553ca6f6afea948ff2bf378eed1b3e9497a3f18f477d5352ae25899520000000000000000000000000000009c4000000000bebc200000000002faf0800acdb0bf90ed7350d429c2d70fce66300ac9b27d8dbb3bceb5bd2cc8bd443938f03f54d00601f1b95e82836540d760ab6b38bc6fc1701df5d5e3b410f1936212d54000000000000000000000000000000000000000000000000000000000000ff03658b1e02efd8464688f87a052518691ff4d818a7c36addf4c6520ae07b7e20912432e16e6e875d1f02a9512943ba2eb9309f4715390b52e4965dd6e39a2989ae63000000002b40420f00000000002200204de81ee2e9850dabdb9c364a12cc2dd75dd20c21d4ca0a809a2e6af3caeeaf9647522102e9cd12509fbc345c10e2b2e10427ae43eabbf0788bda8118b34344e5576d5d502103683425bf640d5e4338553ca6f6afea948ff2bf378eed1b3e9497a3f18f477d5352ae00000032e16e6e875d1f02a9512943ba2eb9309f4715390b52e4965dd6e39a2989ae63061a8000002a000000008833a9275befbedbf928e743a71c9476f46528baf6e832ad25478c2607e4108dea67657c51db7344032627c855518179dc7a94b59f306faf9a3b4eef7684d5d73106226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f061a8000002a000060e32a590101009000000000000003e8000854d00000000a000000003b9aca000000" val commitments = channelDataCodec.decode(anchorOutputsChannel.bits).require.value.commitments - assert(commitments.channelConfig === ChannelConfig.standard) - assert(commitments.channelFeatures === ChannelFeatures(Features.StaticRemoteKey, Features.AnchorOutputs)) + assert(commitments.channelConfig == ChannelConfig.standard) + assert(commitments.channelFeatures == ChannelFeatures(Features.StaticRemoteKey, Features.AnchorOutputs)) } { val wumboChannel = hex"00000000000103af0ed6052cf28d670665549bc86f4b721c9fdb309d40c58f5811f63966e005d00009b3b6da18b7e5e43405415a43e61abd77edf4d300c131af17a955950837d7db4980000001000000000000044c000000001dcd65000000000000002710000000000000000000900064ff1600142946bdbb3141be9a40ed8133ef159ee0022176e90000186b02000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a4982039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a358500000000000003e8ffffffffffffffff0000000000004e2000000000000003e80090001e03a6be2613a9ff761a769b077abb43d76c5f06944fc32010891156179bf8b81607025c24f0c3572631ea09dade913ccbb1cd8a55585fc152cc2165bf4f43af702c8b0306c241c667eefee031639052c4a35c4ae076ab56b49f76f7e12f63dfb7bb32a503fdbff1ca92c99c09a9c0eac3cfe1ca35deb658d5fdb815fe7a240df25da5e20f02c47d9e4e1fb501c81933cfc4d3ba7f0e8203003cda2683569f1f67aac2b6e20d000000030a4982000000000000000000000000002710000000745e66c600000000000bebc2002464fc06b43e94d9ce0a5a0e1ef13f63ba78e56d920e7d606d0c6e7a631c48c32c000000002b0065cd1d00000000220020d1b88cc50b09abce945ce6703f30dae3d71ec626be2201925db9379a3e8b981047522103044d393b0da6bcd92030f3131d0780b0d6fa017a0ff45b7fed708903c2950ced2103a6be2613a9ff761a769b077abb43d76c5f06944fc32010891156179bf8b8160752aefd01590200000000010164fc06b43e94d9ce0a5a0e1ef13f63ba78e56d920e7d606d0c6e7a631c48c32c000000000018e2678002400d030000000000160014cf3c9d08ec27d3ffefbf7e2640d3773e11a60ceb783bca1d00000000220020153e514ade07f347db9ed32cf6b2096d066d48e0cf8c504590cd1155de68be2204004730440220056ac83d5b2eb9eb9714e85294d080a9b64f73916d8206b15533613b4303ed3d022044da40ba433e27ddb8743c75acc0f6b050c346bc9d241ab3a1b65051820ce06a0147304402207683c10f33682e2389e5f02dd34090bbe4d786633d49e1777d5ec2ab71a7924902206d99dceb74ff809237ae8e06c118b38047e2d4a49f9956c538bedca47cb4b1da0147522103044d393b0da6bcd92030f3131d0780b0d6fa017a0ff45b7fed708903c2950ced2103a6be2613a9ff761a769b077abb43d76c5f06944fc32010891156179bf8b8160752aef5c4602000000000000000000000000000002710000000000bebc200000000745e66c6000bdebd6cf39db4c2ce1a675281b0a714e525525149032ba048d75c89e5a9b355021a87b53e12e4b36287635cdf887991a732c2fd56b12f5377d755b8b890795db6000000000000000000000000000000000000000000000000000000000000ff032c5f941f78a00105b995fba7f3c340afe53e287a60361135386ae1448d6f3d632464fc06b43e94d9ce0a5a0e1ef13f63ba78e56d920e7d606d0c6e7a631c48c32c000000002b0065cd1d00000000220020d1b88cc50b09abce945ce6703f30dae3d71ec626be2201925db9379a3e8b981047522103044d393b0da6bcd92030f3131d0780b0d6fa017a0ff45b7fed708903c2950ced2103a6be2613a9ff761a769b077abb43d76c5f06944fc32010891156179bf8b8160752ae00000064fc06b43e94d9ce0a5a0e1ef13f63ba78e56d920e7d606d0c6e7a631c48c32cff5e020000000101010101010101010101010101010101010101010101010101010101010101012a00000000ffffffff010065cd1d00000000220020d1b88cc50b09abce945ce6703f30dae3d71ec626be2201925db9379a3e8b9810000000000000000060e32bf9000082000000000000000000000000000000000000000000000000000000000000000064fc06b43e94d9ce0a5a0e1ef13f63ba78e56d920e7d606d0c6e7a631c48c32c0000f4957823b0a6b76697d7c545bcca66abec8522a0f6350a722e45f3f2830f7f824c84efed8daffa04bb0822ce1a08fb2de77dd20c23a91cced7a3966808956644" val commitments = channelDataCodec.decode(wumboChannel.bits).require.value.commitments - assert(commitments.channelConfig === ChannelConfig.standard) - assert(commitments.channelFeatures === ChannelFeatures(Features.Wumbo)) + assert(commitments.channelConfig == ChannelConfig.standard) + assert(commitments.channelFeatures == ChannelFeatures(Features.Wumbo)) } } test("ensure remote shutdown script is not set") { val commitments = channelDataCodec.decode(dataNormal.bits).require.value.commitments - assert(commitments.remoteParams.shutdownScript === None) + assert(commitments.remoteParams.shutdownScript == None) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version3/ChannelCodecs3Spec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version3/ChannelCodecs3Spec.scala index 4f2f3a634d..18f8a86de7 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version3/ChannelCodecs3Spec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/internal/channel/version3/ChannelCodecs3Spec.scala @@ -35,21 +35,21 @@ class ChannelCodecs3Spec extends AnyFunSuite { val data = normal val bin = DATA_NORMAL_Codec.encode(data).require val check = DATA_NORMAL_Codec.decodeValue(bin).require - assert(data.commitments.localCommit.spec === check.commitments.localCommit.spec) - assert(data === check) + assert(data.commitments.localCommit.spec == check.commitments.localCommit.spec) + assert(data == check) } test("encode/decode channel configuration options") { - assert(channelConfigCodec.encode(ChannelConfig(Set.empty[ChannelConfigOption])).require.bytes === hex"00") - assert(channelConfigCodec.decode(hex"00".bits).require.value === ChannelConfig(Set.empty[ChannelConfigOption])) - assert(channelConfigCodec.decode(hex"01f0".bits).require.value === ChannelConfig(Set.empty[ChannelConfigOption])) - assert(channelConfigCodec.decode(hex"020000".bits).require.value === ChannelConfig(Set.empty[ChannelConfigOption])) - - assert(channelConfigCodec.encode(ChannelConfig.standard).require.bytes === hex"0101") - assert(channelConfigCodec.encode(ChannelConfig(ChannelConfig.FundingPubKeyBasedChannelKeyPath)).require.bytes === hex"0101") - assert(channelConfigCodec.decode(hex"0101".bits).require.value === ChannelConfig(ChannelConfig.FundingPubKeyBasedChannelKeyPath)) - assert(channelConfigCodec.decode(hex"01ff".bits).require.value === ChannelConfig(ChannelConfig.FundingPubKeyBasedChannelKeyPath)) - assert(channelConfigCodec.decode(hex"020001".bits).require.value === ChannelConfig(ChannelConfig.FundingPubKeyBasedChannelKeyPath)) + assert(channelConfigCodec.encode(ChannelConfig(Set.empty[ChannelConfigOption])).require.bytes == hex"00") + assert(channelConfigCodec.decode(hex"00".bits).require.value == ChannelConfig(Set.empty[ChannelConfigOption])) + assert(channelConfigCodec.decode(hex"01f0".bits).require.value == ChannelConfig(Set.empty[ChannelConfigOption])) + assert(channelConfigCodec.decode(hex"020000".bits).require.value == ChannelConfig(Set.empty[ChannelConfigOption])) + + assert(channelConfigCodec.encode(ChannelConfig.standard).require.bytes == hex"0101") + assert(channelConfigCodec.encode(ChannelConfig(ChannelConfig.FundingPubKeyBasedChannelKeyPath)).require.bytes == hex"0101") + assert(channelConfigCodec.decode(hex"0101".bits).require.value == ChannelConfig(ChannelConfig.FundingPubKeyBasedChannelKeyPath)) + assert(channelConfigCodec.decode(hex"01ff".bits).require.value == ChannelConfig(ChannelConfig.FundingPubKeyBasedChannelKeyPath)) + assert(channelConfigCodec.decode(hex"020001".bits).require.value == ChannelConfig(ChannelConfig.FundingPubKeyBasedChannelKeyPath)) } test("decode all known channel configuration options") { @@ -75,7 +75,7 @@ class ChannelCodecs3Spec extends AnyFunSuite { assert(declaredOptions.nonEmpty) val encoded = channelConfigCodec.encode(ChannelConfig(declaredOptions)).require val decoded = channelConfigCodec.decode(encoded).require.value - assert(decoded.options === declaredOptions) + assert(decoded.options == declaredOptions) } test("encode/decode optional shutdown script") { @@ -95,15 +95,15 @@ class ChannelCodecs3Spec extends AnyFunSuite { randomKey().publicKey, Features(ChannelRangeQueries -> Optional, VariableLengthOnion -> Mandatory, PaymentSecret -> Mandatory), None) - assert(codec.decodeValue(codec.encode(remoteParams).require).require === remoteParams) + assert(codec.decodeValue(codec.encode(remoteParams).require).require == remoteParams) val remoteParams1 = remoteParams.copy(shutdownScript = Some(ByteVector.fromValidHex("deadbeef"))) - assert(codec.decodeValue(codec.encode(remoteParams1).require).require === remoteParams1) + assert(codec.decodeValue(codec.encode(remoteParams1).require).require == remoteParams1) val dataWithoutRemoteShutdownScript = normal.copy(commitments = normal.commitments.copy(remoteParams = remoteParams)) - assert(DATA_NORMAL_Codec.decode(DATA_NORMAL_Codec.encode(dataWithoutRemoteShutdownScript).require).require.value === dataWithoutRemoteShutdownScript) + assert(DATA_NORMAL_Codec.decode(DATA_NORMAL_Codec.encode(dataWithoutRemoteShutdownScript).require).require.value == dataWithoutRemoteShutdownScript) val dataWithRemoteShutdownScript = normal.copy(commitments = normal.commitments.copy(remoteParams = remoteParams1)) - assert(DATA_NORMAL_Codec.decode(DATA_NORMAL_Codec.encode(dataWithRemoteShutdownScript).require).require.value === dataWithRemoteShutdownScript) + assert(DATA_NORMAL_Codec.decode(DATA_NORMAL_Codec.encode(dataWithRemoteShutdownScript).require).require.value == dataWithRemoteShutdownScript) } test("encode/decode optional channel reserve") { @@ -141,39 +141,39 @@ class ChannelCodecs3Spec extends AnyFunSuite { val remoteCodec = remoteParamsCodec(ChannelFeatures()) val decodedLocalParams = localCodec.decode(localCodec.encode(localParams).require).require.value val decodedRemoteParams = remoteCodec.decode(remoteCodec.encode(remoteParams).require).require.value - assert(decodedLocalParams === localParams) - assert(decodedRemoteParams === remoteParams) + assert(decodedLocalParams == localParams) + assert(decodedRemoteParams == remoteParams) } { val localCodec = localParamsCodec(ChannelFeatures(Features.DualFunding)) val remoteCodec = remoteParamsCodec(ChannelFeatures(Features.DualFunding)) val decodedLocalParams = localCodec.decode(localCodec.encode(localParams).require).require.value val decodedRemoteParams = remoteCodec.decode(remoteCodec.encode(remoteParams).require).require.value - assert(decodedLocalParams === localParams.copy(requestedChannelReserve_opt = None)) - assert(decodedRemoteParams === remoteParams.copy(requestedChannelReserve_opt = None)) + assert(decodedLocalParams == localParams.copy(requestedChannelReserve_opt = None)) + assert(decodedRemoteParams == remoteParams.copy(requestedChannelReserve_opt = None)) } } test("backward compatibility DATA_NORMAL_COMPAT_02_Codec") { val oldBin = hex"00022aed498450b3eb2f6aafedd40640b54efc60ae681da9e6a35299b8b6a6125a7301010003af0ed6052cf28d670665549bc86f4b721c9fdb309d40c58f5811f63966e005d00009d2b17f27b3938b2b50ec713df1b1ae5fd3d23010c9e2e22385f13a168c6acf2c80000001000000000000044c000000001dcd65000000000000002710000000000000000000900064ff1600149d706d0fa71a0b6aa0f3fa400bee18102b45c8170000186b0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024982039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a358500000000000003e8ffffffffffffffff0000000000004e2000000000000003e80090001e03fb08866066d5f6f539314220fc31a8e7fdf6ccd12ccde150acc59bac5bb971e003f399d17a9e2fb13a52373d1631807c3161250b2774642fffa629858ad0831f68020b4ecc52820a93f6da40a60d7859307edc737347054d82592959ed1cd0b02e9c03db348203bfd939779bfdd825bc807e904225c3348fa5e3bb57d38ac4b9f40f850284c0df55fbfc2212cbd18cf8ab0eb5283b4b883350ff07e81988e01ae2bb71e20000000302498200000000000000000000000000002710000000002faf0800000000000bebc200242aed498450b3eb2f6aafedd40640b54efc60ae681da9e6a35299b8b6a6125a73000000002b40420f00000000002200203305e10ec90f004675285e9b0371a663ead7abe6caba8c6d5739ace6c9eab4534752210390d6a42ff78a21b41560f75359f0f8a9edaaf0ddcf1a6609130f0d5f234463662103fb08866066d5f6f539314220fc31a8e7fdf6ccd12ccde150acc59bac5bb971e052ae7d02000000012aed498450b3eb2f6aafedd40640b54efc60ae681da9e6a35299b8b6a6125a7300000000000a1e418002400d0300000000001600146862a069e7038573a81f5627ae7d0c6ee5cd0acfb8180c0000000000220020a5f137a8049afcac9f0451b0f31677a81b5443f1c04c1910b37b0d2b8aa4ca0084a4eb2096e400507ac49b57910c914cff8338b8bc57884983541ee1b6919ece7431f4030b09a5fcd87b35682dea0d8faa394e47cc31af897cdf3e6ff502b086cfac37c700000000000000000000000000002710000000000bebc200000000002faf080028131acadf245e7d95d3d7a7f1ac0c0411ead7957ab00d310696b0b5d7d14ac8020597a38e090850030f255fb2781a53713faf7ba81c44de931a63a78efd9908ef000000000000000000000000000000000000000000000000000000000000ff035878c87f6ed100476648193e10a1462bfb55cea3ec5a8f4fbd0fe7304979094b242aed498450b3eb2f6aafedd40640b54efc60ae681da9e6a35299b8b6a6125a73000000002b40420f00000000002200203305e10ec90f004675285e9b0371a663ead7abe6caba8c6d5739ace6c9eab4534752210390d6a42ff78a21b41560f75359f0f8a9edaaf0ddcf1a6609130f0d5f234463662103fb08866066d5f6f539314220fc31a8e7fdf6ccd12ccde150acc59bac5bb971e052ae000000061a8000002a0000000088ec7ae2af533c270809b48f9a0b5a9650df9961a2177e04d7e9929ab319fcd0d150e3ded703b8b4a3f5faff0f2fedf22a6729760deefdea4feed868e4e3cdcf1b06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f061a8000002a000061163fb60101009000000000000003e8000858b800000014000000003b9aca000000" val decoded1 = channelDataCodec.decode(oldBin.bits).require.value - assert(decoded1.asInstanceOf[DATA_NORMAL].closingFeerates === None) + assert(decoded1.asInstanceOf[DATA_NORMAL].closingFeerates == None) val newBin = channelDataCodec.encode(decoded1).require.bytes // make sure that encoding used the new codec assert(newBin.startsWith(hex"0007")) val decoded2 = channelDataCodec.decode(newBin.bits).require.value - assert(decoded1 === decoded2) + assert(decoded1 == decoded2) } test("backward compatibility DATA_SHUTDOWN_COMPAT_03_Codec") { val oldBin = hex"0003342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d301010003af0ed6052cf28d670665549bc86f4b721c9fdb309d40c58f5811f63966e005d00009f2408e50889ac3f6c19a007e25752bf143ab0d920cedb9f1c7b7b6b2270c1fe080000001000000000000044c000000001dcd65000000000000002710000000000000000000900064ff160014d0cd80743458194e5f86d9a74592765442fd15bb0000186b0200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024982039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a358500000000000003e8ffffffffffffffff0000000000004e2000000000000003e80090001e03d1a9a2a574585f60abaaa33826488f9eb8d53ca76693bfa69b42ee2bc8ebe9c50223dc803cceb3edff5deacc9965002cc366b719331e776abf76ee680e4afbf46a0315880bf27110fa57f5b75607bc32a098c209fe8a5a2a30120b2a246fd3fcd62e025dc435be4cb790e5ab12705fb3c0b717ddd9f4d0234fdb557358ecefc6a4e97a0238e3723a9d60dac60c2673ec836e2a909ba9fc888fcbd1cd2ad57ff0b10c5c360000000302498200000000000000000001000200fd05aa342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d300000000000000000000000011e1a300d91ec390338376481ff3aea604bf2106cf380d78e946e6a4fc0ad72dc0dec51b00061b100002909a15094ba406ca280bce032eab4d25eae4a9e8b51ff65574b6de2033a292cb1bc6ef576207f4b585273048502efad58af480f08dabcbff1a9642eb3b08811eb4417ac14bf6e5e3883d55ba3b7fdaf27e5ebac16ce63d183b2521867f6cedcf55692f1490da9bc655e38281a26150c44d56e02013faf1cdb2457bec4830e67c10ff0d731798d9e383cc3ce9ba21bddd8971e1d206c54c22317d75411b73abb08c9af348cca2aa2f17232b008aaef4bedb98c426041d3698924d089b59c639396ba38d2ba6d59ea2b0ee8ec9f548deced719e9aae73854d8b6c10c78890999ae09b912a8ae98d3513119bfa0ffdd3037cf5690122020f2c0d01b282ad0cbe345bd31cf7e55d8e78c61abfa62f97d2a095e2256c6569d3e6b5652b365d935d16451f2cf7df04e99e675d9eb649b583fc5d810dae3860001e667b9b78733b3ed6ca5058e6806ca4eb493c5c9a53b0ad78b9ea2091d6e94130afb1d79ce8e274a93d748af9d4ee7ae5b1c06cf1f65507bc79db22c30ae6df93a16c279e4beaf50a0e4e87449e9c830fe9b3877b7332b0632743d4e6267ffa404a35d74d79c5d724bdc9aaaa0423a157fb269b916b0022fd52bb0b2702e6abcc7d9d39d7f69a09a9814b3110cc72574fed031bbc0fd5a03fcee1181076369e76c183b2833385a38dd10773fe3228cb18aa731674a574d310a76052cf89c80077aa89380fcfdeda00508f79261c1e1886240de3bbc343eb84ea7879de24f7dbd0b1527201131bcaf5621e49c69ceec36280f9db6d27161c1676c9b11597d4bd8f10032a964fc1d1afcea594237f3408b184b16eba952778252bc6debc30e6e595c7ebbc2af0c00456ca771d024a56d9f074ca5a7f78f1ef107aa42c2a6426f8dbb2ea8962e2128cfc15161512d2e923e2879635c8ba80bc17f92d09abfae4e08a7f34decc1acd4aa4cc08181017bf248321558a8c4d1a45b92b96274dd9f336eb45d8af6d13147be3a250c17106ec6729e0cffc1af5255352296477dea870426aa82e7af3cc07156b65f8d98b482985618b69b99ee3871240db751923dbeddea6e36f5c3f0599300973fe064ccf4f15cadb7372aaab5b300674f5bf28ce905ab411f5605fba7075ed4a6b08dca3ed5867dc32e491c64e7f09ff4095081e0731cbfc53fa42c33e79bd1a26d8e9f8c5b546b07bd1b300f1f357919e955bded1f987401f4da1a453282b6978ff3bfd13b280f6253dd968cb4e7741a15faf7b4c70dbd9eab6461ca3d3a576410213bc4e144a63685488afeeb7857af4ef83e73c88b17798616a9ccbd603d61ec8f4dbbdd5fea5ca748cf40c38fec50d4eebf1e5b57fd32500baa892da24349598c3125162b2ea0ea049ea9aacdfa848f41fdf7f9eb983776bac58ddf762d131196ab18774349a5eca2fc5b51b60d7aceae1321c1decd462f9c7dbbd820399f71a3c3ccbb30a29f76cd8e94243e400c4dc6e6d32b6f94155a21eb89b6b4c0fd1660bd98509d11b3a45fb257ae1e3c5ebae7bae038200c0f7f2d4ee744c3f2d9007d6fb282b0254ccd71eae5b4c4996b52edb2f2f4120356096c81e42168ee43d98bd630b0af01c270db3fb680cd931d388e1c1260126707548ed1f27006a64db7885ac7500ce020f6349a1abf59fb3ca4bc5bdcbd19b7a0cfe82aeea62f0373d5c16002cd9adcb3ef5e0c862e2fda972530b399b0f6365f4edbc36a32bd1766763104aca34450f278418211d62ff3fff2d0de7f516028011e5681ee892288835a3ec6d0d353f8bc7168086a0eed30d5e81d8a51f7debbb2290dc1a1745e0fc2c08778d11ccb78dc7c98a8b4a4b28fd8decda3a2063ad73c23c112d609b6903613c5ad8e178c90fed2ebd10b176b17c9c2dfc630ef744ac289b437ad229b77a393c6b05c10f36ba2f80482ed6e26b3d9c34d2200fd05aa342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d30000000000000001000000000bebc20092ebfcedc573c52ba840ff42bb322419ed390dc845c2fe80636b6b82cf41210000061b100002f211b0d97e6c7f7fb800dbb8d1c7536ad7ef284c40a85fc7316b771bb525c91f7e1d4bba90df0cf0d12c19906e4ae0a1b83954632b59f5f499dedaeba19d75c3bc244ccb57089abeaf29c7d73d67ae822aea2ed4d85d27dc65042589e8172aa3b66d928d7e35f027d96bf23e656701bdf13651e25bed745fef014fdec3faaba4795638299975d3cdc8d2c5b19e2e411e6e4f7b3cede7e269c8902306d25b1027e99736489fde667f4eaf5726349851986ff15a9e967385e080079a14c0a9c3001bbce5da720dcf739e67801cfe2a565b24f5515f8d8889a6d2dc0b51fae4facb72904ba8c1949550332cd8b9095655da72a9815537a80efd204d497af47fd18ef0f6d0639424eb81dab0e34f228aed9406d23773874b4c41d9a21dcaf632419e459baaca5f338f0f9718c89fb72108788d32aeb07e2eb343c45891958779e75fe0039eddaf7e5c4aa8ac2aee9928c68dc529d415780d8e14adcecc91b142b238e7657ef1dc6b6e9843bb5fbe8d04564307e515d88b34105b90b3fa9ed91025297a373507cba86160ba5b7b569948c95fd483b28b8970bebd5e17fcad76c6ed64615cc2d7297994483d94c010a210ad3602b7f359d7d1391b97968f9eaa70de83ea1168fdb05190a6e9fc7c984213da3e2a6672d09704d8e29e2aa9349c9ae44eca3dc0522c769887cbaa0926c5bad64eaf7c22399f7abcc01505d921cce15f4613406956715fe3030ab5c74506d1acc30649b596931316a8e210a368d758d7c1f406f5888499f8317a9ba629dfe85453b4413107796bde15636e6f628078863c0009db7d97cfadc2bfdcdfed237debac33dc525f25865663bc7a812099102fe9c65c8a37b179337141c8d76f365824b0db54b0b18d6c88b21406a1e35061fb4f5ef8a280f9c2ac2ada9eea8cb365d346c5e9eaa56728584aa71c4296a1c11d76f03351a91a030ae6df1da008a5d0f92207b8ca22f335b5a347707ef2500119597d5b92c559f477d8405f1d0dfd790c99ca5a7b4aeac232224ea8461ed07636931e65fee7b063d0ef49f471c04e2fd45b2fff3fb6923314e26045259640335c417ed14a0799553dda3eff5065ec5606303c42309221881c7dea17227da4003a6e396e308ca77da3b4b743a1c2771252c2fa8caad98c9985f9157dbcdd355d3a70b2edeca9682e4bba3e7da24fdd472017b89103e61ab9a4bcc9ab75bd28f7fad29327bf710b3b4759bb76983b003a0907794ad73194d14a70769ce6731b0ae21d565b53780275b6ac42c650d47f570331c7ac57fc75390d3b232eece8277a7c8453b5f28206ff1026879981f2ac83a0d4760554401e671a110de6c03cc104927c55de7254311680af4fb5d36b2199e1348f6fa50877d6cb163dd5f70381f2418f20d145d8ed5df2714cdcda59a4362b0c544ee1af01ac41bc15729951b1e53f3a135fe9011d3e938b08c50d53da259e2ab19b97a47b96d6b7fd559704ac9d1d8a223cbb88c9f77fa563c0c66524c260f0ff54471acae87e71c0507b14edf02bd42993966eea6b2f5d36db12b7fec7a63b80a13651822867db1f046081ad2cf3676b88fa2ef700b8c865a7dedcdee739795853584b74c3f59868daf79e81bf70afed8ea1ce689d67090a32dfe351fd0bdaf60b3903d7ff7c149134a95b2ddf1d63e0f89dfe0b710accf2ca3c37647973532338c59d32e562d7c55573277c1fab09d57a452f4214131178683533fbfe7726276903aacd579d36c6679187b1d22dda32fc5302b91244840a54c258e4d416deb0d20f96b214c335608db6b725175d8517f35f9d6b466c751a1253b20051863a02f2e0c073830cb7de27c96c4ccb196e079edc817ebdf70972b917b6a07c6a431567b99c6072b102e5103a22908683f60bb4fb72538ae3a3768de85f9fc682e67c6aea0e000027100000000011e1a300000000000bebc20024342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d3000000002b40420f000000000022002091a342be9a9171a40f83766fbf34a0be03b79675dd20c14e13d91651f7f8273e47522103a1bd05e59ffa63f010cee2ff6848730c6f718da57aef6a5df381683d409a815e2103d1a9a2a574585f60abaaa33826488f9eb8d53ca76693bfa69b42ee2bc8ebe9c552aed30200000001342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d300000000007d30f88004400d030000000000160014dab249c7d3b8d826d45244f609bb90f72e691daa400d030000000000220020d24765dcd888e08581c2add26ddfaa6f3ef06b56578373c59915bcc25aa0c6ee286a04000000000022002054d7877901aedaf54d84b20a4233107c2fdab9ff637106d44097e69a813d394ee093040000000000220020039e4d3b414381fb8fda640b122e604b20aa6f64e87607dd9354cdc636cb483d1b17b4207914784cfd82df8f93f15defff862cede27811ce4c59df98e86fd57e5b5105921e842a02a47ee6ddb313b37bc0b6706fe3011e2dd2d82066c85ab11a8d7b4e47000202241ad33e0af0717b31e19b50fd6b0469a42807eec1a080ad29cd56d04a4de54313010000002b400d030000000000220020d24765dcd888e08581c2add26ddfaa6f3ef06b56578373c59915bcc25aa0c6ee8576a91474e49ec772064db47a555b032479b20992beeefe8763ac672102cd66c9b36fdd627754f492f15bc2387f44fd70bc4c9ccdb08df37e25250a5b197c820120876475527c2103d80a13db0dffe34a9b1ff383306a52aed0a40a99ce1c34b113ca7467327f608452ae67a9142a784c1850f79298eab62c5c7709a5d468f5522788ac68685e02000000011ad33e0af0717b31e19b50fd6b0469a42807eec1a080ad29cd56d04a4de54313010000000000000000015af302000000000022002054d7877901aedaf54d84b20a4233107c2fdab9ff637106d44097e69a813d394e101b06000000000000000001f8c46e9fa497a4f9f4fdf422840d264f67178defb43320b83c1d9825a6c152995775652ba3689025f4841f165acbd16732ad88629429b3811d71c7b03adf254402241ad33e0af0717b31e19b50fd6b0469a42807eec1a080ad29cd56d04a4de54313030000002be093040000000000220020039e4d3b414381fb8fda640b122e604b20aa6f64e87607dd9354cdc636cb483d8576a91474e49ec772064db47a555b032479b20992beeefe8763ac672102cd66c9b36fdd627754f492f15bc2387f44fd70bc4c9ccdb08df37e25250a5b197c820120876475527c2103d80a13db0dffe34a9b1ff383306a52aed0a40a99ce1c34b113ca7467327f608452ae67a91448d436723875e511f3a4fc540ca63c91637e926388ac68685e02000000011ad33e0af0717b31e19b50fd6b0469a42807eec1a080ad29cd56d04a4de5431303000000000000000001fa7904000000000022002054d7877901aedaf54d84b20a4233107c2fdab9ff637106d44097e69a813d394e101b06000000000000000000ce718c1999b28ddd1207bcdd6789541ec2f405f775efb096bd896bb237b7f5c17543684f99cb53efeade77bc386997e7b5361418c510ed442700cee38c36f18900000000000000010002fffd05aa342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d300000000000000000000000011e1a300d91ec390338376481ff3aea604bf2106cf380d78e946e6a4fc0ad72dc0dec51b00061b100002909a15094ba406ca280bce032eab4d25eae4a9e8b51ff65574b6de2033a292cb1bc6ef576207f4b585273048502efad58af480f08dabcbff1a9642eb3b08811eb4417ac14bf6e5e3883d55ba3b7fdaf27e5ebac16ce63d183b2521867f6cedcf55692f1490da9bc655e38281a26150c44d56e02013faf1cdb2457bec4830e67c10ff0d731798d9e383cc3ce9ba21bddd8971e1d206c54c22317d75411b73abb08c9af348cca2aa2f17232b008aaef4bedb98c426041d3698924d089b59c639396ba38d2ba6d59ea2b0ee8ec9f548deced719e9aae73854d8b6c10c78890999ae09b912a8ae98d3513119bfa0ffdd3037cf5690122020f2c0d01b282ad0cbe345bd31cf7e55d8e78c61abfa62f97d2a095e2256c6569d3e6b5652b365d935d16451f2cf7df04e99e675d9eb649b583fc5d810dae3860001e667b9b78733b3ed6ca5058e6806ca4eb493c5c9a53b0ad78b9ea2091d6e94130afb1d79ce8e274a93d748af9d4ee7ae5b1c06cf1f65507bc79db22c30ae6df93a16c279e4beaf50a0e4e87449e9c830fe9b3877b7332b0632743d4e6267ffa404a35d74d79c5d724bdc9aaaa0423a157fb269b916b0022fd52bb0b2702e6abcc7d9d39d7f69a09a9814b3110cc72574fed031bbc0fd5a03fcee1181076369e76c183b2833385a38dd10773fe3228cb18aa731674a574d310a76052cf89c80077aa89380fcfdeda00508f79261c1e1886240de3bbc343eb84ea7879de24f7dbd0b1527201131bcaf5621e49c69ceec36280f9db6d27161c1676c9b11597d4bd8f10032a964fc1d1afcea594237f3408b184b16eba952778252bc6debc30e6e595c7ebbc2af0c00456ca771d024a56d9f074ca5a7f78f1ef107aa42c2a6426f8dbb2ea8962e2128cfc15161512d2e923e2879635c8ba80bc17f92d09abfae4e08a7f34decc1acd4aa4cc08181017bf248321558a8c4d1a45b92b96274dd9f336eb45d8af6d13147be3a250c17106ec6729e0cffc1af5255352296477dea870426aa82e7af3cc07156b65f8d98b482985618b69b99ee3871240db751923dbeddea6e36f5c3f0599300973fe064ccf4f15cadb7372aaab5b300674f5bf28ce905ab411f5605fba7075ed4a6b08dca3ed5867dc32e491c64e7f09ff4095081e0731cbfc53fa42c33e79bd1a26d8e9f8c5b546b07bd1b300f1f357919e955bded1f987401f4da1a453282b6978ff3bfd13b280f6253dd968cb4e7741a15faf7b4c70dbd9eab6461ca3d3a576410213bc4e144a63685488afeeb7857af4ef83e73c88b17798616a9ccbd603d61ec8f4dbbdd5fea5ca748cf40c38fec50d4eebf1e5b57fd32500baa892da24349598c3125162b2ea0ea049ea9aacdfa848f41fdf7f9eb983776bac58ddf762d131196ab18774349a5eca2fc5b51b60d7aceae1321c1decd462f9c7dbbd820399f71a3c3ccbb30a29f76cd8e94243e400c4dc6e6d32b6f94155a21eb89b6b4c0fd1660bd98509d11b3a45fb257ae1e3c5ebae7bae038200c0f7f2d4ee744c3f2d9007d6fb282b0254ccd71eae5b4c4996b52edb2f2f4120356096c81e42168ee43d98bd630b0af01c270db3fb680cd931d388e1c1260126707548ed1f27006a64db7885ac7500ce020f6349a1abf59fb3ca4bc5bdcbd19b7a0cfe82aeea62f0373d5c16002cd9adcb3ef5e0c862e2fda972530b399b0f6365f4edbc36a32bd1766763104aca34450f278418211d62ff3fff2d0de7f516028011e5681ee892288835a3ec6d0d353f8bc7168086a0eed30d5e81d8a51f7debbb2290dc1a1745e0fc2c08778d11ccb78dc7c98a8b4a4b28fd8decda3a2063ad73c23c112d609b6903613c5ad8e178c90fed2ebd10b176b17c9c2dfc630ef744ac289b437ad229b77a393c6b05c10f36ba2f80482ed6e26b3d9c34d22fffd05aa342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d30000000000000001000000000bebc20092ebfcedc573c52ba840ff42bb322419ed390dc845c2fe80636b6b82cf41210000061b100002f211b0d97e6c7f7fb800dbb8d1c7536ad7ef284c40a85fc7316b771bb525c91f7e1d4bba90df0cf0d12c19906e4ae0a1b83954632b59f5f499dedaeba19d75c3bc244ccb57089abeaf29c7d73d67ae822aea2ed4d85d27dc65042589e8172aa3b66d928d7e35f027d96bf23e656701bdf13651e25bed745fef014fdec3faaba4795638299975d3cdc8d2c5b19e2e411e6e4f7b3cede7e269c8902306d25b1027e99736489fde667f4eaf5726349851986ff15a9e967385e080079a14c0a9c3001bbce5da720dcf739e67801cfe2a565b24f5515f8d8889a6d2dc0b51fae4facb72904ba8c1949550332cd8b9095655da72a9815537a80efd204d497af47fd18ef0f6d0639424eb81dab0e34f228aed9406d23773874b4c41d9a21dcaf632419e459baaca5f338f0f9718c89fb72108788d32aeb07e2eb343c45891958779e75fe0039eddaf7e5c4aa8ac2aee9928c68dc529d415780d8e14adcecc91b142b238e7657ef1dc6b6e9843bb5fbe8d04564307e515d88b34105b90b3fa9ed91025297a373507cba86160ba5b7b569948c95fd483b28b8970bebd5e17fcad76c6ed64615cc2d7297994483d94c010a210ad3602b7f359d7d1391b97968f9eaa70de83ea1168fdb05190a6e9fc7c984213da3e2a6672d09704d8e29e2aa9349c9ae44eca3dc0522c769887cbaa0926c5bad64eaf7c22399f7abcc01505d921cce15f4613406956715fe3030ab5c74506d1acc30649b596931316a8e210a368d758d7c1f406f5888499f8317a9ba629dfe85453b4413107796bde15636e6f628078863c0009db7d97cfadc2bfdcdfed237debac33dc525f25865663bc7a812099102fe9c65c8a37b179337141c8d76f365824b0db54b0b18d6c88b21406a1e35061fb4f5ef8a280f9c2ac2ada9eea8cb365d346c5e9eaa56728584aa71c4296a1c11d76f03351a91a030ae6df1da008a5d0f92207b8ca22f335b5a347707ef2500119597d5b92c559f477d8405f1d0dfd790c99ca5a7b4aeac232224ea8461ed07636931e65fee7b063d0ef49f471c04e2fd45b2fff3fb6923314e26045259640335c417ed14a0799553dda3eff5065ec5606303c42309221881c7dea17227da4003a6e396e308ca77da3b4b743a1c2771252c2fa8caad98c9985f9157dbcdd355d3a70b2edeca9682e4bba3e7da24fdd472017b89103e61ab9a4bcc9ab75bd28f7fad29327bf710b3b4759bb76983b003a0907794ad73194d14a70769ce6731b0ae21d565b53780275b6ac42c650d47f570331c7ac57fc75390d3b232eece8277a7c8453b5f28206ff1026879981f2ac83a0d4760554401e671a110de6c03cc104927c55de7254311680af4fb5d36b2199e1348f6fa50877d6cb163dd5f70381f2418f20d145d8ed5df2714cdcda59a4362b0c544ee1af01ac41bc15729951b1e53f3a135fe9011d3e938b08c50d53da259e2ab19b97a47b96d6b7fd559704ac9d1d8a223cbb88c9f77fa563c0c66524c260f0ff54471acae87e71c0507b14edf02bd42993966eea6b2f5d36db12b7fec7a63b80a13651822867db1f046081ad2cf3676b88fa2ef700b8c865a7dedcdee739795853584b74c3f59868daf79e81bf70afed8ea1ce689d67090a32dfe351fd0bdaf60b3903d7ff7c149134a95b2ddf1d63e0f89dfe0b710accf2ca3c37647973532338c59d32e562d7c55573277c1fab09d57a452f4214131178683533fbfe7726276903aacd579d36c6679187b1d22dda32fc5302b91244840a54c258e4d416deb0d20f96b214c335608db6b725175d8517f35f9d6b466c751a1253b20051863a02f2e0c073830cb7de27c96c4ccb196e079edc817ebdf70972b917b6a07c6a431567b99c6072b102e5103a22908683f60bb4fb72538ae3a3768de85f9fc682e67c6aea0e00002710000000000bebc2000000000011e1a300306acd0b21100f755a6d193a819042fde1b4c3839598e730905dfa7e6ef699220240a9cccdb58d887b42ccadeee5704030acd52bd9c7759ba01f47f0995531ca360000000000000000000000000000000000000002000000000000000000020000000000000000000334c7b350311d40b3b422e07f3b7759b400000000000000010003e3dd409b342046e7b410cc380c9a09c2ff03cdeeaf422678a9eac407da8f811a402718083016f88d5404f5508054fe25acb824342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d3000000002b40420f000000000022002091a342be9a9171a40f83766fbf34a0be03b79675dd20c14e13d91651f7f8273e47522103a1bd05e59ffa63f010cee2ff6848730c6f718da57aef6a5df381683d409a815e2103d1a9a2a574585f60abaaa33826488f9eb8d53ca76693bfa69b42ee2bc8ebe9c552ae000100400000ffffffffffff00204cec06f1f1496c01cd4840cddff19b47c24b7daa478bcaea862c6d11fcc9fff180007fffffffffff8038342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d300160014d0cd80743458194e5f86d9a74592765442fd15bb38342b8fd35a1f3384c6db37723ecc766b672f61b4b0f2e7d5d81cf1e451b584d30016001483366b494906052362a88e967304296937926cd1" val decoded1 = channelDataCodec.decode(oldBin.bits).require.value - assert(decoded1.asInstanceOf[DATA_SHUTDOWN].closingFeerates === None) + assert(decoded1.asInstanceOf[DATA_SHUTDOWN].closingFeerates == None) val newBin = channelDataCodec.encode(decoded1).require.bytes // make sure that encoding used the new codec assert(newBin.startsWith(hex"0008")) val decoded2 = channelDataCodec.decode(newBin.bits).require.value - assert(decoded1 === decoded2) + assert(decoded1 == decoded2) } test("backwards compatibility with legacy claim-htlc-success transactions") { @@ -183,7 +183,7 @@ class ChannelCodecs3Spec extends AnyFunSuite { val legacyClaimHtlcSuccess = { val claimHtlcSuccessTx1 = txWithInputInfoCodec.decode(oldTxWithInputInfoCodecBin.bits).require.value val claimHtlcSuccessTx2 = claimHtlcTxCodec.decode(oldClaimHtlcTxBin.bits).require.value - assert(claimHtlcSuccessTx1 === claimHtlcSuccessTx2) + assert(claimHtlcSuccessTx1 == claimHtlcSuccessTx2) assert(claimHtlcSuccessTx1.isInstanceOf[LegacyClaimHtlcSuccessTx]) claimHtlcSuccessTx1.asInstanceOf[LegacyClaimHtlcSuccessTx] } @@ -197,9 +197,9 @@ class ChannelCodecs3Spec extends AnyFunSuite { // And decode new data that contains a payment hash. val decoded1 = txWithInputInfoCodec.decode(txWithInputInfoCodecBin.bits).require.value - assert(claimHtlcSuccess === decoded1) + assert(claimHtlcSuccess == decoded1) val decoded2 = claimHtlcTxCodec.decode(claimHtlcTxBin.bits).require.value - assert(claimHtlcSuccess === decoded2) + assert(claimHtlcSuccess == decoded2) } test("backwards compatibility with transactions missing a confirmation target") { @@ -207,46 +207,46 @@ class ChannelCodecs3Spec extends AnyFunSuite { val oldAnchorTxBin = hex"0011 24bd0be30e31c748c7afdde7d2c527d711fadf88500971a4a1136bca375dba07b8000000002b4a0100000000000022002036c067df8952dbcd5db347e7c152ca3fa4514f2072d27867837b1c2d319a7e01282103cc89f1459b5201cda08e08c6fb7b1968c54e8172c555896da27c6fdc10522ceeac736460b268330200000001bd0be30e31c748c7afdde7d2c527d711fadf88500971a4a1136bca375dba07b80000000000000000000000000000" val oldAnchorTx = txWithInputInfoCodec.decode(oldAnchorTxBin.bits).require.value assert(oldAnchorTx.isInstanceOf[ClaimLocalAnchorOutputTx]) - assert(oldAnchorTx.asInstanceOf[ClaimLocalAnchorOutputTx].confirmBefore === BlockHeight(0)) + assert(oldAnchorTx.asInstanceOf[ClaimLocalAnchorOutputTx].confirmBefore == BlockHeight(0)) val anchorTx = oldAnchorTx.asInstanceOf[ClaimLocalAnchorOutputTx].copy(confirmBefore = BlockHeight(1105)) val anchorTx2 = txWithInputInfoCodec.decode(txWithInputInfoCodec.encode(anchorTx).require).require.value - assert(anchorTx === anchorTx2) + assert(anchorTx == anchorTx2) } { val oldHtlcSuccessTxBin = hex"0002 24f5580de0577271dce09d2de26e19ec58bf2373b0171473291a8f8be9b04fb289000000002bb0ad010000000000220020462cf8912ffc5f27764c109bed188950500011a2837ff8b9c8f9a39cffa395a58b76a91406b0950d9feded82239b3e6c9082308900f389de8763ac672102d65aa07658a7214ff129f91a1a22ade2ea4d1b07cc14b2f85a2842c34240836f7c8201208763a914c461c897e2165c7e44e14850dfcfd68f99127aed88527c21033c8d41cfbe1511a909b63fed68e75a29c3ce30418c39bbb8294c8b36c6a6c16a52ae677503101b06b175ac6868fd01a002000000000101f5580de0577271dce09d2de26e19ec58bf2373b0171473291a8f8be9b04fb289000000000000000000013a920100000000002200208742b16c9fd4e74854dcd84322dd1de06f7993fe627fd2ca0be4b996a936d56b050047304402201b4527c8f420852550af00bbd9149db9b31adcb7e1f127766e75e1e01746df0302202a57bb1e274ed7d3e8dbe5f205de721a23092c1e2ce2135f4750f18f6c0b51b001483045022100b6df309c8e5746a077b1f7c2f299528e164946bd514a5049475af7f5665805da0220392ae877112a3c52f74d190b354b4f5c020da9c1a71a7a08ced0a5363e795a27012017ea8f5afde8f708258d5669e1bbd454e82ddca8c6c480ec5302b4b1e8051d3d8b76a91406b0950d9feded82239b3e6c9082308900f389de8763ac672102d65aa07658a7214ff129f91a1a22ade2ea4d1b07cc14b2f85a2842c34240836f7c8201208763a914c461c897e2165c7e44e14850dfcfd68f99127aed88527c21033c8d41cfbe1511a909b63fed68e75a29c3ce30418c39bbb8294c8b36c6a6c16a52ae677503101b06b175ac686800000000dc7002a387673f17ebaf08545ccec712a9b6914813cdb83b4270932294f20f660000000000000000" val oldHtlcSuccessTx = txWithInputInfoCodec.decode(oldHtlcSuccessTxBin.bits).require.value assert(oldHtlcSuccessTx.isInstanceOf[HtlcSuccessTx]) - assert(oldHtlcSuccessTx.asInstanceOf[HtlcSuccessTx].confirmBefore === BlockHeight(0)) + assert(oldHtlcSuccessTx.asInstanceOf[HtlcSuccessTx].confirmBefore == BlockHeight(0)) val htlcSuccessTx = oldHtlcSuccessTx.asInstanceOf[HtlcSuccessTx].copy(confirmBefore = BlockHeight(1105)) val htlcSuccessTx2 = txWithInputInfoCodec.decode(txWithInputInfoCodec.encode(htlcSuccessTx).require).require.value - assert(htlcSuccessTx === htlcSuccessTx2) + assert(htlcSuccessTx == htlcSuccessTx2) } { val oldHtlcTimeoutTxBin = hex"0003 248f0619a4b2a351977b3e5b0ddd700482e1d697d40deea2dd7356df99345d51d0000000002b50c300000000000022002005ff644937d7f5f32ec194424f551371e8d4bcf2cda3e1096cdd2fe88687fc408576a914c98707b6420ef3454f3bd10d663adcc04452baea8763ac672102fb20469287c8ade948011bd001440d74633d5e1a98574e4783dd38b76509d8f67c820120876475527c210279d3a1c2086a0968404a0160c8f8c6f88c0ce7184022bb7406f98fdb503ea51452ae67a9140550b2b1621e788d795fe3ae308e7dec06a6a1e088ac6868fd0179020000000001018f0619a4b2a351977b3e5b0ddd700482e1d697d40deea2dd7356df99345d51d0000000000000000000016aa9000000000000220020c980a1573ce6dc6a1bb8a1d60ecffdf2f0a7aa983c49786a2ab1ba8f0cd74a76050047304402200d2b631fb0e5a7f406f3de2b36fe3c0ab3337fe98f114dadf38de8f5548e87eb02203ad7c385c7cf62ac17ec15329dee071ee2c479aceb34a14d700dfeba80008574014730440220653b4ff490b03de06a9053aa7ab0b30e85c484c76900c586db65f7308f38ad86022019ac12ffb127e4a17a01dc6db730d3eccea837d2dc85a0275bdea8b393a2f11d01008576a914c98707b6420ef3454f3bd10d663adcc04452baea8763ac672102fb20469287c8ade948011bd001440d74633d5e1a98574e4783dd38b76509d8f67c820120876475527c210279d3a1c2086a0968404a0160c8f8c6f88c0ce7184022bb7406f98fdb503ea51452ae67a9140550b2b1621e788d795fe3ae308e7dec06a6a1e088ac6868101b06000000000000000003" val oldHtlcTimeoutTx = txWithInputInfoCodec.decode(oldHtlcTimeoutTxBin.bits).require.value assert(oldHtlcTimeoutTx.isInstanceOf[HtlcTimeoutTx]) - assert(oldHtlcTimeoutTx.asInstanceOf[HtlcTimeoutTx].confirmBefore === BlockHeight(0)) + assert(oldHtlcTimeoutTx.asInstanceOf[HtlcTimeoutTx].confirmBefore == BlockHeight(0)) val htlcTimeoutTx = oldHtlcTimeoutTx.asInstanceOf[HtlcTimeoutTx].copy(confirmBefore = BlockHeight(1105)) val htlcTimeoutTx2 = txWithInputInfoCodec.decode(txWithInputInfoCodec.encode(htlcTimeoutTx).require).require.value - assert(htlcTimeoutTx === htlcTimeoutTx2) + assert(htlcTimeoutTx == htlcTimeoutTx2) } { val oldClaimHtlcSuccessTxBin = hex"0016 24e75b5236d1cdd482a6f540d5f08b9aa27b74a9ecae6e2622a67110b3ee1b3d89000000002bb0ad01000000000022002063e22369052a2bad9eb124737742690b8d1aba7693869d041da16443e2973e638576a91494957f4639ebc6f8a30e126552aff8429174dfb18763ac672102e1aa04ff55771238012edb958e6e0525af0415a01d52dd8d5f69fb391e586adc7c820120876475527c2102384e785d34b3b1fe35d3c093a750b234fbc79d8316c149e7845929f628a5baa052ae67a9145e3be49c9ace2d9eab11dc5fc29e40cd4148262e88ac6868fd014502000000000101e75b5236d1cdd482a6f540d5f08b9aa27b74a9ecae6e2622a67110b3ee1b3d890000000000000000000162970100000000001600140262586eef1a2c8f47ebc139a2733123d09e315603483045022100898f6b51361f044c8c54468dcb1b9decd75edcc1b69b62e584059b512eb075900220675f8b23aa402bb7d5bfdefbac4074088f82bd34d09b34c651c0dff48e6967930120efb38d645311af59c028cd8a9bf8ee21ff9e7c1a1cff1a0398a0315280247ac38576a91494957f4639ebc6f8a30e126552aff8429174dfb18763ac672102e1aa04ff55771238012edb958e6e0525af0415a01d52dd8d5f69fb391e586adc7c820120876475527c2102384e785d34b3b1fe35d3c093a750b234fbc79d8316c149e7845929f628a5baa052ae67a9145e3be49c9ace2d9eab11dc5fc29e40cd4148262e88ac686800000000ad02394dd18774f6f403f783afb518b6c69a89d531f718b29868ddca3e7905020000000000000000" val oldClaimHtlcSuccessTx = txWithInputInfoCodec.decode(oldClaimHtlcSuccessTxBin.bits).require.value assert(oldClaimHtlcSuccessTx.isInstanceOf[ClaimHtlcSuccessTx]) - assert(oldClaimHtlcSuccessTx.asInstanceOf[ClaimHtlcSuccessTx].confirmBefore === BlockHeight(0)) + assert(oldClaimHtlcSuccessTx.asInstanceOf[ClaimHtlcSuccessTx].confirmBefore == BlockHeight(0)) val claimHtlcSuccessTx = oldClaimHtlcSuccessTx.asInstanceOf[ClaimHtlcSuccessTx].copy(confirmBefore = BlockHeight(1105)) val claimHtlcSuccessTx2 = txWithInputInfoCodec.decode(txWithInputInfoCodec.encode(claimHtlcSuccessTx).require).require.value - assert(claimHtlcSuccessTx === claimHtlcSuccessTx2) + assert(claimHtlcSuccessTx == claimHtlcSuccessTx2) } { val oldClaimHtlcTimeoutTxBin = hex"0005 24df6aa4cd4e8877e4b3a363d6180951036d6f18ef214dabd50a6c05a60077d4d8000000002b50c30000000000002200205db892d76fb358ed508ec09c77b5a184cd9de3aa3e74a025a5c5d3f7adc221f78b76a914e0c241e0656088953f84475cbe5c70ded12e05b58763ac6721028876f3e23b21e07f889f10fc2aa0875b96021359a06d0b7f52a79fc284f6b2837c8201208763a9144ae5c96e8b7495fd35a5ca5681aa7c8f4ab6bc9b88527c2102b4d398ee7a42e87012de5a76832d9ebfa8532ef267490a7f3fe75b2c2e18cc9152ae677503981a06b175ac6868fd012b02000000000101df6aa4cd4e8877e4b3a363d6180951036d6f18ef214dabd50a6c05a60077d4d80000000000000000000106ae0000000000001600142b8e221121004b248f6551a0c6fb8ce219f4997e03483045022100ecdb8179f92c097594844756ac2bd7948f1c44ae74b54dfda86971800e59bf980220125edbe563f24cde15fa1fa25f4eac7cb938a3ace6f9329eb487938005c7621501008b76a914e0c241e0656088953f84475cbe5c70ded12e05b58763ac6721028876f3e23b21e07f889f10fc2aa0875b96021359a06d0b7f52a79fc284f6b2837c8201208763a9144ae5c96e8b7495fd35a5ca5681aa7c8f4ab6bc9b88527c2102b4d398ee7a42e87012de5a76832d9ebfa8532ef267490a7f3fe75b2c2e18cc9152ae677503981a06b175ac6868981a06000000000000000003" val oldClaimHtlcTimeoutTx = txWithInputInfoCodec.decode(oldClaimHtlcTimeoutTxBin.bits).require.value assert(oldClaimHtlcTimeoutTx.isInstanceOf[ClaimHtlcTimeoutTx]) - assert(oldClaimHtlcTimeoutTx.asInstanceOf[ClaimHtlcTimeoutTx].confirmBefore === BlockHeight(0)) + assert(oldClaimHtlcTimeoutTx.asInstanceOf[ClaimHtlcTimeoutTx].confirmBefore == BlockHeight(0)) val claimHtlcTimeoutTx = oldClaimHtlcTimeoutTx.asInstanceOf[ClaimHtlcTimeoutTx].copy(confirmBefore = BlockHeight(1105)) val claimHtlcTimeoutTx2 = txWithInputInfoCodec.decode(txWithInputInfoCodec.encode(claimHtlcTimeoutTx).require).require.value - assert(claimHtlcTimeoutTx === claimHtlcTimeoutTx2) + assert(claimHtlcTimeoutTx == claimHtlcTimeoutTx2) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/CommonCodecsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/CommonCodecsSpec.scala index dbc6b4e11e..feeef78e46 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/CommonCodecsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/CommonCodecsSpec.scala @@ -47,9 +47,9 @@ class CommonCodecsSpec extends AnyFunSuite { for ((uint, ref) <- expected) { val encoded = uint64.encode(uint).require - assert(ref === encoded) + assert(ref == encoded) val decoded = uint64.decode(encoded).require.value - assert(uint === decoded) + assert(uint == decoded) } } @@ -60,7 +60,7 @@ class CommonCodecsSpec extends AnyFunSuite { UInt64(hex"efffffffffffffff"), UInt64(hex"effffffffffffffe") ) - assert(refs.forall(value => uint64.decode(uint64.encode(value).require).require.value === value)) + assert(refs.forall(value => uint64.decode(uint64.encode(value).require).require.value == value)) } test("encode/decode with varint codec") { @@ -78,9 +78,9 @@ class CommonCodecsSpec extends AnyFunSuite { for ((uint, ref) <- expected) { val encoded = varint.encode(uint).require - assert(ref === encoded, ref) + assert(ref == encoded, ref) val decoded = varint.decode(encoded).require.value - assert(uint === decoded, uint) + assert(uint == decoded, uint) } } @@ -121,9 +121,9 @@ class CommonCodecsSpec extends AnyFunSuite { for ((long, ref) <- expected) { val encoded = varintoverflow.encode(long).require - assert(ref === encoded, ref) + assert(ref == encoded, ref) val decoded = varintoverflow.decode(encoded).require.value - assert(long === decoded, long) + assert(long == decoded, long) } } @@ -144,21 +144,21 @@ class CommonCodecsSpec extends AnyFunSuite { bin"00000001" -> ChannelFlags(announceChannel = true), ) testCases.foreach { case (bin, obj) => - assert(channelflags.decode(bin).require === DecodeResult(obj, BitVector.empty)) - assert(channelflags.encode(obj).require === bin) + assert(channelflags.decode(bin).require == DecodeResult(obj, BitVector.empty)) + assert(channelflags.encode(obj).require == bin) } // BOLT 2: The receiving node MUST [...] ignore undefined bits in channel_flags. - assert(channelflags.decode(bin"11111111").require === DecodeResult(ChannelFlags(announceChannel = true), BitVector.empty)) - assert(channelflags.decode(bin"11111110").require === DecodeResult(ChannelFlags(announceChannel = false), BitVector.empty)) + assert(channelflags.decode(bin"11111111").require == DecodeResult(ChannelFlags(announceChannel = true), BitVector.empty)) + assert(channelflags.decode(bin"11111110").require == DecodeResult(ChannelFlags(announceChannel = false), BitVector.empty)) } test("encode/decode with rgb codec") { val color = Color(47.toByte, 255.toByte, 142.toByte) val bin = rgb.encode(color).require - assert(bin === hex"2f ff 8e".toBitVector) + assert(bin == hex"2f ff 8e".toBitVector) val color2 = rgb.decode(bin).require.value - assert(color === color2) + assert(color == color2) } test("encode/decode all kind of IPv6 addresses with ipv6address codec") { @@ -167,7 +167,7 @@ class CommonCodecsSpec extends AnyFunSuite { val bin = hex"00000000000000000000ffffae8a0b08".toBitVector val ipv6 = Inet6Address.getByAddress(null, bin.toByteArray, null) val bin2 = ipv6address.encode(ipv6).require - assert(bin === bin2) + assert(bin == bin2) } { @@ -175,7 +175,7 @@ class CommonCodecsSpec extends AnyFunSuite { val ipv6 = InetAddresses.forString("1080:0:0:0:8:800:200C:417A").asInstanceOf[Inet6Address] val bin = ipv6address.encode(ipv6).require val ipv62 = ipv6address.decode(bin).require.value - assert(ipv6 === ipv62) + assert(ipv6 == ipv62) } } @@ -184,31 +184,31 @@ class CommonCodecsSpec extends AnyFunSuite { val ipv4addr = InetAddress.getByAddress(Array[Byte](192.toByte, 168.toByte, 1.toByte, 42.toByte)).asInstanceOf[Inet4Address] val nodeaddr = IPv4(ipv4addr, 4231) val bin = nodeaddress.encode(nodeaddr).require - assert(bin === hex"01 C0 A8 01 2A 10 87".toBitVector) + assert(bin == hex"01 C0 A8 01 2A 10 87".toBitVector) val nodeaddr2 = nodeaddress.decode(bin).require.value - assert(nodeaddr === nodeaddr2) + assert(nodeaddr == nodeaddr2) } { val ipv6addr = InetAddress.getByAddress(hex"2001 0db8 0000 85a3 0000 0000 ac1f 8001".toArray).asInstanceOf[Inet6Address] val nodeaddr = IPv6(ipv6addr, 4231) val bin = nodeaddress.encode(nodeaddr).require - assert(bin === hex"02 2001 0db8 0000 85a3 0000 0000 ac1f 8001 1087".toBitVector) + assert(bin == hex"02 2001 0db8 0000 85a3 0000 0000 ac1f 8001 1087".toBitVector) val nodeaddr2 = nodeaddress.decode(bin).require.value - assert(nodeaddr === nodeaddr2) + assert(nodeaddr == nodeaddr2) } { val nodeaddr = Tor2("z4zif3fy7fe7bpg3", 4231) val bin = nodeaddress.encode(nodeaddr).require - assert(bin === hex"03 cf3282ecb8f949f0bcdb 1087".toBitVector) + assert(bin == hex"03 cf3282ecb8f949f0bcdb 1087".toBitVector) val nodeaddr2 = nodeaddress.decode(bin).require.value - assert(nodeaddr === nodeaddr2) + assert(nodeaddr == nodeaddr2) } { val nodeaddr = Tor3("mrl2d3ilhctt2vw4qzvmz3etzjvpnc6dczliq5chrxetthgbuczuggyd", 4231) val bin = nodeaddress.encode(nodeaddr).require - assert(bin === hex"04 6457a1ed0b38a73d56dc866accec93ca6af68bc316568874478dc9399cc1a0b3431b03 1087".toBitVector) + assert(bin == hex"04 6457a1ed0b38a73d56dc866accec93ca6af68bc316568874478dc9399cc1a0b3431b03 1087".toBitVector) val nodeaddr2 = nodeaddress.decode(bin).require.value - assert(nodeaddr === nodeaddr2) + assert(nodeaddr == nodeaddr2) } } @@ -229,8 +229,8 @@ class CommonCodecsSpec extends AnyFunSuite { expected_opt match { case Some(expected) => val decoded = bytes32.decode(encoded.bits).require.value - assert(decoded === expected) - assert(expected.bytes === bytes32.encode(decoded).require.bytes) + assert(decoded == expected) + assert(expected.bytes == bytes32.encode(decoded).require.bytes) case None => assert(bytes32.decode(encoded.bits).isFailure) } @@ -255,8 +255,8 @@ class CommonCodecsSpec extends AnyFunSuite { expected_opt match { case Some(expected) => val decoded = bytes64.decode(encoded.bits).require.value - assert(decoded === expected) - assert(expected.bytes === bytes64.encode(decoded).require.bytes) + assert(decoded == expected) + assert(expected.bytes == bytes64.encode(decoded).require.bytes) case None => assert(bytes64.decode(encoded.bits).isFailure) } @@ -285,17 +285,17 @@ class CommonCodecsSpec extends AnyFunSuite { { val alias = "IRATEMONK" val bin = c.encode(alias).require - assert(bin === BitVector(alias.getBytes("UTF-8") ++ Array.fill[Byte](32 - alias.length)(0))) + assert(bin == BitVector(alias.getBytes("UTF-8") ++ Array.fill[Byte](32 - alias.length)(0))) val alias2 = c.decode(bin).require.value - assert(alias === alias2) + assert(alias == alias2) } { val alias = "this-alias-is-exactly-32-B-long." val bin = c.encode(alias).require - assert(bin === BitVector(alias.getBytes("UTF-8") ++ Array.fill[Byte](32 - alias.length)(0))) + assert(bin == BitVector(alias.getBytes("UTF-8") ++ Array.fill[Byte](32 - alias.length)(0))) val alias2 = c.decode(bin).require.value - assert(alias === alias2) + assert(alias == alias2) } { @@ -314,17 +314,17 @@ class CommonCodecsSpec extends AnyFunSuite { for ((codec, expected, bin) <- testCases) { val macCodec = prependmac(codec, mac) val decoded = macCodec.decode(bin.toBitVector).require.value - assert(decoded === expected) + assert(decoded == expected) val encoded = macCodec.encode(expected).require.toByteVector - assert(encoded === bin) + assert(encoded == bin) } } test("backward compatibility on feerate codec") { val value = 123456 val feerate = FeeratePerKw(value sat) - assert(feeratePerKw.decode(uint32.encode(value).require).require === DecodeResult(feerate, BitVector.empty)) + assert(feeratePerKw.decode(uint32.encode(value).require).require == DecodeResult(feerate, BitVector.empty)) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/ExtendedQueriesCodecsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/ExtendedQueriesCodecsSpec.scala index 342ae09b36..b405869f1e 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/ExtendedQueriesCodecsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/ExtendedQueriesCodecsSpec.scala @@ -32,7 +32,7 @@ class ExtendedQueriesCodecsSpec extends AnyFunSuite { val ids = EncodedShortChannelIds(EncodingType.UNCOMPRESSED, List(ShortChannelId(142), ShortChannelId(15465), ShortChannelId(4564676))) val encoded = encodedShortChannelIdsCodec.encode(ids).require val decoded = encodedShortChannelIdsCodec.decode(encoded).require.value - assert(decoded === ids) + assert(decoded == ids) } { @@ -40,25 +40,25 @@ class ExtendedQueriesCodecsSpec extends AnyFunSuite { val ids = EncodedShortChannelIds(EncodingType.COMPRESSED_ZLIB, List(ShortChannelId(142), ShortChannelId(15465), ShortChannelId(4564676))) val encoded = encodedShortChannelIdsCodec.encode(ids).require val decoded = encodedShortChannelIdsCodec.decode(encoded).require.value - assert(decoded === ids) + assert(decoded == ids) } { // encode/decode empty list with encoding 'uncompressed' val ids = EncodedShortChannelIds(EncodingType.UNCOMPRESSED, List.empty) val encoded = encodedShortChannelIdsCodec.encode(ids).require - assert(encoded.bytes === hex"00") + assert(encoded.bytes == hex"00") val decoded = encodedShortChannelIdsCodec.decode(encoded).require.value - assert(decoded === ids) + assert(decoded == ids) } { // encode/decode empty list with encoding 'zlib' val ids = EncodedShortChannelIds(EncodingType.COMPRESSED_ZLIB, List.empty) val encoded = encodedShortChannelIdsCodec.encode(ids).require - assert(encoded.bytes === hex"00") // NB: empty list is always encoded with encoding type 'uncompressed' + assert(encoded.bytes == hex"00") // NB: empty list is always encoded with encoding type 'uncompressed' val decoded = encodedShortChannelIdsCodec.decode(encoded).require.value - assert(decoded === EncodedShortChannelIds(EncodingType.UNCOMPRESSED, List.empty)) + assert(decoded == EncodedShortChannelIds(EncodingType.UNCOMPRESSED, List.empty)) } } @@ -70,7 +70,7 @@ class ExtendedQueriesCodecsSpec extends AnyFunSuite { val encoded = queryShortChannelIdsCodec.encode(query_short_channel_id).require val decoded = queryShortChannelIdsCodec.decode(encoded).require.value - assert(decoded === query_short_channel_id) + assert(decoded == query_short_channel_id) } test("encode query_short_channel_ids (with optional data)") { @@ -81,7 +81,7 @@ class ExtendedQueriesCodecsSpec extends AnyFunSuite { val encoded = queryShortChannelIdsCodec.encode(query_short_channel_id).require val decoded = queryShortChannelIdsCodec.decode(encoded).require.value - assert(decoded === query_short_channel_id) + assert(decoded == query_short_channel_id) } test("encode query_short_channel_ids (with optional data including unknown data)") { @@ -96,7 +96,7 @@ class ExtendedQueriesCodecsSpec extends AnyFunSuite { val encoded = queryShortChannelIdsCodec.encode(query_short_channel_id).require val decoded = queryShortChannelIdsCodec.decode(encoded).require.value - assert(decoded === query_short_channel_id) + assert(decoded == query_short_channel_id) } test("encode reply_channel_range (no optional data)") { @@ -109,7 +109,7 @@ class ExtendedQueriesCodecsSpec extends AnyFunSuite { val encoded = replyChannelRangeCodec.encode(replyChannelRange).require val decoded = replyChannelRangeCodec.decode(encoded).require.value - assert(decoded === replyChannelRange) + assert(decoded == replyChannelRange) } test("encode reply_channel_range (with optional timestamps)") { @@ -123,7 +123,7 @@ class ExtendedQueriesCodecsSpec extends AnyFunSuite { val encoded = replyChannelRangeCodec.encode(replyChannelRange).require val decoded = replyChannelRangeCodec.decode(encoded).require.value - assert(decoded === replyChannelRange) + assert(decoded == replyChannelRange) } test("encode reply_channel_range (with optional timestamps, checksums, and unknown data)") { @@ -143,7 +143,7 @@ class ExtendedQueriesCodecsSpec extends AnyFunSuite { val encoded = replyChannelRangeCodec.encode(replyChannelRange).require val decoded = replyChannelRangeCodec.decode(encoded).require.value - assert(decoded === replyChannelRange) + assert(decoded == replyChannelRange) } test("compute checksums correctly (CL test #1)") { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/FailureMessageCodecsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/FailureMessageCodecsSpec.scala index 70f13991de..5a2ebade3f 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/FailureMessageCodecsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/FailureMessageCodecsSpec.scala @@ -53,7 +53,7 @@ class FailureMessageCodecsSpec extends AnyFunSuite { msg => { val encoded = failureMessageCodec.encode(msg).require val decoded = failureMessageCodec.decode(encoded).require - assert(msg === decoded.value) + assert(msg == decoded.value) } } } @@ -74,8 +74,8 @@ class FailureMessageCodecsSpec extends AnyFunSuite { val decoded = failureMessageCodec.decode(bin.bits).require.value assert(decoded.isInstanceOf[FailureMessage]) assert(decoded.isInstanceOf[UnknownFailureMessage]) - assert(decoded.isInstanceOf[Node] === node) - assert(decoded.isInstanceOf[Perm] === perm) + assert(decoded.isInstanceOf[Node] == node) + assert(decoded.isInstanceOf[Perm] == perm) } } @@ -87,7 +87,7 @@ class FailureMessageCodecsSpec extends AnyFunSuite { ) for ((code, message) <- msgs) { - assert(message.code === code) + assert(message.code == code) } } @@ -100,10 +100,10 @@ class FailureMessageCodecsSpec extends AnyFunSuite { for ((expected, bin) <- testCases) { val decoded = codec.decode(bin.toBitVector).require.value - assert(decoded === expected) + assert(decoded == expected) val encoded = codec.encode(expected).require.toByteVector - assert(encoded === bin) + assert(encoded == bin) } } @@ -119,7 +119,7 @@ class FailureMessageCodecsSpec extends AnyFunSuite { ) for ((expected, bin) <- testCases) { - assert(codec.decode(bin.bits).require.value === expected) + assert(codec.decode(bin.bits).require.value == expected) } } @@ -151,10 +151,10 @@ class FailureMessageCodecsSpec extends AnyFunSuite { val ref = TemporaryChannelFailure(ChannelUpdate(ByteVector64(hex"cc3e80149073ed487c76e48e9622bf980f78267b8a34a3f61921f2d8fce6063b08e74f34a073a13f2097337e4915bb4c001f3b5c4d81e9524ed575e1f4578219"), Block.LivenetGenesisBlock.hash, ShortChannelId(0x826050004130000L), 1536275759 unixsec, ChannelUpdate.ChannelFlags(isEnabled = false, isNode1 = false), CltvExpiryDelta(14), 1000 msat, 1 msat, 1, None)) val u = failureMessageCodec.decode(tmp_channel_failure_notype.toBitVector).require.value - assert(u === ref) + assert(u == ref) val bin = ByteVector(failureMessageCodec.encode(u).require.toByteArray) - assert(bin === tmp_channel_failure_withtype) + assert(bin == tmp_channel_failure_withtype) val u2 = failureMessageCodec.decode(bin.toBitVector).require.value - assert(u2 === ref) + assert(u2 == ref) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/LightningMessageCodecsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/LightningMessageCodecsSpec.scala index 76b2f9cf4b..899de909a0 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/LightningMessageCodecsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/LightningMessageCodecsSpec.scala @@ -81,12 +81,12 @@ class LightningMessageCodecsSpec extends AnyFunSuite { for (testCase <- testCases) { if (testCase.valid) { val init = initCodec.decode(testCase.encoded.bits).require.value - assert(init.features.toByteVector === testCase.rawFeatures) - assert(init.networks === testCase.networks) - assert(init.remoteAddress_opt === testCase.address) + assert(init.features.toByteVector == testCase.rawFeatures) + assert(init.networks == testCase.networks) + assert(init.remoteAddress_opt == testCase.address) val encoded = initCodec.encode(init).require - assert(encoded.bytes === testCase.reEncoded.getOrElse(testCase.encoded)) - assert(initCodec.decode(encoded).require.value === init) + assert(encoded.bytes == testCase.reEncoded.getOrElse(testCase.encoded)) + assert(initCodec.decode(encoded).require.value == init) } else { assert(initCodec.decode(testCase.encoded.bits).isFailure) } @@ -102,8 +102,8 @@ class LightningMessageCodecsSpec extends AnyFunSuite { ) for ((warning, expected) <- testCases) { - assert(lightningMessageCodec.encode(warning).require.bytes === expected) - assert(lightningMessageCodec.decode(expected.bits).require.value === warning) + assert(lightningMessageCodec.encode(warning).require.bytes == expected) + assert(lightningMessageCodec.decode(expected.bits).require.value == warning) } } @@ -142,8 +142,8 @@ class LightningMessageCodecsSpec extends AnyFunSuite { ) refs.foreach { case ((bin, remainder), msg) => - assert(lightningMessageCodec.decode(bin.bits ++ remainder.bits).require === DecodeResult(msg, remainder.bits)) - assert(lightningMessageCodec.encode(msg).require === bin.bits) + assert(lightningMessageCodec.decode(bin.bits ++ remainder.bits).require == DecodeResult(msg, remainder.bits)) + assert(lightningMessageCodec.encode(msg).require == bin.bits) } } @@ -153,7 +153,7 @@ class LightningMessageCodecsSpec extends AnyFunSuite { val node = nodeAnnouncementCodec.decode(bin).require.value val bin2 = nodeAnnouncementCodec.encode(node).require - assert(bin === bin2) + assert(bin == bin2) } test("encode/decode interactive-tx messages") { @@ -187,9 +187,9 @@ class LightningMessageCodecsSpec extends AnyFunSuite { testCases.foreach { case (message, bin) => val decoded = lightningMessageCodec.decode(bin.bits).require assert(decoded.remainder.isEmpty) - assert(decoded.value === message) + assert(decoded.value == message) val encoded = lightningMessageCodec.encode(message).require.bytes - assert(encoded === bin) + assert(encoded == bin) } } @@ -226,9 +226,9 @@ class LightningMessageCodecsSpec extends AnyFunSuite { for ((encoded, expected) <- testCases) { val decoded = openChannelCodec.decode(encoded.bits).require.value - assert(decoded === expected) + assert(decoded == expected) val reEncoded = openChannelCodec.encode(decoded).require.bytes - assert(reEncoded === encoded) + assert(reEncoded == encoded) } } @@ -260,9 +260,9 @@ class LightningMessageCodecsSpec extends AnyFunSuite { ) testCases.foreach { case (open, bin) => val decoded = lightningMessageCodec.decode(bin.bits).require.value - assert(decoded === open) + assert(decoded == open) val encoded = lightningMessageCodec.encode(open).require.bytes - assert(encoded === bin) + assert(encoded == bin) } } @@ -276,7 +276,7 @@ class LightningMessageCodecsSpec extends AnyFunSuite { ) testCases.foreach { case (bin, flags) => val decoded = lightningMessageCodec.decode(bin.bits).require.value - assert(decoded === defaultOpen.copy(channelFlags = flags)) + assert(decoded == defaultOpen.copy(channelFlags = flags)) } } @@ -300,9 +300,9 @@ class LightningMessageCodecsSpec extends AnyFunSuite { for ((encoded, expected) <- testCases) { val decoded = acceptChannelCodec.decode(encoded.bits).require.value - assert(decoded === expected) + assert(decoded == expected) val reEncoded = acceptChannelCodec.encode(decoded).require.bytes - assert(reEncoded === encoded) + assert(reEncoded == encoded) } } @@ -315,9 +315,9 @@ class LightningMessageCodecsSpec extends AnyFunSuite { ) testCases.foreach { case (accept, bin) => val decoded = lightningMessageCodec.decode(bin.bits).require.value - assert(decoded === accept) + assert(decoded == accept) val encoded = lightningMessageCodec.encode(accept).require.bytes - assert(encoded === bin) + assert(encoded == bin) } } @@ -334,9 +334,9 @@ class LightningMessageCodecsSpec extends AnyFunSuite { for ((encoded, expected) <- testCases) { val decoded = closingSignedCodec.decode(encoded.bits).require.value - assert(decoded === expected) + assert(decoded == expected) val reEncoded = closingSignedCodec.encode(decoded).require.bytes - assert(reEncoded === encoded) + assert(reEncoded == encoded) } } @@ -389,7 +389,7 @@ class LightningMessageCodecsSpec extends AnyFunSuite { msg => { val encoded = lightningMessageCodecWithFallback.encode(msg).require val decoded = lightningMessageCodecWithFallback.decode(encoded).require - assert(msg === decoded.value) + assert(msg == decoded.value) } } } @@ -401,7 +401,7 @@ class LightningMessageCodecsSpec extends AnyFunSuite { val encoded1 = lightningMessageCodecWithFallback.encode(unknown).require val decoded1 = lightningMessageCodecWithFallback.decode(encoded1).require.value assert(lightningMessageCodec.decode(encoded1).isFailure) - assert(decoded1 === unknown) + assert(decoded1 == unknown) } test("non-reg encoding type") { @@ -462,7 +462,7 @@ class LightningMessageCodecsSpec extends AnyFunSuite { val items = refs.map { case (obj, refbin) => val bin = lightningMessageCodec.encode(obj).require - assert(refbin.bits === bin) + assert(refbin.bits == bin) TestItem(obj, bin.toHex) } @@ -520,11 +520,11 @@ class LightningMessageCodecsSpec extends AnyFunSuite { // this was generated by c-lightning val bin = hex"010258fff7d0e987e2cdd560e3bb5a046b4efe7b26c969c2f51da1dceec7bcb8ae1b634790503d5290c1a6c51d681cf8f4211d27ed33a257dcc1102862571bf1792306226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f0005a100000200005bc75919010100060000000000000001000000010000000a000000003a699d00" val update = lightningMessageCodec.decode(bin.bits).require.value.asInstanceOf[ChannelUpdate] - assert(update === ChannelUpdate(ByteVector64(hex"58fff7d0e987e2cdd560e3bb5a046b4efe7b26c969c2f51da1dceec7bcb8ae1b634790503d5290c1a6c51d681cf8f4211d27ed33a257dcc1102862571bf17923"), ByteVector32(hex"06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f"), ShortChannelId(0x5a10000020000L), 1539791129 unixsec, ChannelUpdate.ChannelFlags(isEnabled = true, isNode1 = false), CltvExpiryDelta(6), 1 msat, 1 msat, 10, Some(980000000 msat))) + assert(update == ChannelUpdate(ByteVector64(hex"58fff7d0e987e2cdd560e3bb5a046b4efe7b26c969c2f51da1dceec7bcb8ae1b634790503d5290c1a6c51d681cf8f4211d27ed33a257dcc1102862571bf17923"), ByteVector32(hex"06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f"), ShortChannelId(0x5a10000020000L), 1539791129 unixsec, ChannelUpdate.ChannelFlags(isEnabled = true, isNode1 = false), CltvExpiryDelta(6), 1 msat, 1 msat, 10, Some(980000000 msat))) val nodeId = PublicKey(hex"03370c9bac836e557eb4f017fe8f9cc047f44db39c1c4e410ff0f7be142b817ae4") assert(Announcements.checkSig(update, nodeId)) val bin2 = ByteVector(lightningMessageCodec.encode(update).require.toByteArray) - assert(bin === bin2) + assert(bin == bin2) } test("non-regression on channel_update") { @@ -549,10 +549,10 @@ class LightningMessageCodecsSpec extends AnyFunSuite { for ((bin, ref) <- bins) { val decoded = channelUpdateCodec.decode(bin.bits).require // not only must decoding succeed, it must also produce the same object - assert(Serialization.write(decoded.value)(JsonSerializers.formats) === ref) + assert(Serialization.write(decoded.value)(JsonSerializers.formats) == ref) assert(decoded.remainder.isEmpty) // encoding must produce the same buffer - assert(channelUpdateCodec.encode(decoded.value).require.bytes === bin) + assert(channelUpdateCodec.encode(decoded.value).require.bytes == bin) } } @@ -565,9 +565,9 @@ class LightningMessageCodecsSpec extends AnyFunSuite { ) for ((bin, ref) <- testCases) { val decoded = channelFlagsCodec.decode(bin).require - assert(decoded.value === ref) + assert(decoded.value == ref) assert(decoded.remainder.isEmpty) - assert(channelFlagsCodec.encode(ref).require === bin) + assert(channelFlagsCodec.encode(ref).require == bin) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/MessageOnionCodecsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/MessageOnionCodecsSpec.scala index ae4c9fc98c..12768df26c 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/MessageOnionCodecsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/MessageOnionCodecsSpec.scala @@ -14,8 +14,8 @@ class MessageOnionCodecsSpec extends AnyFunSuiteLike { test("simple relay payload") { val payload = RelayPayload(TlvStream(EncryptedData(hex"0a336970e870b473ddbc27e3098bfa45bb1aa54f1f637f803d957e6271d8ffeba89da2665d62123763d9b634e30714144a1c165ac9"))) val serialized = hex"3704350a336970e870b473ddbc27e3098bfa45bb1aa54f1f637f803d957e6271d8ffeba89da2665d62123763d9b634e30714144a1c165ac9" - assert(relayPerHopPayloadCodec.encode(payload).require.bytes === serialized) - assert(relayPerHopPayloadCodec.decode(serialized.bits).require.value === payload) + assert(relayPerHopPayloadCodec.encode(payload).require.bytes == serialized) + assert(relayPerHopPayloadCodec.decode(serialized.bits).require.value == payload) } test("empty relay payload") { @@ -31,8 +31,8 @@ class MessageOnionCodecsSpec extends AnyFunSuiteLike { test("simple final payload") { val payload = FinalPayload(TlvStream(EncryptedData(hex""))) val serialized = hex"020400" - assert(finalPerHopPayloadCodec.encode(payload).require.bytes === serialized) - assert(finalPerHopPayloadCodec.decode(serialized.bits).require.value === payload) + assert(finalPerHopPayloadCodec.encode(payload).require.bytes == serialized) + assert(finalPerHopPayloadCodec.decode(serialized.bits).require.value == payload) } test("empty final payload") { @@ -47,34 +47,34 @@ class MessageOnionCodecsSpec extends AnyFunSuiteLike { List(hex"04210324653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c", hex"0421027f31ebc5462c1fdce1b737ecff52d37d75dea43ce11c74d25aa297165faa2007")) val payload = FinalPayload(TlvStream(ReplyPath(blindedRoute), EncryptedData(hex""))) val serialized = hex"f202ee02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f28368661902c5ee5d5d559475814916957e167b8c257e06532ae6bfcbe4553e4549b9142ec7039dcddf597c0ea5bfe3c4de00630182d26c8f3cb588fa02c8cd19391a110f41a200330840ad82edc7378794e568deb3a836e3b9bc2e4a684412c34dbc5e50159ecf0b9c3844719f8656af9ff283e1eecb503f5e45b302aa42066bc9802597cac8f9f7193b8fd24b8671e3807e9c61dae8b330b695de780033d76f6388daa82694bcc63d43eaac1c5d189722cb84d0edb3b8b7dccb833c886eda7adb483f44498789f4139b2c12a0bfe8436a0400" - assert(finalPerHopPayloadCodec.encode(payload).require.bytes === serialized) - assert(finalPerHopPayloadCodec.decode(serialized.bits).require.value === payload) + assert(finalPerHopPayloadCodec.encode(payload).require.bytes == serialized) + assert(finalPerHopPayloadCodec.decode(serialized.bits).require.value == payload) } test("onion packet can be any size") { { // small onion val onion = OnionRoutingPacket(1, hex"032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991", hex"0012345679abcdef", ByteVector32(hex"0000111122223333444455556666777788889999aaaabbbbccccddddeeee0000")) val serialized = hex"004a 01 032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991 0012345679abcdef 0000111122223333444455556666777788889999aaaabbbbccccddddeeee0000" - assert(messageOnionPacketCodec.encode(onion).require.bytes === serialized) - assert(messageOnionPacketCodec.decode(serialized.bits).require.value === onion) + assert(messageOnionPacketCodec.encode(onion).require.bytes == serialized) + assert(messageOnionPacketCodec.decode(serialized.bits).require.value == onion) } { // larger onion val onion = OnionRoutingPacket(2, hex"027f31ebc5462c1fdce1b737ecff52d37d75dea43ce11c74d25aa297165faa2007", hex"0012345679abcdef012345679abcdef012345679abcdef012345679abcdef012345679abcdef", ByteVector32(hex"eeee0000111122223333444455556666777788889999aaaabbbbccccddddeeee")) val serialized = hex"0068 02 027f31ebc5462c1fdce1b737ecff52d37d75dea43ce11c74d25aa297165faa2007 0012345679abcdef012345679abcdef012345679abcdef012345679abcdef012345679abcdef eeee0000111122223333444455556666777788889999aaaabbbbccccddddeeee" - assert(messageOnionPacketCodec.encode(onion).require.bytes === serialized) - assert(messageOnionPacketCodec.decode(serialized.bits).require.value === onion) + assert(messageOnionPacketCodec.encode(onion).require.bytes == serialized) + assert(messageOnionPacketCodec.decode(serialized.bits).require.value == onion) } { // onion with trailing additional bytes val onion = OnionRoutingPacket(0, hex"032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991", hex"ffffffff", ByteVector32.Zeroes) val serialized = hex"0046 00 032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991 ffffffff 0000000000000000000000000000000000000000000000000000000000000000 0a01020000030400000000" - assert(messageOnionPacketCodec.encode(onion).require.bytes === serialized.dropRight(11)) - assert(messageOnionPacketCodec.decode(serialized.bits).require.value === onion) + assert(messageOnionPacketCodec.encode(onion).require.bytes == serialized.dropRight(11)) + assert(messageOnionPacketCodec.decode(serialized.bits).require.value == onion) } { // onion with empty payload val onion = OnionRoutingPacket(0, hex"032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991", hex"", ByteVector32.Zeroes) val serialized = hex"0042 00 032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991 0000000000000000000000000000000000000000000000000000000000000000" - assert(messageOnionPacketCodec.encode(onion).require.bytes === serialized) - assert(messageOnionPacketCodec.decode(serialized.bits).require.value === onion) + assert(messageOnionPacketCodec.encode(onion).require.bytes == serialized) + assert(messageOnionPacketCodec.decode(serialized.bits).require.value == onion) } { // onion length too big val serialized = hex"0048 00 032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991 ffffffff 0000000000000000000000000000000000000000000000000000000000000000" diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/OffersSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/OffersSpec.scala index c282d943bc..22e7636dc2 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/OffersSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/OffersSpec.scala @@ -52,8 +52,8 @@ class OffersSpec extends AnyFunSuite { val offer = Offer.decode(encoded).get assert(offer.amount.isEmpty) assert(offer.signature.isEmpty) - assert(offer.description === "Offer by rusty's node") - assert(offer.nodeIdXOnly === nodeId) + assert(offer.description == "Offer by rusty's node") + assert(offer.nodeIdXOnly == nodeId) } test("basic signed offer") { @@ -61,30 +61,30 @@ class OffersSpec extends AnyFunSuite { val Success(signedOffer) = Offer.decode(encodedSigned) assert(signedOffer.checkSignature()) assert(signedOffer.amount.isEmpty) - assert(signedOffer.description === "Offer by rusty's node") - assert(signedOffer.nodeIdXOnly === nodeId) + assert(signedOffer.description == "Offer by rusty's node") + assert(signedOffer.nodeIdXOnly == nodeId) } test("offer with amount and quantity") { val encoded = "lno1pqqnyzsmx5cx6umpwssx6atvw35j6ut4v9h8g6t50ysx7enxv4epgrmjw4ehgcm0wfczucm0d5hxzagkqyq3ugztng063cqx783exlm97ekyprnd4rsu5u5w5sez9fecrhcuc3ykq5" val Success(offer) = Offer.decode(encoded) - assert(offer.amount === Some(50 msat)) + assert(offer.amount == Some(50 msat)) assert(offer.signature.isEmpty) - assert(offer.description === "50msat multi-quantity offer") - assert(offer.nodeIdXOnly === nodeId) - assert(offer.issuer === Some("rustcorp.com.au")) - assert(offer.quantityMin === Some(1)) + assert(offer.description == "50msat multi-quantity offer") + assert(offer.nodeIdXOnly == nodeId) + assert(offer.issuer == Some("rustcorp.com.au")) + assert(offer.quantityMin == Some(1)) } test("signed offer with amount and quantity") { val encodedSigned = "lno1pqqnyzsmx5cx6umpwssx6atvw35j6ut4v9h8g6t50ysx7enxv4epgrmjw4ehgcm0wfczucm0d5hxzagkqyq3ugztng063cqx783exlm97ekyprnd4rsu5u5w5sez9fecrhcuc3ykqhcypjju7unu05vav8yvhn27lztf46k9gqlga8uvu4uq62kpuywnu6me8srgh2q7puczukr8arectaapfl5d4rd6uc7st7tnqf0ttx39n40s" val Success(signedOffer) = Offer.decode(encodedSigned) assert(signedOffer.checkSignature()) - assert(signedOffer.amount === Some(50 msat)) - assert(signedOffer.description === "50msat multi-quantity offer") - assert(signedOffer.nodeIdXOnly === nodeId) - assert(signedOffer.issuer === Some("rustcorp.com.au")) - assert(signedOffer.quantityMin === Some(1)) + assert(signedOffer.amount == Some(50 msat)) + assert(signedOffer.description == "50msat multi-quantity offer") + assert(signedOffer.nodeIdXOnly == nodeId) + assert(signedOffer.issuer == Some("rustcorp.com.au")) + assert(signedOffer.quantityMin == Some(1)) } test("decode invalid offer") { @@ -198,16 +198,16 @@ class OffersSpec extends AnyFunSuite { test("decode invoice request") { val encoded = "lnr1qvsxlc5vp2m0rvmjcxn2y34wv0m5lyc7sdj7zksgn35dvxgqqqqqqqqyypz8xu3xwsqpar9dd26lgrrvc7s63ljt0pgh6ag2utv5udez7n2mjzqzz47qcqczqgqzqqgzycsv2tmjgzc5l546aldq699wj9pdusvfred97l352p4aa862vqvzw5p8pdyjqctdyppxzardv9hrypx74klwluzqd0rqgeew2uhuagttuv6aqwklvm0xmlg52lfnagzw8ygt0wrtnv2tsx69m6tgug7njaw5ypa5fn369n9yzc87v02rqccj9h04dxf3nzc" val Success(request) = InvoiceRequest.decode(encoded) - assert(request.amount === Some(5500 msat)) - assert(request.offerId === ByteVector32(hex"4473722674001e8cad6ab5f40c6cc7a1a8fe4b78517d750ae2d94e3722f4d5b9")) - assert(request.quantity === 2) - assert(request.features === Features(VariableLengthOnion -> Optional, BasicMultiPartPayment -> Optional)) + assert(request.amount == Some(5500 msat)) + assert(request.offerId == ByteVector32(hex"4473722674001e8cad6ab5f40c6cc7a1a8fe4b78517d750ae2d94e3722f4d5b9")) + assert(request.quantity == 2) + assert(request.features == Features(VariableLengthOnion -> Optional, BasicMultiPartPayment -> Optional)) assert(request.records.get[Chain].nonEmpty) - assert(request.chain === Block.LivenetGenesisBlock.hash) - assert(request.payerKey === ByteVector32(hex"c52f7240b14fd2baefda0d14ae9142de41891e5a5f7e34506bde9f4a60182750")) - assert(request.payerInfo === Some(hex"deadbeef")) - assert(request.payerNote === Some("I am Batman")) - assert(request.encode() === encoded) + assert(request.chain == Block.LivenetGenesisBlock.hash) + assert(request.payerKey == ByteVector32(hex"c52f7240b14fd2baefda0d14ae9142de41891e5a5f7e34506bde9f4a60182750")) + assert(request.payerInfo == Some(hex"deadbeef")) + assert(request.payerNote == Some("I am Batman")) + assert(request.encode() == encoded) } test("decode invalid invoice request") { @@ -274,9 +274,9 @@ class OffersSpec extends AnyFunSuite { case TestCase(tlvStream, tlvCount, expectedRoot) => val genericTlvStream: Codec[TlvStream[GenericTlv]] = list(TlvCodecs.genericTlv).xmap(tlvs => TlvStream(tlvs), tlvs => tlvs.records.toList) val tlvs = genericTlvStream.decode(tlvStream.bits).require.value - assert(tlvs.records.size === tlvCount) + assert(tlvs.records.size == tlvCount) val root = Offers.rootHash(tlvs, genericTlvStream) - assert(root === expectedRoot) + assert(root == expectedRoot) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/PaymentOnionSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/PaymentOnionSpec.scala index 94e83962ea..0e597c8a75 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/PaymentOnionSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/PaymentOnionSpec.scala @@ -40,10 +40,10 @@ class PaymentOnionSpec extends AnyFunSuite { val expected = OnionRoutingPacket(0, hex"02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619", hex"e5f14350c2a76fc232b5e46d421e9615471ab9e0bc887beff8c95fdb878f7b3a71da571226458c510bbadd1276f045c21c520a07d35da256ef75b4367962437b0dd10f7d61ab590531cf08000178a333a347f8b4072e216400406bdf3bf038659793a86cae5f52d32f3438527b47a1cfc54285a8afec3a4c9f3323db0c946f5d4cb2ce721caad69320c3a469a202f3e468c67eaf7a7cda226d0fd32f7b48084dca885d15222e60826d5d971f64172d98e0760154400958f00e86697aa1aa9d41bee8119a1ec866abe044a9ad635778ba61fc0776dc832b39451bd5d35072d2269cf9b040d6ba38b54ec35f81d7fc67678c3be47274f3c4cc472aff005c3469eb3bc140769ed4c7f0218ff8c6c7dd7221d189c65b3b9aaa71a01484b122846c7c7b57e02e679ea8469b70e14fe4f70fee4d87b910cf144be6fe48eef24da475c0b0bcc6565ae82cd3f4e3b24c76eaa5616c6111343306ab35c1fe5ca4a77c0e314ed7dba39d6f1e0de791719c241a939cc493bea2bae1c1e932679ea94d29084278513c77b899cc98059d06a27d171b0dbdf6bee13ddc4fc17a0c4d2827d488436b57baa167544138ca2e64a11b43ac8a06cd0c2fba2d4d900ed2d9205305e2d7383cc98dacb078133de5f6fb6bed2ef26ba92cea28aafc3b9948dd9ae5559e8bd6920b8cea462aa445ca6a95e0e7ba52961b181c79e73bd581821df2b10173727a810c92b83b5ba4a0403eb710d2ca10689a35bec6c3a708e9e92f7d78ff3c5d9989574b00c6736f84c199256e76e19e78f0c98a9d580b4a658c84fc8f2096c2fbea8f5f8c59d0fdacb3be2802ef802abbecb3aba4acaac69a0e965abd8981e9896b1f6ef9d60f7a164b371af869fd0e48073742825e9434fc54da837e120266d53302954843538ea7c6c3dbfb4ff3b2fdbe244437f2a153ccf7bdb4c92aa08102d4f3cff2ae5ef86fab4653595e6a5837fa2f3e29f27a9cde5966843fb847a4a61f1e76c281fe8bb2b0a181d096100db5a1a5ce7a910238251a43ca556712eaadea167fb4d7d75825e440f3ecd782036d7574df8bceacb397abefc5f5254d2722215c53ff54af8299aaaad642c6d72a14d27882d9bbd539e1cc7a527526ba89b8c037ad09120e98ab042d3e8652b31ae0e478516bfaf88efca9f3676ffe99d2819dcaeb7610a626695f53117665d267d3f7abebd6bbd6733f645c72c389f03855bdf1e4b8075b516569b118233a0f0971d24b83113c0b096f5216a207ca99a7cddc81c130923fe3d91e7508c9ac5f2e914ff5dccab9e558566fa14efb34ac98d878580814b94b73acbfde9072f30b881f7f0fff42d4045d1ace6322d86a97d164aa84d93a60498065cc7c20e636f5862dc81531a88c60305a2e59a985be327a6902e4bed986dbf4a0b50c217af0ea7fdf9ab37f9ea1a1aaa72f54cf40154ea9b269f1a7c09f9f43245109431a175d50e2db0132337baa0ef97eed0fcf20489da36b79a1172faccc2f7ded7c60e00694282d93359c4682135642bc81f433574aa8ef0c97b4ade7ca372c5ffc23c7eddd839bab4e0f14d6df15c9dbeab176bec8b5701cf054eb3072f6dadc98f88819042bf10c407516ee58bce33fbe3b3d86a54255e577db4598e30a135361528c101683a5fcde7e8ba53f3456254be8f45fe3a56120ae96ea3773631fcb3873aa3abd91bcff00bd38bd43697a2e789e00da6077482e7b1b1a677b5afae4c54e6cbdf7377b694eb7d7a5b913476a5be923322d3de06060fd5e819635232a2cf4f0731da13b8546d1d6d4f8d75b9fce6c2341a71b0ea6f780df54bfdb0dd5cd9855179f602f9172", ByteVector32(hex"65f21f9190c70217774a6fbaaa7d63ad64199f4664813b955cff954949076dcf")) val decoded = paymentOnionPacketCodec.decode(bin.bits).require.value - assert(decoded === expected) + assert(decoded == expected) val encoded = paymentOnionPacketCodec.encode(decoded).require - assert(encoded.toByteVector === bin) + assert(encoded.toByteVector == bin) } test("encode/decode fixed-size (legacy) relay per-hop payload") { @@ -55,10 +55,10 @@ class PaymentOnionSpec extends AnyFunSuite { for ((expected, bin) <- testCases) { val decoded = channelRelayPerHopPayloadCodec.decode(bin.bits).require.value - assert(decoded === expected) + assert(decoded == expected) val encoded = channelRelayPerHopPayloadCodec.encode(expected).require.bytes - assert(encoded === bin) + assert(encoded == bin) } } @@ -75,7 +75,7 @@ class PaymentOnionSpec extends AnyFunSuite { ) for ((payloadLength, bin) <- testCases) { - assert(payloadLengthDecoder.decode(bin.bits).require.value === payloadLength) + assert(payloadLengthDecoder.decode(bin.bits).require.value == payloadLength) } } @@ -88,13 +88,13 @@ class PaymentOnionSpec extends AnyFunSuite { for ((expected, bin) <- testCases) { val decoded = channelRelayPerHopPayloadCodec.decode(bin.bits).require.value - assert(decoded === ChannelRelayTlvPayload(expected)) - assert(decoded.amountToForward === 561.msat) - assert(decoded.outgoingCltv === CltvExpiry(42)) - assert(decoded.outgoingChannelId === ShortChannelId(1105)) + assert(decoded == ChannelRelayTlvPayload(expected)) + assert(decoded.amountToForward == 561.msat) + assert(decoded.outgoingCltv == CltvExpiry(42)) + assert(decoded.outgoingChannelId == ShortChannelId(1105)) val encoded = channelRelayPerHopPayloadCodec.encode(ChannelRelayTlvPayload(expected)).require.bytes - assert(encoded === bin) + assert(encoded == bin) } } @@ -104,17 +104,17 @@ class PaymentOnionSpec extends AnyFunSuite { val bin = hex"2e 02020231 04012a fe000102322102eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619" val decoded = nodeRelayPerHopPayloadCodec.decode(bin.bits).require.value - assert(decoded === NodeRelayPayload(expected)) - assert(decoded.amountToForward === 561.msat) - assert(decoded.totalAmount === 561.msat) - assert(decoded.outgoingCltv === CltvExpiry(42)) - assert(decoded.outgoingNodeId === nodeId) - assert(decoded.paymentSecret === None) - assert(decoded.invoiceFeatures === None) - assert(decoded.invoiceRoutingInfo === None) + assert(decoded == NodeRelayPayload(expected)) + assert(decoded.amountToForward == 561.msat) + assert(decoded.totalAmount == 561.msat) + assert(decoded.outgoingCltv == CltvExpiry(42)) + assert(decoded.outgoingNodeId == nodeId) + assert(decoded.paymentSecret == None) + assert(decoded.invoiceFeatures == None) + assert(decoded.invoiceRoutingInfo == None) val encoded = nodeRelayPerHopPayloadCodec.encode(NodeRelayPayload(expected)).require.bytes - assert(encoded === bin) + assert(encoded == bin) } test("encode/decode variable-length (tlv) node relay to legacy per-hop payload") { @@ -129,17 +129,17 @@ class PaymentOnionSpec extends AnyFunSuite { val bin = hex"fa 02020231 04012a 0822eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f2836866190451 fe00010231010a fe000102322102eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619 fe000102339b01036d6caac248af96f6afa7f904f550253a0f3ef3f5aa2fe6838a95b216691468e200000000000000010000000a00000064009002025f7117a78150fe2ef97db7cfc83bd57b2e2c0d0dd25eaf467a4a1c2a45ce148600000000000000020000001400000096000c02a051267759c3a149e3e72372f4e0c4054ba597ebfd0eda78a2273023667205ee00000000000000030000001e000000c80018" val decoded = nodeRelayPerHopPayloadCodec.decode(bin.bits).require.value - assert(decoded === NodeRelayPayload(expected)) - assert(decoded.amountToForward === 561.msat) - assert(decoded.totalAmount === 1105.msat) - assert(decoded.paymentSecret === Some(ByteVector32(hex"eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619"))) - assert(decoded.outgoingCltv === CltvExpiry(42)) - assert(decoded.outgoingNodeId === nodeId) - assert(decoded.invoiceFeatures === Some(features)) - assert(decoded.invoiceRoutingInfo === Some(routingHints)) + assert(decoded == NodeRelayPayload(expected)) + assert(decoded.amountToForward == 561.msat) + assert(decoded.totalAmount == 1105.msat) + assert(decoded.paymentSecret == Some(ByteVector32(hex"eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619"))) + assert(decoded.outgoingCltv == CltvExpiry(42)) + assert(decoded.outgoingNodeId == nodeId) + assert(decoded.invoiceFeatures == Some(features)) + assert(decoded.invoiceRoutingInfo == Some(routingHints)) val encoded = nodeRelayPerHopPayloadCodec.encode(NodeRelayPayload(expected)).require.bytes - assert(encoded === bin) + assert(encoded == bin) } test("encode/decode variable-length (tlv) final per-hop payload") { @@ -157,12 +157,12 @@ class PaymentOnionSpec extends AnyFunSuite { for ((expected, bin) <- testCases) { val decoded = finalPerHopPayloadCodec.decode(bin.bits).require.value - assert(decoded === FinalTlvPayload(expected)) - assert(decoded.amount === 561.msat) - assert(decoded.expiry === CltvExpiry(42)) + assert(decoded == FinalTlvPayload(expected)) + assert(decoded.amount == 561.msat) + assert(decoded.expiry == CltvExpiry(42)) val encoded = finalPerHopPayloadCodec.encode(FinalTlvPayload(expected)).require.bytes - assert(encoded === bin) + assert(encoded == bin) } } @@ -171,22 +171,22 @@ class PaymentOnionSpec extends AnyFunSuite { val bin = hex"53 02020231 04012a 0820eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619 ff0000000143c7a0402016c7ec71663784ff100b6eface1e60a97b92ea9d18b8ece5e558586bc7453828" val encoded = finalPerHopPayloadCodec.encode(FinalTlvPayload(tlvs)).require.bytes - assert(encoded === bin) + assert(encoded == bin) assert(finalPerHopPayloadCodec.decode(bin.bits).require.value == FinalTlvPayload(tlvs)) } test("decode multi-part final per-hop payload") { val multiPart = finalPerHopPayloadCodec.decode(hex"2b 02020231 04012a 0822eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f2836866190451".bits).require.value - assert(multiPart.amount === 561.msat) - assert(multiPart.expiry === CltvExpiry(42)) - assert(multiPart.totalAmount === 1105.msat) - assert(multiPart.paymentSecret === ByteVector32(hex"eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619")) + assert(multiPart.amount == 561.msat) + assert(multiPart.expiry == CltvExpiry(42)) + assert(multiPart.totalAmount == 1105.msat) + assert(multiPart.paymentSecret == ByteVector32(hex"eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619")) val multiPartNoTotalAmount = finalPerHopPayloadCodec.decode(hex"29 02020231 04012a 0820eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619".bits).require.value - assert(multiPartNoTotalAmount.amount === 561.msat) - assert(multiPartNoTotalAmount.expiry === CltvExpiry(42)) - assert(multiPartNoTotalAmount.totalAmount === 561.msat) - assert(multiPartNoTotalAmount.paymentSecret === ByteVector32(hex"eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619")) + assert(multiPartNoTotalAmount.amount == 561.msat) + assert(multiPartNoTotalAmount.expiry == CltvExpiry(42)) + assert(multiPartNoTotalAmount.totalAmount == 561.msat) + assert(multiPartNoTotalAmount.paymentSecret == ByteVector32(hex"eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619")) } test("decode variable-length (tlv) relay per-hop payload missing information") { @@ -200,7 +200,7 @@ class PaymentOnionSpec extends AnyFunSuite { val decoded = channelRelayPerHopPayloadCodec.decode(bin.bits) assert(decoded.isFailure) val Attempt.Failure(err: MissingRequiredTlv) = decoded - assert(err.failureMessage === expectedErr) + assert(err.failureMessage == expectedErr) } } @@ -215,7 +215,7 @@ class PaymentOnionSpec extends AnyFunSuite { val decoded = nodeRelayPerHopPayloadCodec.decode(bin.bits) assert(decoded.isFailure) val Attempt.Failure(err: MissingRequiredTlv) = decoded - assert(err.failureMessage === expectedErr) + assert(err.failureMessage == expectedErr) } } @@ -230,7 +230,7 @@ class PaymentOnionSpec extends AnyFunSuite { val decoded = finalPerHopPayloadCodec.decode(bin.bits) assert(decoded.isFailure) val Attempt.Failure(err: MissingRequiredTlv) = decoded - assert(err.failureMessage === expectedErr) + assert(err.failureMessage == expectedErr) } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/RouteBlindingSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/RouteBlindingSpec.scala index 5bbbc114ea..3e7f63fe60 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/RouteBlindingSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/RouteBlindingSpec.scala @@ -27,9 +27,9 @@ class RouteBlindingSpec extends AnyFunSuiteLike { for ((encoded, data) <- payloads) { val decoded = RouteBlindingEncryptedDataCodecs.encryptedDataCodec.decode(encoded.bits).require.value - assert(decoded === data) + assert(decoded == data) val reEncoded = RouteBlindingEncryptedDataCodecs.encryptedDataCodec.encode(data).require.bytes - assert(reEncoded === encoded) + assert(reEncoded == encoded) } } @@ -51,7 +51,7 @@ class RouteBlindingSpec extends AnyFunSuiteLike { val Success((decryptedPayload2, blinding3)) = RouteBlindingEncryptedDataCodecs.decode(nodePrivKeys(2), blinding2, blindedRoute.encryptedPayloads(2)) val Success((decryptedPayload3, blinding4)) = RouteBlindingEncryptedDataCodecs.decode(nodePrivKeys(3), blinding3, blindedRoute.encryptedPayloads(3)) val Success((decryptedPayload4, _)) = RouteBlindingEncryptedDataCodecs.decode(nodePrivKeys(4), blinding4, blindedRoute.encryptedPayloads(4)) - assert(Seq(decryptedPayload0, decryptedPayload1, decryptedPayload2, decryptedPayload3, decryptedPayload4) === payloads.map(_._1)) + assert(Seq(decryptedPayload0, decryptedPayload1, decryptedPayload2, decryptedPayload3, decryptedPayload4) == payloads.map(_._1)) } test("decode invalid encrypted route blinding data") { diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/TlvCodecsSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/TlvCodecsSpec.scala index c718ab26ff..d13a7b5374 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/TlvCodecsSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/wire/protocol/TlvCodecsSpec.scala @@ -48,13 +48,13 @@ class TlvCodecsSpec extends AnyFunSuite { for ((bin, lengthPrefixedBin, expected) <- testCases) { val decoded = tu16.decode(bin.bits).require.value val decoded1 = ltu16.decode(lengthPrefixedBin.bits).require.value - assert(decoded === expected) - assert(decoded1 === expected) + assert(decoded == expected) + assert(decoded1 == expected) val encoded = tu16.encode(expected).require.bytes val encoded1 = ltu16.encode(expected).require.bytes - assert(encoded === bin) - assert(encoded1 === lengthPrefixedBin) + assert(encoded == bin) + assert(encoded1 == lengthPrefixedBin) } } @@ -77,13 +77,13 @@ class TlvCodecsSpec extends AnyFunSuite { for ((bin, lengthPrefixedBin, expected) <- testCases) { val decoded = tu32.decode(bin.bits).require.value val decoded1 = ltu32.decode(lengthPrefixedBin.bits).require.value - assert(decoded === expected) - assert(decoded1 === expected) + assert(decoded == expected) + assert(decoded1 == expected) val encoded = tu32.encode(expected).require.bytes val encoded1 = ltu32.encode(expected).require.bytes - assert(encoded === bin) - assert(encoded1 === lengthPrefixedBin) + assert(encoded == bin) + assert(encoded1 == lengthPrefixedBin) } } @@ -118,32 +118,32 @@ class TlvCodecsSpec extends AnyFunSuite { for ((bin, lengthPrefixedBin, expected) <- testCases) { val decoded = tu64.decode(bin.bits).require.value val decoded1 = ltu64.decode(lengthPrefixedBin.bits).require.value - assert(decoded === expected) - assert(decoded1 === expected) + assert(decoded == expected) + assert(decoded1 == expected) val encoded = tu64.encode(expected).require.bytes val encoded1 = ltu64.encode(expected).require.bytes - assert(encoded === bin) - assert(encoded1 === lengthPrefixedBin) + assert(encoded == bin) + assert(encoded1 == lengthPrefixedBin) } } test("encode/decode truncated uint64 overflow") { - assert(tu64overflow.encode(Long.MaxValue).require.toByteVector === hex"7fffffffffffffff") - assert(tu64overflow.decode(hex"7fffffffffffffff".bits).require.value === Long.MaxValue) + assert(tu64overflow.encode(Long.MaxValue).require.toByteVector == hex"7fffffffffffffff") + assert(tu64overflow.decode(hex"7fffffffffffffff".bits).require.value == Long.MaxValue) - assert(tu64overflow.encode(42L).require.toByteVector === hex"2a") - assert(tu64overflow.decode(hex"2a".bits).require.value === 42L) + assert(tu64overflow.encode(42L).require.toByteVector == hex"2a") + assert(tu64overflow.decode(hex"2a".bits).require.value == 42L) assert(tu64overflow.encode(-1L).isFailure) assert(tu64overflow.decode(hex"8000000000000000".bits).isFailure) } test("decode length-prefixed truncated uint64 ignores trailing bytes") { - assert(ltu64.decode(hex"00 1234".bits).require.value === UInt64(0)) - assert(ltu64.decode(hex"01 2a ff".bits).require.value === UInt64(42)) - assert(ltu64.decode(hex"02 0451 1234".bits).require.value === UInt64(1105)) - assert(ltu64.decode(hex"03 010000 0000".bits).require.value === UInt64(65536)) + assert(ltu64.decode(hex"00 1234".bits).require.value == UInt64(0)) + assert(ltu64.decode(hex"01 2a ff".bits).require.value == UInt64(42)) + assert(ltu64.decode(hex"02 0451 1234".bits).require.value == UInt64(1105)) + assert(ltu64.decode(hex"03 010000 0000".bits).require.value == UInt64(65536)) } test("decode invalid truncated integers") { @@ -200,9 +200,9 @@ class TlvCodecsSpec extends AnyFunSuite { for ((bin, expected) <- testCases) { val decoded = testTlvStreamCodec.decode(bin.bits).require.value - assert(decoded === expected) + assert(decoded == expected) val encoded = testTlvStreamCodec.encode(expected).require.bytes - assert(encoded === bin) + assert(encoded == bin) } } @@ -275,7 +275,7 @@ class TlvCodecsSpec extends AnyFunSuite { ) for (testCase <- testCases) { - assert(lengthPrefixedTestTlvStreamCodec.encode(lengthPrefixedTestTlvStreamCodec.decode(testCase.bits).require.value).require.bytes === testCase) + assert(lengthPrefixedTestTlvStreamCodec.encode(lengthPrefixedTestTlvStreamCodec.decode(testCase.bits).require.value).require.bytes == testCase) } } @@ -302,8 +302,8 @@ class TlvCodecsSpec extends AnyFunSuite { test("encode unordered tlv stream (codec should sort appropriately)") { val stream = TlvStream[TestTlv](Seq(TestType254(42), TestType1(42)), Seq(GenericTlv(13, hex"2a"), GenericTlv(11, hex"2b"))) - assert(testTlvStreamCodec.encode(stream).require.toByteVector === hex"01012a 0b012b 0d012a fd00fe02002a") - assert(lengthPrefixedTestTlvStreamCodec.encode(stream).require.toByteVector === hex"0f 01012a 0b012b 0d012a fd00fe02002a") + assert(testTlvStreamCodec.encode(stream).require.toByteVector == hex"01012a 0b012b 0d012a fd00fe02002a") + assert(lengthPrefixedTestTlvStreamCodec.encode(stream).require.toByteVector == hex"0f 01012a 0b012b 0d012a fd00fe02002a") } test("encode/decode custom even tlv records") { @@ -334,9 +334,9 @@ class TlvCodecsSpec extends AnyFunSuite { test("get optional TLV field") { val stream = TlvStream[TestTlv](Seq(TestType254(42), TestType1(42)), Seq(GenericTlv(13, hex"2a"), GenericTlv(11, hex"2b"))) - assert(stream.get[TestType254] === Some(TestType254(42))) - assert(stream.get[TestType1] === Some(TestType1(42))) - assert(stream.get[TestType2] === None) + assert(stream.get[TestType254] == Some(TestType254(42))) + assert(stream.get[TestType1] == Some(TestType1(42))) + assert(stream.get[TestType2] == None) } } diff --git a/eclair-front/src/test/scala/fr/acinq/eclair/router/FrontRouterSpec.scala b/eclair-front/src/test/scala/fr/acinq/eclair/router/FrontRouterSpec.scala index 404d3a2c7f..a72d82c11b 100644 --- a/eclair-front/src/test/scala/fr/acinq/eclair/router/FrontRouterSpec.scala +++ b/eclair-front/src/test/scala/fr/acinq/eclair/router/FrontRouterSpec.scala @@ -89,7 +89,7 @@ class FrontRouterSpec extends TestKit(ActorSystem("test")) with AnyFunSuiteLike pipe1.expectMsg(PeerRoutingMessage(front1, origin1a.nodeId, chan_ab)) pipe1.send(router, PeerRoutingMessage(pipe1.ref, origin1a.nodeId, chan_ab)) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_ab) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_ab) peerConnection1b.send(front1, PeerRoutingMessage(peerConnection1b.ref, origin1b.nodeId, chan_ab)) pipe1.expectNoMessage() @@ -177,7 +177,7 @@ class FrontRouterSpec extends TestKit(ActorSystem("test")) with AnyFunSuiteLike val origin3a = RemoteGossip(peerConnection3a.ref, randomKey().publicKey) peerConnection1a.send(front1, PeerRoutingMessage(peerConnection1a.ref, origin1a.nodeId, chan_ab)) - assert(watcher.expectMsgType[ValidateRequest].ann === chan_ab) + assert(watcher.expectMsgType[ValidateRequest].ann == chan_ab) peerConnection1b.send(front1, PeerRoutingMessage(peerConnection1b.ref, origin1b.nodeId, chan_ab)) peerConnection2a.send(front2, PeerRoutingMessage(peerConnection2a.ref, origin2a.nodeId, chan_ab)) diff --git a/eclair-node/src/test/scala/fr/acinq/eclair/api/ApiServiceSpec.scala b/eclair-node/src/test/scala/fr/acinq/eclair/api/ApiServiceSpec.scala index 9913651d85..de7394b551 100644 --- a/eclair-node/src/test/scala/fr/acinq/eclair/api/ApiServiceSpec.scala +++ b/eclair-node/src/test/scala/fr/acinq/eclair/api/ApiServiceSpec.scala @@ -631,7 +631,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM assert(status == OK) val response = entityAs[String] val expected = """{"paymentHash":"0000000000000000000000000000000000000000000000000000000000000000","paymentPreimage":"0100000000000000000000000000000000000000000000000000000000000000"}""" - assert(response === expected) + assert(response == expected) } val uuid = UUID.fromString("487da196-a4dc-4b1e-92b4-3e5e905e9f3f") @@ -645,7 +645,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM assert(status == OK) val response = entityAs[String] val expected = """{"type":"payment-sent","id":"487da196-a4dc-4b1e-92b4-3e5e905e9f3f","paymentHash":"0000000000000000000000000000000000000000000000000000000000000000","paymentPreimage":"0100000000000000000000000000000000000000000000000000000000000000","recipientAmount":25,"recipientNodeId":"03af0ed6052cf28d670665549bc86f4b721c9fdb309d40c58f5811f63966e005d0","parts":[{"id":"487da196-a4dc-4b1e-92b4-3e5e905e9f3f","amount":21,"feesPaid":1,"toChannelId":"0000000000000000000000000000000000000000000000000000000000000000","timestamp":{"iso":"2019-03-28T14:45:37.711Z","unix":1553784337}}]}""" - assert(response === expected) + assert(response == expected) } val paymentFailed = PaymentFailed(uuid, ByteVector32.Zeroes, failures = Seq.empty, timestamp = TimestampMilli(1553784963659L)) @@ -658,7 +658,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM assert(status == OK) val response = entityAs[String] val expected = """{"type":"payment-failed","id":"487da196-a4dc-4b1e-92b4-3e5e905e9f3f","paymentHash":"0000000000000000000000000000000000000000000000000000000000000000","failures":[],"timestamp":{"iso":"2019-03-28T14:56:03.659Z","unix":1553784963}}""" - assert(response === expected) + assert(response == expected) } } @@ -1121,55 +1121,55 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM check { val pf = PaymentFailed(fixedUUID, ByteVector32.Zeroes, failures = Seq.empty, timestamp = TimestampMilli(1553784963659L)) val expectedSerializedPf = """{"type":"payment-failed","id":"487da196-a4dc-4b1e-92b4-3e5e905e9f3f","paymentHash":"0000000000000000000000000000000000000000000000000000000000000000","failures":[],"timestamp":{"iso":"2019-03-28T14:56:03.659Z","unix":1553784963}}""" - assert(serialization.write(pf) === expectedSerializedPf) + assert(serialization.write(pf) == expectedSerializedPf) system.eventStream.publish(pf) wsClient.expectMessage(expectedSerializedPf) val ps = PaymentSent(fixedUUID, ByteVector32.Zeroes, ByteVector32.One, 25 msat, aliceNodeId, Seq(PaymentSent.PartialPayment(fixedUUID, 21 msat, 1 msat, ByteVector32.Zeroes, None, TimestampMilli(1553784337711L)))) val expectedSerializedPs = """{"type":"payment-sent","id":"487da196-a4dc-4b1e-92b4-3e5e905e9f3f","paymentHash":"0000000000000000000000000000000000000000000000000000000000000000","paymentPreimage":"0100000000000000000000000000000000000000000000000000000000000000","recipientAmount":25,"recipientNodeId":"03af0ed6052cf28d670665549bc86f4b721c9fdb309d40c58f5811f63966e005d0","parts":[{"id":"487da196-a4dc-4b1e-92b4-3e5e905e9f3f","amount":21,"feesPaid":1,"toChannelId":"0000000000000000000000000000000000000000000000000000000000000000","timestamp":{"iso":"2019-03-28T14:45:37.711Z","unix":1553784337}}]}""" - assert(serialization.write(ps) === expectedSerializedPs) + assert(serialization.write(ps) == expectedSerializedPs) system.eventStream.publish(ps) wsClient.expectMessage(expectedSerializedPs) val prel = ChannelPaymentRelayed(21 msat, 20 msat, ByteVector32.Zeroes, ByteVector32.Zeroes, ByteVector32.One, TimestampMilli(1553784963659L)) val expectedSerializedPrel = """{"type":"payment-relayed","amountIn":21,"amountOut":20,"paymentHash":"0000000000000000000000000000000000000000000000000000000000000000","fromChannelId":"0000000000000000000000000000000000000000000000000000000000000000","toChannelId":"0100000000000000000000000000000000000000000000000000000000000000","timestamp":{"iso":"2019-03-28T14:56:03.659Z","unix":1553784963}}""" - assert(serialization.write(prel) === expectedSerializedPrel) + assert(serialization.write(prel) == expectedSerializedPrel) system.eventStream.publish(prel) wsClient.expectMessage(expectedSerializedPrel) val ptrel = TrampolinePaymentRelayed(ByteVector32.Zeroes, Seq(PaymentRelayed.Part(21 msat, ByteVector32.Zeroes)), Seq(PaymentRelayed.Part(8 msat, ByteVector32.Zeroes), PaymentRelayed.Part(10 msat, ByteVector32.One)), bobNodeId, 17 msat, TimestampMilli(1553784963659L)) val expectedSerializedPtrel = """{"type":"trampoline-payment-relayed","paymentHash":"0000000000000000000000000000000000000000000000000000000000000000","incoming":[{"amount":21,"channelId":"0000000000000000000000000000000000000000000000000000000000000000"}],"outgoing":[{"amount":8,"channelId":"0000000000000000000000000000000000000000000000000000000000000000"},{"amount":10,"channelId":"0100000000000000000000000000000000000000000000000000000000000000"}],"nextTrampolineNodeId":"039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a3585","nextTrampolineAmount":17,"timestamp":{"iso":"2019-03-28T14:56:03.659Z","unix":1553784963}}""" - assert(serialization.write(ptrel) === expectedSerializedPtrel) + assert(serialization.write(ptrel) == expectedSerializedPtrel) system.eventStream.publish(ptrel) wsClient.expectMessage(expectedSerializedPtrel) val precv = PaymentReceived(ByteVector32.Zeroes, Seq(PaymentReceived.PartialPayment(21 msat, ByteVector32.Zeroes, TimestampMilli(1553784963659L)))) val expectedSerializedPrecv = """{"type":"payment-received","paymentHash":"0000000000000000000000000000000000000000000000000000000000000000","parts":[{"amount":21,"fromChannelId":"0000000000000000000000000000000000000000000000000000000000000000","timestamp":{"iso":"2019-03-28T14:56:03.659Z","unix":1553784963}}]}""" - assert(serialization.write(precv) === expectedSerializedPrecv) + assert(serialization.write(precv) == expectedSerializedPrecv) system.eventStream.publish(precv) wsClient.expectMessage(expectedSerializedPrecv) val pset = PaymentSettlingOnChain(fixedUUID, 21 msat, ByteVector32.One, timestamp = TimestampMilli(1553785442676L)) val expectedSerializedPset = """{"type":"payment-settling-onchain","id":"487da196-a4dc-4b1e-92b4-3e5e905e9f3f","amount":21,"paymentHash":"0100000000000000000000000000000000000000000000000000000000000000","timestamp":{"iso":"2019-03-28T15:04:02.676Z","unix":1553785442}}""" - assert(serialization.write(pset) === expectedSerializedPset) + assert(serialization.write(pset) == expectedSerializedPset) system.eventStream.publish(pset) wsClient.expectMessage(expectedSerializedPset) val chcr = ChannelCreated(system.deadLetters, system.deadLetters, bobNodeId, isInitiator = true, ByteVector32.One, FeeratePerKw(25 sat), Some(FeeratePerKw(20 sat))) val expectedSerializedChcr = """{"type":"channel-opened","remoteNodeId":"039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a3585","isInitiator":true,"temporaryChannelId":"0100000000000000000000000000000000000000000000000000000000000000","commitTxFeeratePerKw":25,"fundingTxFeeratePerKw":20}""" - assert(serialization.write(chcr) === expectedSerializedChcr) + assert(serialization.write(chcr) == expectedSerializedChcr) system.eventStream.publish(chcr) wsClient.expectMessage(expectedSerializedChcr) val chsc = ChannelStateChanged(system.deadLetters, ByteVector32.One, system.deadLetters, bobNodeId, OFFLINE, NORMAL, null) val expectedSerializedChsc = """{"type":"channel-state-changed","channelId":"0100000000000000000000000000000000000000000000000000000000000000","remoteNodeId":"039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a3585","previousState":"OFFLINE","currentState":"NORMAL"}""" - assert(serialization.write(chsc) === expectedSerializedChsc) + assert(serialization.write(chsc) == expectedSerializedChsc) system.eventStream.publish(chsc) wsClient.expectMessage(expectedSerializedChsc) val chcl = ChannelClosed(system.deadLetters, ByteVector32.One, Closing.NextRemoteClose(null, null), null) val expectedSerializedChcl = """{"type":"channel-closed","channelId":"0100000000000000000000000000000000000000000000000000000000000000","closingType":"NextRemoteClose"}""" - assert(serialization.write(chcl) === expectedSerializedChcl) + assert(serialization.write(chcl) == expectedSerializedChcl) system.eventStream.publish(chcl) wsClient.expectMessage(expectedSerializedChcl) @@ -1181,7 +1181,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM GenericTlv(UInt64(5), hex"1111") ))), Some(hex"2222")) val expectedSerializedMsgrcv = """{"type":"onion-message-received","pathId":"2222","encodedReplyPath":"039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a358502eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619020303f91e620504cde242df38d04599d8b4d4c555149cc742a5f12de452cbdd400013126a26221759247584d704b382a5789f1d8c5a","replyPath":{"introductionNodeId":"039dc0e0b1d25905e44fdf6f8e89755a5e219685840d0bc1d28d3308f9628a3585","blindingKey":"02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619","blindedNodes":[{"blindedPublicKey":"020303f91e620504cde242df38d04599d8b4d4c555149cc742a5f12de452cbdd40","encryptedPayload":"126a26221759247584d704b382a5789f1d8c5a"}]},"unknownTlvs":{"5":"1111"}}""" - assert(serialization.write(msgrcv) === expectedSerializedMsgrcv) + assert(serialization.write(msgrcv) == expectedSerializedMsgrcv) system.eventStream.publish(msgrcv) wsClient.expectMessage(expectedSerializedMsgrcv) }