Skip to content

Commit

Permalink
Fix to basic splice gossip test
Browse files Browse the repository at this point in the history
- This test demonstrates that local channels update their capacity, but we can not test the remote node (carol) because the ChannelAnnouncement is ignored because it has a duplicate scid. After PR ACINQ#2941 we can fix this test.
  • Loading branch information
remyers committed Dec 12, 2024
1 parent 1c6424f commit df17db2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,23 @@ class GossipIntegrationSpec extends ThreeNodesIntegrationSpec {
val scid_bc = getChannelData(bob, channelId_bc).asInstanceOf[DATA_NORMAL].shortIds.real.asInstanceOf[RealScidStatus.Final].realScid

// splice in to increase capacity of alice->bob channel
spliceIn(alice, bob, channelId_ab, 100_000 sat, None).asInstanceOf[RES_SPLICE].fundingTxId
spliceIn(alice, channelId_ab, 100_000 sat, None).asInstanceOf[RES_SPLICE].fundingTxId

// verify that the new capacity and scid are correctly propagated
eventually {
val scid_ab1 = getChannelData(alice, channelId_ab).asInstanceOf[DATA_NORMAL].shortIds.real.asInstanceOf[RealScidStatus.Final].realScid
/// assert(scid_ab != scid_ab1)
val channelData_alice1 = getChannelData(alice, channelId_ab).asInstanceOf[DATA_NORMAL]
val channelData_bob1 = getChannelData(bob, channelId_ab).asInstanceOf[DATA_NORMAL]
assert(channelData_alice1.commitments.latest.capacity == 200_000.sat)
assert(channelData_bob1.commitments.latest.capacity == 200_000.sat)
assert(channelData_alice1.shortIds.real.toOption.get == channelData_bob1.shortIds.real.toOption.get)
//assert(getRouterData(alice).channels(scid_ab1).capacity == 200_000.sat)
//assert(getRouterData(bob).channels(scid_ab1).capacity == 200_000.sat)
//assert(getRouterData(carol).channels(scid_ab1).capacity == 200_000.sat)
val scid_ab1 = getChannelData(alice, channelId_ab).asInstanceOf[DATA_NORMAL].shortIds.real.asInstanceOf[RealScidStatus.Final].realScid
val ann_splice = getRouterData(alice).channels(scid_ab1)
assert(ann_splice.capacity == 200_000.sat)
assert(getRouterData(bob).channels(scid_ab1) == ann_splice)
// TODO: after PR 2941, the slice ChannelAnnouncement will have a new scid and not be ignore by carol
assert(getRouterData(carol).spentChannels.exists(_._2 == ann_splice.shortChannelId))
// assert(scid_ab != scid_ab1)
// assert(getRouterData(carol).channels(scid_ab1).capacity == 200_000.sat)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ object MinimalNodeFixture extends Assertions with Eventually with IntegrationPat
sender.expectMsgType[OpenChannelResponse.Created]
}

def spliceIn(node1: MinimalNodeFixture, node2: MinimalNodeFixture, channelId: ByteVector32, amountIn: Satoshi, pushAmount_opt: Option[MilliSatoshi])(implicit system: ActorSystem): CommandResponse[CMD_SPLICE] = {
def spliceIn(node1: MinimalNodeFixture, channelId: ByteVector32, amountIn: Satoshi, pushAmount_opt: Option[MilliSatoshi])(implicit system: ActorSystem): CommandResponse[CMD_SPLICE] = {
val sender = TestProbe("sender")
val spliceIn = SpliceIn(additionalLocalFunding = amountIn, pushAmount = pushAmount_opt.getOrElse(0.msat))
val cmd = CMD_SPLICE(sender.ref.toTyped, spliceIn_opt = Some(spliceIn), spliceOut_opt = None, requestFunding_opt = None)
Expand Down Expand Up @@ -324,6 +324,13 @@ object MinimalNodeFixture extends Assertions with Eventually with IntegrationPat
case None => timers.startSingleTimer(watch, 10 millis)
}
Behaviors.same
case watch: ZmqWatcher.WatchExternalChannelSpent =>
knownFundingTxs().find(_.txIn.exists(_.outPoint.txid == watch.txId)) match {
case Some(nextFundingTx) =>
watch.replyTo ! ZmqWatcher.WatchExternalChannelSpentTriggered(watch.shortChannelId, nextFundingTx)
case None => timers.startSingleTimer(watch, 10 millis)
}
Behaviors.same
case _ =>
Behaviors.same
}
Expand Down

0 comments on commit df17db2

Please sign in to comment.