mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-24 14:50:46 +01:00
Add test for duplicate temporary channel id (#1660)
This scenario was correctly handled, but we were missing test coverage.
This commit is contained in:
parent
dd8975aebe
commit
7343283f9f
2 changed files with 22 additions and 3 deletions
|
@ -296,7 +296,6 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
|
|||
context.system.eventStream.publish(ChannelCreated(self, peer, remoteNodeId, isFunder = false, open.temporaryChannelId, open.feeratePerKw, None))
|
||||
val fundingPubkey = keyManager.fundingPublicKey(localParams.fundingKeyPath).publicKey
|
||||
val channelKeyPath = keyManager.keyPath(localParams, channelVersion)
|
||||
// TODO: maybe also check uniqueness of temporary channel id
|
||||
val minimumDepth = Helpers.minDepthForFunding(nodeParams, open.fundingSatoshis)
|
||||
val accept = AcceptChannel(temporaryChannelId = open.temporaryChannelId,
|
||||
dustLimitSatoshis = localParams.dustLimit,
|
||||
|
@ -346,7 +345,6 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
|
|||
Helpers.validateParamsFunder(nodeParams, open, accept) match {
|
||||
case Left(t) => handleLocalError(t, d, Some(accept))
|
||||
case _ =>
|
||||
// TODO: check equality of temporaryChannelId? or should be done upstream
|
||||
val remoteParams = RemoteParams(
|
||||
nodeId = remoteNodeId,
|
||||
dustLimit = accept.dustLimitSatoshis,
|
||||
|
|
|
@ -21,7 +21,7 @@ import akka.actor.Status.Failure
|
|||
import akka.testkit.{TestFSMRef, TestProbe}
|
||||
import com.google.common.net.HostAndPort
|
||||
import fr.acinq.bitcoin.Crypto.PublicKey
|
||||
import fr.acinq.bitcoin.{Btc, SatoshiLong, Script}
|
||||
import fr.acinq.bitcoin.{Block, Btc, SatoshiLong, Script}
|
||||
import fr.acinq.eclair.FeatureSupport.Optional
|
||||
import fr.acinq.eclair.Features.{StaticRemoteKey, Wumbo}
|
||||
import fr.acinq.eclair.TestConstants._
|
||||
|
@ -237,6 +237,27 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with StateTe
|
|||
monitor.expectMsg(FSM.Transition(reconnectionTask, ReconnectionTask.CONNECTING, ReconnectionTask.IDLE))
|
||||
}
|
||||
|
||||
test("don't spawn a channel with duplicate temporary channel id") { f =>
|
||||
import f._
|
||||
|
||||
val probe = TestProbe()
|
||||
system.eventStream.subscribe(probe.ref, classOf[ChannelCreated])
|
||||
connect(remoteNodeId, peer, peerConnection)
|
||||
assert(peer.stateData.channels.isEmpty)
|
||||
|
||||
val open = wire.OpenChannel(Block.RegtestGenesisBlock.hash, randomBytes32, 25000 sat, 0 msat, 483 sat, UInt64(100), 1000 sat, 1 msat, TestConstants.feeratePerKw, CltvExpiryDelta(144), 10, randomKey.publicKey, randomKey.publicKey, randomKey.publicKey, randomKey.publicKey, randomKey.publicKey, randomKey.publicKey, 0)
|
||||
peerConnection.send(peer, open)
|
||||
awaitCond(peer.stateData.channels.nonEmpty)
|
||||
assert(probe.expectMsgType[ChannelCreated].temporaryChannelId === open.temporaryChannelId)
|
||||
peerConnection.expectMsgType[AcceptChannel]
|
||||
|
||||
// open_channel messages with the same temporary channel id should simply be ignored
|
||||
peerConnection.send(peer, open.copy(fundingSatoshis = 100000 sat, fundingPubkey = randomKey.publicKey))
|
||||
probe.expectNoMsg(100 millis)
|
||||
peerConnection.expectNoMsg(100 millis)
|
||||
assert(peer.stateData.channels.size === 1)
|
||||
}
|
||||
|
||||
test("don't spawn a wumbo channel if wumbo feature isn't enabled") { f =>
|
||||
import f._
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue