1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-22 22:25:26 +01:00

enforcing sequential zero-based htlc ids

This commit is contained in:
pm47 2017-02-10 16:55:43 +01:00
parent cb5189b3c7
commit 2b479aade6
21 changed files with 183 additions and 179 deletions

View file

@ -242,7 +242,7 @@ class Channel(val them: ActorRef, val blockchain: ActorRef, router: ActorRef, re
val commitments = Commitments(params.localParams, params.remoteParams,
LocalCommit(0, localSpec, PublishableTxs(signedLocalCommitTx, Nil)), RemoteCommit(0, remoteSpec, remoteCommitTx.tx.txid, remoteFirstPerCommitmentPoint),
LocalChanges(Nil, Nil, Nil), RemoteChanges(Nil, Nil),
localCurrentHtlcId = 0L,
localNextHtlcId = 0L, remoteNextHtlcId = 0L,
remoteNextCommitInfo = Right(null), // TODO: we will receive their next per-commitment point in the next message, so we temporarily put an empty byte array
commitInput, ShaChain.init, channelId = 0) // TODO: we will compute the channelId at the next step, so we temporarily put 0
context.system.eventStream.publish(ChannelIdAssigned(self, commitments.anchorId, Satoshi(params.fundingSatoshis)))
@ -276,7 +276,7 @@ class Channel(val them: ActorRef, val blockchain: ActorRef, router: ActorRef, re
val commitments = Commitments(params.localParams, params.remoteParams,
LocalCommit(0, localSpec, PublishableTxs(signedLocalCommitTx, Nil)), remoteCommit,
LocalChanges(Nil, Nil, Nil), RemoteChanges(Nil, Nil),
localCurrentHtlcId = 0L,
localNextHtlcId = 0L, remoteNextHtlcId = 0L,
remoteNextCommitInfo = Right(null), // TODO: we will receive their next per-commitment point in the next message, so we temporarily put an empty byte array
commitInput, ShaChain.init, channelId = 0)
context.system.eventStream.publish(ChannelIdAssigned(self, commitments.anchorId, Satoshi(params.fundingSatoshis)))
@ -395,7 +395,7 @@ class Channel(val them: ActorRef, val blockchain: ActorRef, router: ActorRef, re
case Event(c: CMD_ADD_HTLC, d: DATA_NORMAL) if d.localShutdown.isDefined =>
handleCommandError(sender, new RuntimeException("cannot send new htlcs, closing in progress"))
case Event(c@CMD_ADD_HTLC(amountMsat, rHash, expiry, route, origin, id_opt, do_commit), d@DATA_NORMAL(params, commitments, _)) =>
case Event(c@CMD_ADD_HTLC(amountMsat, rHash, expiry, route, origin, do_commit), d@DATA_NORMAL(params, commitments, _)) =>
Try(Commitments.sendAdd(commitments, c)) match {
case Success((commitments1, add)) =>
relayer ! Binding(add, origin)

View file

@ -85,11 +85,7 @@ case class BITCOIN_FUNDING_OTHER_CHANNEL_SPENT(channelId: Long) extends BitcoinE
*/
sealed trait Command
/**
* @param id should only be provided in tests otherwise it will be assigned automatically
*/
final case class CMD_ADD_HTLC(amountMsat: Long, paymentHash: BinaryData, expiry: Long, onion: BinaryData = BinaryData("00" * 1254), origin: Origin = Local, id: Option[Long] = None, commit: Boolean = false) extends Command
final case class CMD_ADD_HTLC(amountMsat: Long, paymentHash: BinaryData, expiry: Long, onion: BinaryData = BinaryData("00" * 1254), origin: Origin = Local, commit: Boolean = false) extends Command
final case class CMD_FULFILL_HTLC(id: Long, r: BinaryData, commit: Boolean = false) extends Command
final case class CMD_FAIL_HTLC(id: Long, reason: String, commit: Boolean = false) extends Command
case object CMD_SIGN extends Command

View file

@ -32,7 +32,7 @@ case class RemoteCommit(index: Long, spec: CommitmentSpec, txid: BinaryData, rem
case class Commitments(localParams: LocalParams, remoteParams: RemoteParams,
localCommit: LocalCommit, remoteCommit: RemoteCommit,
localChanges: LocalChanges, remoteChanges: RemoteChanges,
localCurrentHtlcId: Long,
localNextHtlcId: Long, remoteNextHtlcId: Long,
remoteNextCommitInfo: Either[RemoteCommit, Point],
commitInput: InputInfo,
remotePerCommitmentSecrets: ShaChain, channelId: Long) {
@ -91,14 +91,17 @@ object Commitments extends Logging {
throw new RuntimeException(s"insufficient funds: to-local=${reduced.toRemoteMsat / 1000} reserve=${commitments.remoteParams.channelReserveSatoshis} available=${available / 1000}")
}
val id = cmd.id.getOrElse(commitments.localCurrentHtlcId + 1)
val add = UpdateAddHtlc(commitments.channelId, id, cmd.amountMsat, cmd.expiry, cmd.paymentHash, cmd.onion)
val commitments1 = addLocalProposal(commitments, add).copy(localCurrentHtlcId = id)
val add = UpdateAddHtlc(commitments.channelId, commitments.localNextHtlcId, cmd.amountMsat, cmd.expiry, cmd.paymentHash, cmd.onion)
val commitments1 = addLocalProposal(commitments, add).copy(localNextHtlcId = commitments.localNextHtlcId + 1)
(commitments1, add)
}
def receiveAdd(commitments: Commitments, add: UpdateAddHtlc): Commitments = {
if (add.id != commitments.remoteNextHtlcId) {
throw new RuntimeException(s"unexpected htlc id: actual=${add.id} expected=${commitments.remoteNextHtlcId}")
}
val blockCount = Globals.blockCount.get()
// if we are the final payee, we need a reasonable amount of time to pull the funds before the sender can get refunded
val minExpiry = blockCount + 3
@ -129,7 +132,7 @@ object Commitments extends Logging {
throw new RuntimeException(s"insufficient funds: to-remote=${reduced.toRemoteMsat / 1000} reserve=${commitments.localParams.channelReserveSatoshis} available=${available / 1000}")
}
addRemoteProposal(commitments, add)
addRemoteProposal(commitments, add).copy(remoteNextHtlcId = commitments.remoteNextHtlcId + 1)
}
def sendFulfill(commitments: Commitments, cmd: CMD_FULFILL_HTLC): (Commitments, UpdateFulfillHtlc) = {

View file

@ -1,6 +1,6 @@
# Simple test that we can commit an HTLC
# Initial state: A=1000000 sat, B=0, both fee rates=10000 sat
A:offer 1,1000000,9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
# Initial state: A=1000000 sat, B=1000000 sat, both fee rates=10000 sat
A:offer 1000000,9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
B:recvoffer
A:commit
B:recvcommit

View file

@ -1,30 +1,30 @@
***A***
LOCAL COMMITS:
Commit 1:
Offered htlcs: (1,1000000)
Offered htlcs: (0,1000000)
Received htlcs:
Balance us: 999000000
Balance them: 0
Balance them: 1000000000
Fee rate: 10000
REMOTE COMMITS:
Commit 1:
Offered htlcs:
Received htlcs: (1,1000000)
Balance us: 0
Received htlcs: (0,1000000)
Balance us: 1000000000
Balance them: 999000000
Fee rate: 10000
***B***
LOCAL COMMITS:
Commit 1:
Offered htlcs:
Received htlcs: (1,1000000)
Balance us: 0
Received htlcs: (0,1000000)
Balance us: 1000000000
Balance them: 999000000
Fee rate: 10000
REMOTE COMMITS:
Commit 1:
Offered htlcs: (1,1000000)
Offered htlcs: (0,1000000)
Received htlcs:
Balance us: 999000000
Balance them: 0
Balance them: 1000000000
Fee rate: 10000

View file

@ -1,7 +1,7 @@
# Simple test that we can commit two HTLCs
# Initial state: A=1000000 sat, B=0, both fee rates=10000 sat
A:offer 1,1000000,7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c
A:offer 3,2000000,6016bcc377c93692f2fe19fbad47eee6fb8f4cc98c56e935db5edb69806d84f6
# Initial state: A=1000000 sat, B=1000000 sat, both fee rates=10000 sat
A:offer 1000000,7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c
A:offer 2000000,6016bcc377c93692f2fe19fbad47eee6fb8f4cc98c56e935db5edb69806d84f6
A:commit
B:recvoffer
B:recvoffer

View file

@ -1,30 +1,30 @@
***A***
LOCAL COMMITS:
Commit 1:
Offered htlcs: (1,1000000) (3,2000000)
Offered htlcs: (0,1000000) (1,2000000)
Received htlcs:
Balance us: 997000000
Balance them: 0
Balance them: 1000000000
Fee rate: 10000
REMOTE COMMITS:
Commit 1:
Offered htlcs:
Received htlcs: (1,1000000) (3,2000000)
Balance us: 0
Received htlcs: (0,1000000) (1,2000000)
Balance us: 1000000000
Balance them: 997000000
Fee rate: 10000
***B***
LOCAL COMMITS:
Commit 1:
Offered htlcs:
Received htlcs: (1,1000000) (3,2000000)
Balance us: 0
Received htlcs: (0,1000000) (1,2000000)
Balance us: 1000000000
Balance them: 997000000
Fee rate: 10000
REMOTE COMMITS:
Commit 1:
Offered htlcs: (1,1000000) (3,2000000)
Offered htlcs: (0,1000000) (1,2000000)
Received htlcs:
Balance us: 997000000
Balance them: 0
Balance them: 1000000000
Fee rate: 10000

View file

@ -1,6 +1,6 @@
# Simple test that we can fulfill (remove) an HTLC after fully settled.
# Initial state: A=1000000 sat, B=0, both fee rates=10000 sat
A:offer 1,1000000,b8928207364d445daa42f4ba8be0ef661b8d7190206c01f6ee8281566b3dec0a
# Initial state: A=1000000 sat, B=1000000 sat, both fee rates=10000 sat
A:offer 1000000,b8928207364d445daa42f4ba8be0ef661b8d7190206c01f6ee8281566b3dec0a
B:recvoffer
A:commit
B:recvcommit
@ -9,7 +9,7 @@ B:commit
A:recvcommit
B:recvrevoke
B:fulfill 1,60303ae22b998861bce3b28f33eec1be758a213c86c93c076dbe9f558c11c752
B:fulfill 0,60303ae22b998861bce3b28f33eec1be758a213c86c93c076dbe9f558c11c752
B:commit
A:recvremove
A:recvcommit

View file

@ -4,13 +4,13 @@ LOCAL COMMITS:
Offered htlcs:
Received htlcs:
Balance us: 999000000
Balance them: 1000000
Balance them: 1001000000
Fee rate: 10000
REMOTE COMMITS:
Commit 2:
Offered htlcs:
Received htlcs:
Balance us: 1000000
Balance us: 1001000000
Balance them: 999000000
Fee rate: 10000
***B***
@ -18,7 +18,7 @@ LOCAL COMMITS:
Commit 2:
Offered htlcs:
Received htlcs:
Balance us: 1000000
Balance us: 1001000000
Balance them: 999000000
Fee rate: 10000
REMOTE COMMITS:
@ -26,5 +26,5 @@ REMOTE COMMITS:
Offered htlcs:
Received htlcs:
Balance us: 999000000
Balance them: 1000000
Balance them: 1001000000
Fee rate: 10000

View file

@ -1,12 +1,12 @@
# Test A can commit twice; queueing two commits onto B's queue.
# Initial state: A=1000000 sat, B=0, both fee rates=10000 sat
A:offer 1,1000000,7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c
A:offer 1000000,7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c
B:recvoffer
A:commit
B:recvcommit
A:recvrevoke
A:offer 3,2000000,6016bcc377c93692f2fe19fbad47eee6fb8f4cc98c56e935db5edb69806d84f6
A:offer 2000000,6016bcc377c93692f2fe19fbad47eee6fb8f4cc98c56e935db5edb69806d84f6
B:recvoffer
A:commit
B:recvcommit

View file

@ -1,30 +1,30 @@
***A***
LOCAL COMMITS:
Commit 1:
Offered htlcs: (1,1000000) (3,2000000)
Offered htlcs: (0,1000000) (1,2000000)
Received htlcs:
Balance us: 997000000
Balance them: 0
Balance them: 1000000000
Fee rate: 10000
REMOTE COMMITS:
Commit 2:
Offered htlcs:
Received htlcs: (1,1000000) (3,2000000)
Balance us: 0
Received htlcs: (0,1000000) (1,2000000)
Balance us: 1000000000
Balance them: 997000000
Fee rate: 10000
***B***
LOCAL COMMITS:
Commit 2:
Offered htlcs:
Received htlcs: (1,1000000) (3,2000000)
Balance us: 0
Received htlcs: (0,1000000) (1,2000000)
Balance us: 1000000000
Balance them: 997000000
Fee rate: 10000
REMOTE COMMITS:
Commit 1:
Offered htlcs: (1,1000000) (3,2000000)
Offered htlcs: (0,1000000) (1,2000000)
Received htlcs:
Balance us: 997000000
Balance them: 0
Balance them: 1000000000
Fee rate: 10000

View file

@ -1,11 +1,9 @@
# Offers which cross over still get resolved.
# Initial state: A=1000000 sat, B=0, both fee rates=10000 sat
A:send 500000000
# Intermediate state: A=500000 sat, B=500000 sat, both fee rates=10000 sat
# Initial state: A=1000000 sat, B=1000000, both fee rates=10000 sat
A:offer 1,1000000,7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c
A:offer 1000000,7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c
A:commit
B:offer 2,2000000,6016bcc377c93692f2fe19fbad47eee6fb8f4cc98c56e935db5edb69806d84f6
B:offer 2000000,6016bcc377c93692f2fe19fbad47eee6fb8f4cc98c56e935db5edb69806d84f6
B:recvoffer
B:recvcommit
B:commit

View file

@ -1,30 +1,30 @@
***A***
LOCAL COMMITS:
Commit 3:
Offered htlcs: (1,1000000)
Received htlcs: (2,2000000)
Balance us: 499000000
Balance them: 498000000
Commit 1:
Offered htlcs: (0,1000000)
Received htlcs: (0,2000000)
Balance us: 999000000
Balance them: 998000000
Fee rate: 10000
REMOTE COMMITS:
Commit 4:
Offered htlcs: (2,2000000)
Received htlcs: (1,1000000)
Balance us: 498000000
Balance them: 499000000
Commit 2:
Offered htlcs: (0,2000000)
Received htlcs: (0,1000000)
Balance us: 998000000
Balance them: 999000000
Fee rate: 10000
***B***
LOCAL COMMITS:
Commit 4:
Offered htlcs: (2,2000000)
Received htlcs: (1,1000000)
Balance us: 498000000
Balance them: 499000000
Commit 2:
Offered htlcs: (0,2000000)
Received htlcs: (0,1000000)
Balance us: 998000000
Balance them: 999000000
Fee rate: 10000
REMOTE COMMITS:
Commit 3:
Offered htlcs: (1,1000000)
Received htlcs: (2,2000000)
Balance us: 499000000
Balance them: 498000000
Commit 1:
Offered htlcs: (0,1000000)
Received htlcs: (0,2000000)
Balance us: 999000000
Balance them: 998000000
Fee rate: 10000

View file

@ -1,10 +1,8 @@
# Commits which cross over still get resolved.
# Initial state: A=1000000 sat, B=0, both fee rates=10000 sat
A:send 500000000
# Intermediate state: A=500000 sat, B=500000 sat, both fee rates=10000 sat
# Initial state: A=1000000 sat, B=1000000, both fee rates=10000 sat
A:offer 1,1000000,7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c
B:offer 2,2000000,6016bcc377c93692f2fe19fbad47eee6fb8f4cc98c56e935db5edb69806d84f6
A:offer 1000000,7b3d979ca8330a94fa7e9e1b466d8b99e0bcdea1ec90596c0dcc8d7ef6b4300c
B:offer 2000000,6016bcc377c93692f2fe19fbad47eee6fb8f4cc98c56e935db5edb69806d84f6
A:commit
B:commit

View file

@ -1,30 +1,30 @@
***A***
LOCAL COMMITS:
Commit 4:
Offered htlcs: (1,1000000)
Received htlcs: (2,2000000)
Balance us: 499000000
Balance them: 498000000
Commit 2:
Offered htlcs: (0,1000000)
Received htlcs: (0,2000000)
Balance us: 999000000
Balance them: 998000000
Fee rate: 10000
REMOTE COMMITS:
Commit 4:
Offered htlcs: (2,2000000)
Received htlcs: (1,1000000)
Balance us: 498000000
Balance them: 499000000
Commit 2:
Offered htlcs: (0,2000000)
Received htlcs: (0,1000000)
Balance us: 998000000
Balance them: 999000000
Fee rate: 10000
***B***
LOCAL COMMITS:
Commit 4:
Offered htlcs: (2,2000000)
Received htlcs: (1,1000000)
Balance us: 498000000
Balance them: 499000000
Commit 2:
Offered htlcs: (0,2000000)
Received htlcs: (0,1000000)
Balance us: 998000000
Balance them: 999000000
Fee rate: 10000
REMOTE COMMITS:
Commit 4:
Offered htlcs: (1,1000000)
Received htlcs: (2,2000000)
Balance us: 499000000
Balance them: 498000000
Commit 2:
Offered htlcs: (0,1000000)
Received htlcs: (0,2000000)
Balance us: 999000000
Balance them: 998000000
Fee rate: 10000

View file

@ -52,13 +52,27 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
sender.send(alice, CMD_ADD_HTLC(50000000, h, 400144))
sender.expectMsg("ok")
val htlc = alice2bob.expectMsgType[UpdateAddHtlc]
assert(htlc.id == 1 && htlc.paymentHash == h)
assert(htlc.id == 0 && htlc.paymentHash == h)
awaitCond(alice.stateData == initialState.copy(
commitments = initialState.commitments.copy(localCurrentHtlcId = 1, localChanges = initialState.commitments.localChanges.copy(proposed = htlc :: Nil))))
commitments = initialState.commitments.copy(localNextHtlcId = 1, localChanges = initialState.commitments.localChanges.copy(proposed = htlc :: Nil))))
relayer.expectMsg(Binding(htlc, origin = Local))
}
}
test("recv CMD_ADD_HTLC (incrementing ids)") { case (alice, _, alice2bob, _, _, _, relayer) =>
within(30 seconds) {
val initialState = alice.stateData.asInstanceOf[DATA_NORMAL]
val sender = TestProbe()
val h = BinaryData("00112233445566778899aabbccddeeff")
for (i <- 0 until 10) {
sender.send(alice, CMD_ADD_HTLC(50000000, h, 400144))
sender.expectMsg("ok")
val htlc = alice2bob.expectMsgType[UpdateAddHtlc]
assert(htlc.id == i && htlc.paymentHash == h)
}
}
}
test("recv CMD_ADD_HTLC (relayed htlc)") { case (alice, _, alice2bob, _, _, _, relayer) =>
within(30 seconds) {
val initialState = alice.stateData.asInstanceOf[DATA_NORMAL]
@ -69,9 +83,9 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
sender.send(alice, cmd)
sender.expectMsg("ok")
val htlc = alice2bob.expectMsgType[UpdateAddHtlc]
assert(htlc.id == 1 && htlc.paymentHash == h)
assert(htlc.id == 0 && htlc.paymentHash == h)
awaitCond(alice.stateData == initialState.copy(
commitments = initialState.commitments.copy(localCurrentHtlcId = 1, localChanges = initialState.commitments.localChanges.copy(proposed = htlc :: Nil))))
commitments = initialState.commitments.copy(localNextHtlcId = 1, localChanges = initialState.commitments.localChanges.copy(proposed = htlc :: Nil))))
relayer.expectMsg(Binding(htlc, origin = Relayed(originHtlc)))
}
}
@ -177,16 +191,33 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv UpdateAddHtlc") { case (_, bob, _, _, _, _, _) =>
within(30 seconds) {
val initialData = bob.stateData.asInstanceOf[DATA_NORMAL]
val htlc = UpdateAddHtlc(0, 42, 150000, 400144, BinaryData("00112233445566778899aabbccddeeff"), "")
val htlc = UpdateAddHtlc(0, 0, 150000, 400144, BinaryData("00112233445566778899aabbccddeeff"), "")
bob ! htlc
awaitCond(bob.stateData == initialData.copy(commitments = initialData.commitments.copy(remoteChanges = initialData.commitments.remoteChanges.copy(proposed = initialData.commitments.remoteChanges.proposed :+ htlc))))
awaitCond(bob.stateData == initialData.copy(commitments = initialData.commitments.copy(remoteChanges = initialData.commitments.remoteChanges.copy(proposed = initialData.commitments.remoteChanges.proposed :+ htlc), remoteNextHtlcId = 1)))
}
}
test("recv UpdateAddHtlc (unexpected id)") { case (_, bob, _, bob2alice, _, bob2blockchain, _) =>
within(30 seconds) {
val tx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.publishableTxs.commitTx.tx
val htlc = UpdateAddHtlc(0, 42, 150000, 400144, BinaryData("00112233445566778899aabbccddeeff"), "")
bob ! htlc.copy(id = 0)
bob ! htlc.copy(id = 1)
bob ! htlc.copy(id = 2)
bob ! htlc.copy(id = 3)
bob ! htlc.copy(id = 42)
val error = bob2alice.expectMsgType[Error]
assert(new String(error.data) === "unexpected htlc id: actual=42 expected=4")
awaitCond(bob.stateName == CLOSING)
bob2blockchain.expectMsg(PublishAsap(tx))
bob2blockchain.expectMsgType[WatchConfirmed]
}
}
test("recv UpdateAddHtlc (expiry too small)") { case (_, bob, alice2bob, bob2alice, _, bob2blockchain, _) =>
within(30 seconds) {
val tx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.publishableTxs.commitTx.tx
val htlc = UpdateAddHtlc(0, 42, 150000, expiry = 1, BinaryData("00112233445566778899aabbccddeeff"), "")
val htlc = UpdateAddHtlc(0, 0, 150000, expiry = 1, BinaryData("00112233445566778899aabbccddeeff"), "")
alice2bob.forward(bob, htlc)
val error = bob2alice.expectMsgType[Error]
assert(new String(error.data) === "expiry too small: required=400003 actual=1 (blockCount=400000)")
@ -199,7 +230,7 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv UpdateAddHtlc (value too small)") { case (_, bob, alice2bob, bob2alice, _, bob2blockchain, _) =>
within(30 seconds) {
val tx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.publishableTxs.commitTx.tx
val htlc = UpdateAddHtlc(0, 42, 150, expiry = 400144, BinaryData("00112233445566778899aabbccddeeff"), "")
val htlc = UpdateAddHtlc(0, 0, 150, expiry = 400144, BinaryData("00112233445566778899aabbccddeeff"), "")
alice2bob.forward(bob, htlc)
val error = bob2alice.expectMsgType[Error]
assert(new String(error.data) === "htlc value too small: min=1000")
@ -212,7 +243,7 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv UpdateAddHtlc (insufficient funds)") { case (_, bob, alice2bob, bob2alice, _, bob2blockchain, _) =>
within(30 seconds) {
val tx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.publishableTxs.commitTx.tx
val htlc = UpdateAddHtlc(0, 42, Long.MaxValue, 400144, BinaryData("00112233445566778899aabbccddeeff"), "")
val htlc = UpdateAddHtlc(0, 0, Long.MaxValue, 400144, BinaryData("00112233445566778899aabbccddeeff"), "")
alice2bob.forward(bob, htlc)
val error = bob2alice.expectMsgType[Error]
assert(new String(error.data) === "insufficient funds: to-remote=800000 reserve=20000 available=780000")
@ -225,10 +256,10 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv UpdateAddHtlc (insufficient funds w/ pending htlcs 1/2)") { case (_, bob, alice2bob, bob2alice, _, bob2blockchain, _) =>
within(30 seconds) {
val tx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.publishableTxs.commitTx.tx
alice2bob.forward(bob, UpdateAddHtlc(0, 42, 500000000, 400144, "11" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 43, 200000000, 400144, "22" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 44, 80000000, 400144, "33" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 44, 10000000, 400144, "44" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 0, 500000000, 400144, "11" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 1, 200000000, 400144, "22" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 2, 80000000, 400144, "33" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 3, 10000000, 400144, "44" * 32, ""))
val error = bob2alice.expectMsgType[Error]
assert(new String(error.data) === "insufficient funds: to-remote=20000 reserve=20000 available=0")
awaitCond(bob.stateName == CLOSING)
@ -240,9 +271,9 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv UpdateAddHtlc (insufficient funds w/ pending htlcs 2/2)") { case (_, bob, alice2bob, bob2alice, _, bob2blockchain, _) =>
within(30 seconds) {
val tx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.publishableTxs.commitTx.tx
alice2bob.forward(bob, UpdateAddHtlc(0, 42, 300000000, 400144, "11" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 43, 300000000, 400144, "22" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 44, 500000000, 400144, "33" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 0, 300000000, 400144, "11" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 1, 300000000, 400144, "22" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 2, 500000000, 400144, "33" * 32, ""))
val error = bob2alice.expectMsgType[Error]
assert(new String(error.data) === "insufficient funds: to-remote=200000 reserve=20000 available=180000")
awaitCond(bob.stateName == CLOSING)
@ -254,7 +285,7 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv UpdateAddHtlc (over max inflight htlc value)") { case (alice, _, alice2bob, _, alice2blockchain, _, _) =>
within(30 seconds) {
val tx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.publishableTxs.commitTx.tx
alice2bob.forward(alice, UpdateAddHtlc(0, 42, 151000000, 400144, "11" * 32, ""))
alice2bob.forward(alice, UpdateAddHtlc(0, 0, 151000000, 400144, "11" * 32, ""))
val error = alice2bob.expectMsgType[Error]
assert(new String(error.data) === "in-flight htlcs hold too much value: value=151000000 max=150000000")
awaitCond(alice.stateName == CLOSING)
@ -268,9 +299,9 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
val tx = bob.stateData.asInstanceOf[DATA_NORMAL].commitments.localCommit.publishableTxs.commitTx.tx
// Bob accepts a maximum of 30 htlcs
for (i <- 0 until 30) {
alice2bob.forward(bob, UpdateAddHtlc(i, 42, 1000000, 400144, "11" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, i, 1000000, 400144, "11" * 32, ""))
}
alice2bob.forward(bob, UpdateAddHtlc(0, 42, 1000000, 400144, "11" * 32, ""))
alice2bob.forward(bob, UpdateAddHtlc(0, 30, 1000000, 400144, "11" * 32, ""))
val error = bob2alice.expectMsgType[Error]
assert(new String(error.data) === "too many accepted htlcs: value=31 max=30")
awaitCond(bob.stateName == CLOSING)
@ -608,7 +639,7 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
// actual test begins
val initialState = bob.stateData.asInstanceOf[DATA_NORMAL]
sender.send(bob, CMD_FULFILL_HTLC(htlc.id, "00" * 32))
sender.expectMsg("invalid htlc preimage for htlc id=1")
sender.expectMsg("invalid htlc preimage for htlc id=0")
assert(initialState == bob.stateData)
}
}
@ -945,8 +976,8 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
sign(alice, bob, alice2bob, bob2alice)
sign(bob, alice, bob2alice, alice2bob)
sign(alice, bob, alice2bob, bob2alice)
fulfillHtlc(2, ra2, bob, alice, bob2alice, alice2bob)
fulfillHtlc(1, rb1, alice, bob, alice2bob, bob2alice)
fulfillHtlc(1, ra2, bob, alice, bob2alice, alice2bob)
fulfillHtlc(0, rb1, alice, bob, alice2bob, bob2alice)
// at this point here is the situation from alice pov and what she should do when bob publishes his commit tx:
// balances :
@ -1053,8 +1084,8 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
sign(alice, bob, alice2bob, bob2alice)
sign(bob, alice, bob2alice, alice2bob)
sign(alice, bob, alice2bob, bob2alice)
fulfillHtlc(2, ra2, bob, alice, bob2alice, alice2bob)
fulfillHtlc(1, rb1, alice, bob, alice2bob, bob2alice)
fulfillHtlc(1, ra2, bob, alice, bob2alice, alice2bob)
fulfillHtlc(0, rb1, alice, bob, alice2bob, bob2alice)
// at this point here is the situation from alice pov and what she should do when she publishes his commit tx:
// balances :

View file

@ -77,7 +77,7 @@ class ShutdownStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
within(30 seconds) {
val sender = TestProbe()
val initialState = bob.stateData.asInstanceOf[DATA_SHUTDOWN]
sender.send(bob, CMD_FULFILL_HTLC(1, "11" * 32))
sender.send(bob, CMD_FULFILL_HTLC(0, "11" * 32))
sender.expectMsg("ok")
val fulfill = bob2alice.expectMsgType[UpdateFulfillHtlc]
awaitCond(bob.stateData == initialState.copy(commitments = initialState.commitments.copy(localChanges = initialState.commitments.localChanges.copy(initialState.commitments.localChanges.proposed :+ fulfill))))
@ -108,7 +108,7 @@ class ShutdownStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
within(30 seconds) {
val sender = TestProbe()
val initialState = alice.stateData.asInstanceOf[DATA_SHUTDOWN]
val fulfill = UpdateFulfillHtlc(0, 1, "11" * 32)
val fulfill = UpdateFulfillHtlc(0, 0, "11" * 32)
sender.send(alice, fulfill)
awaitCond(alice.stateData.asInstanceOf[DATA_SHUTDOWN].commitments == initialState.commitments.copy(remoteChanges = initialState.commitments.remoteChanges.copy(initialState.commitments.remoteChanges.proposed :+ fulfill)))
}
@ -186,7 +186,7 @@ class ShutdownStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
within(30 seconds) {
val sender = TestProbe()
// we need to have something to sign so we first send a fulfill and acknowledge (=sign) it
sender.send(bob, CMD_FULFILL_HTLC(1, "11" * 32))
sender.send(bob, CMD_FULFILL_HTLC(0, "11" * 32))
bob2alice.expectMsgType[UpdateFulfillHtlc]
bob2alice.forward(alice)
sender.send(bob, CMD_SIGN)
@ -227,7 +227,7 @@ class ShutdownStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv CommitSig") { case (alice, bob, alice2bob, bob2alice, _, _) =>
within(30 seconds) {
val sender = TestProbe()
sender.send(bob, CMD_FULFILL_HTLC(1, "11" * 32))
sender.send(bob, CMD_FULFILL_HTLC(0, "11" * 32))
sender.expectMsg("ok")
bob2alice.expectMsgType[UpdateFulfillHtlc]
bob2alice.forward(alice)
@ -266,7 +266,7 @@ class ShutdownStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv RevokeAndAck (with remaining htlcs on both sides)") { case (alice, bob, alice2bob, bob2alice, _, bob2blockchain) =>
within(30 seconds) {
fulfillHtlc(2, "22" * 32, bob, alice, bob2alice, alice2bob)
fulfillHtlc(1, "22" * 32, bob, alice, bob2alice, alice2bob)
sign(bob, alice, bob2alice, alice2bob)
val sender = TestProbe()
sender.send(alice, CMD_SIGN)
@ -284,8 +284,8 @@ class ShutdownStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv RevokeAndAck (with remaining htlcs on one side)") { case (alice, bob, alice2bob, bob2alice, _, bob2blockchain) =>
within(30 seconds) {
fulfillHtlc(1, "11" * 32, bob, alice, bob2alice, alice2bob)
fulfillHtlc(2, "22" * 32, bob, alice, bob2alice, alice2bob)
fulfillHtlc(0, "11" * 32, bob, alice, bob2alice, alice2bob)
fulfillHtlc(1, "22" * 32, bob, alice, bob2alice, alice2bob)
sign(bob, alice, bob2alice, alice2bob)
val sender = TestProbe()
sender.send(alice, CMD_SIGN)
@ -303,8 +303,8 @@ class ShutdownStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
test("recv RevokeAndAck (no more htlcs on either side)") { case (alice, bob, alice2bob, bob2alice, _, bob2blockchain) =>
within(30 seconds) {
fulfillHtlc(1, "11" * 32, bob, alice, bob2alice, alice2bob)
fulfillHtlc(2, "22" * 32, bob, alice, bob2alice, alice2bob)
fulfillHtlc(0, "11" * 32, bob, alice, bob2alice, alice2bob)
fulfillHtlc(1, "22" * 32, bob, alice, bob2alice, alice2bob)
sign(bob, alice, bob2alice, alice2bob)
val sender = TestProbe()
sender.send(alice, CMD_SIGN)
@ -322,7 +322,7 @@ class ShutdownStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
within(30 seconds) {
val tx = bob.stateData.asInstanceOf[DATA_SHUTDOWN].commitments.localCommit.publishableTxs.commitTx.tx
val sender = TestProbe()
sender.send(bob, CMD_FULFILL_HTLC(1, "11" * 32))
sender.send(bob, CMD_FULFILL_HTLC(0, "11" * 32))
sender.expectMsg("ok")
bob2alice.expectMsgType[UpdateFulfillHtlc]
bob2alice.forward(alice)
@ -415,7 +415,7 @@ class ShutdownStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
assert(revokedTx.txOut.size == 4)
// bob fulfills one of the pending htlc (just so that he can have a new sig)
fulfillHtlc(1, "11" * 32, bob, alice, bob2alice, alice2bob)
fulfillHtlc(0, "11" * 32, bob, alice, bob2alice, alice2bob)
// bob and alice sign
sign(bob, alice, bob2alice, alice2bob)
sign(alice, bob, alice2bob, bob2alice)

View file

@ -173,11 +173,11 @@ class InteroperabilitySpec extends FunSuite with BeforeAndAfterAll {
peer2 = lncli.getPeers.head
_ = assert(peer2.their_amount + peer2.their_fee == 70000000 + 80000000)
// we send lightningd a HTLC
_ <- sendCommand(channelId, CMD_ADD_HTLC(70000000, Commitments.revocationHash(seed, 0), blockcount.toInt + 576, id = Some(42)))
_ <- sendCommand(channelId, CMD_ADD_HTLC(70000000, Commitments.revocationHash(seed, 0), blockcount.toInt + 576))
_ <- sendCommand(channelId, CMD_SIGN)
_ = Thread.sleep(500)
// and we ask lightingd to fulfill it
_ = lncli.fulfillhtlc(peer.peerid, 42, Commitments.revocationPreimage(seed, 0))
_ = lncli.fulfillhtlc(peer.peerid, 0, Commitments.revocationPreimage(seed, 0))
_ = Thread.sleep(500)
_ <- sendCommand(channelId, CMD_SIGN)
c <- listChannels.map(_.head).map(_.data.asInstanceOf[DATA_NORMAL].commitments)

View file

@ -37,7 +37,8 @@ class RustyTestsSpec extends TestKit(ActorSystem("test")) with Matchers with fix
val router = TestProbe()
val alice: TestFSMRef[State, Data, Channel] = TestFSMRef(new Channel(pipe, blockchainA, router.ref, relayer, Alice.channelParams, Bob.id))
val bob: TestFSMRef[State, Data, Channel] = TestFSMRef(new Channel(pipe, blockchainB, router.ref, relayer, Bob.channelParams, Alice.id))
alice ! INPUT_INIT_FUNDER(TestConstants.fundingSatoshis, 0)
// alice and bob will both have 1 000 000 sat
alice ! INPUT_INIT_FUNDER(2000000, 1000000000)
bob ! INPUT_INIT_FUNDEE()
pipe ! (alice, bob)
within(30 seconds) {

View file

@ -23,9 +23,8 @@ import fr.acinq.eclair.transactions.{IN, OUT}
*/
class SynchronizationPipe(latch: CountDownLatch) extends Actor with ActorLogging with Stash {
val offer = "(.):offer ([0-9]+),([0-9]+),([0-9a-f]+)".r
val offer = "(.):offer ([0-9]+),([0-9a-f]+)".r
val fulfill = "(.):fulfill ([0-9]+),([0-9a-f]+)".r
val send = "(.):send ([0-9]+)".r
val commit = "(.):commit".r
val feechange = "(.):feechange".r
val recv = "(.):recv.*".r
@ -39,8 +38,8 @@ class SynchronizationPipe(latch: CountDownLatch) extends Actor with ActorLogging
def resolve(x: String) = if (x == "A") a else b
script match {
case offer(x, id, amount, rhash) :: rest =>
resolve(x) ! CMD_ADD_HTLC(amount.toInt, BinaryData(rhash), 144, id = Some(id.toLong))
case offer(x, amount, rhash) :: rest =>
resolve(x) ! CMD_ADD_HTLC(amount.toInt, BinaryData(rhash), 144)
exec(rest, a, b)
case fulfill(x, id, r) :: rest =>
resolve(x) ! CMD_FULFILL_HTLC(id.toInt, BinaryData(r))
@ -48,28 +47,6 @@ class SynchronizationPipe(latch: CountDownLatch) extends Actor with ActorLogging
case commit(x) :: rest =>
resolve(x) ! CMD_SIGN
exec(rest, a, b)
case send(x, amount) :: rest =>
// this is a macro for sending a given amount including commits and fulfill
val sender = x
val recipt = if (x == "A") "B" else "A"
val r: BinaryData = Crypto.sha256(scala.compat.Platform.currentTime.toString.getBytes)
val h: BinaryData = Crypto.sha256(r)
exec(s"$sender:offer 42,$amount,$h" ::
s"$recipt:recvoffer" ::
s"$sender:commit" ::
s"$recipt:recvcommit" ::
s"$sender:recvrevoke" ::
s"$recipt:commit" ::
s"$sender:recvcommit" ::
s"$recipt:recvrevoke" ::
s"$recipt:fulfill 42,$r" ::
s"$recipt:commit" ::
s"$sender:recvremove" ::
s"$sender:recvcommit" ::
s"$recipt:recvrevoke" ::
s"$sender:commit" ::
s"$recipt:recvcommit" ::
s"$sender:recvrevoke" :: rest, a, b)
/*case feechange(x) :: rest =>
resolve(x) ! CmdFeeChange()
exec(rest, a, b)*/

View file

@ -47,7 +47,7 @@ class RelayerSpec extends TestkitBaseClass {
test("add a channel") { case (relayer, _, _) =>
val sender = TestProbe()
val channel_bc = TestProbe()
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, 'upstreams)
val upstreams = sender.expectMsgType[Set[OutgoingChannel]]
assert(upstreams === Set(OutgoingChannel(channelId_bc, channel_bc.ref, nodeId_c.hash160)))
@ -57,12 +57,12 @@ class RelayerSpec extends TestkitBaseClass {
val sender = TestProbe()
val channel_bc = TestProbe()
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, 'upstreams)
val upstreams1 = sender.expectMsgType[Set[OutgoingChannel]]
assert(upstreams1 === Set(OutgoingChannel(channelId_bc, channel_bc.ref, nodeId_c.hash160)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, SHUTDOWN, NEGOTIATING, DATA_NEGOTIATING(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), null, null, null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, SHUTDOWN, NEGOTIATING, DATA_NEGOTIATING(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), null, null, null)))
sender.send(relayer, 'upstreams)
val upstreams2 = sender.expectMsgType[Set[OutgoingChannel]]
assert(upstreams2 === Set.empty)
@ -72,12 +72,12 @@ class RelayerSpec extends TestkitBaseClass {
val sender = TestProbe()
val channel_bc = TestProbe()
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, 'upstreams)
val upstreams1 = sender.expectMsgType[Set[OutgoingChannel]]
assert(upstreams1 === Set(OutgoingChannel(channelId_bc, channel_bc.ref, nodeId_c.hash160)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, NORMAL, CLOSING, DATA_CLOSING(Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), None, Some(null), None, None, Nil)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, NORMAL, CLOSING, DATA_CLOSING(Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), None, Some(null), None, None, Nil)))
sender.send(relayer, 'upstreams)
val upstreams2 = sender.expectMsgType[Set[OutgoingChannel]]
assert(upstreams2 === Set.empty)
@ -111,7 +111,7 @@ class RelayerSpec extends TestkitBaseClass {
UpdateAddHtlc(channelId = channelId_ab, id = 123456, cmd.amountMsat, cmd.expiry, cmd.paymentHash, cmd.onion)
}
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, add_ab)
sender.expectNoMsg(1 second)
@ -175,8 +175,8 @@ class RelayerSpec extends TestkitBaseClass {
UpdateAddHtlc(channelId = channelId_ab, id = 123456, cmd.amountMsat, cmd.expiry, cmd.paymentHash, cmd.onion)
}
sender.send(relayer, ChannelChangedState(channel_ab.ref, null, nodeId_a, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_ab), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, ChannelChangedState(channel_ab.ref, null, nodeId_a, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_ab), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, add_ab)
val cmd_bc = channel_bc.expectMsgType[CMD_ADD_HTLC]
val add_bc = UpdateAddHtlc(channelId = channelId_bc, id = 987451, amountMsat = cmd_bc.amountMsat, expiry = cmd_bc.expiry, paymentHash = cmd_bc.paymentHash, onionRoutingPacket = cmd_bc.onion)
@ -227,8 +227,8 @@ class RelayerSpec extends TestkitBaseClass {
UpdateAddHtlc(channelId = channelId_ab, id = 123456, cmd.amountMsat, cmd.expiry, cmd.paymentHash, cmd.onion)
}
sender.send(relayer, ChannelChangedState(channel_ab.ref, null, nodeId_a, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_ab), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, ChannelChangedState(channel_ab.ref, null, nodeId_a, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_ab), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, add_ab)
val cmd_bc = channel_bc.expectMsgType[CMD_ADD_HTLC]
val add_bc = UpdateAddHtlc(channelId = channelId_bc, id = 987451, amountMsat = cmd_bc.amountMsat, expiry = cmd_bc.expiry, paymentHash = cmd_bc.paymentHash, onionRoutingPacket = cmd_bc.onion)
@ -277,8 +277,8 @@ class RelayerSpec extends TestkitBaseClass {
UpdateAddHtlc(channelId = channelId_ab, id = 123456, cmd.amountMsat, cmd.expiry, cmd.paymentHash, cmd.onion)
}
sender.send(relayer, ChannelChangedState(channel_ab.ref, null, nodeId_a, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_ab), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, ChannelChangedState(channel_ab.ref, null, nodeId_a, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_ab), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, add_ab)
val cmd_bc = channel_bc.expectMsgType[CMD_ADD_HTLC]
val add_bc = UpdateAddHtlc(channelId = channelId_bc, id = 987451, amountMsat = cmd_bc.amountMsat, expiry = cmd_bc.expiry, paymentHash = cmd_bc.paymentHash, onionRoutingPacket = cmd_bc.onion)
@ -306,8 +306,8 @@ class RelayerSpec extends TestkitBaseClass {
UpdateAddHtlc(channelId = channelId_ab, id = 123456, cmd.amountMsat, cmd.expiry, cmd.paymentHash, cmd.onion)
}
sender.send(relayer, ChannelChangedState(channel_ab.ref, null, nodeId_a, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_ab), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, ChannelChangedState(channel_ab.ref, null, nodeId_a, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_ab), null)))
sender.send(relayer, ChannelChangedState(channel_bc.ref, null, nodeId_c, WAIT_FOR_FUNDING_LOCKED, NORMAL, DATA_NORMAL(null, Commitments(null, null, null, null, null, null, 0, 0, null, null, null, channelId_bc), null)))
sender.send(relayer, add_ab)
val cmd_bc = channel_bc.expectMsgType[CMD_ADD_HTLC]
val add_bc = UpdateAddHtlc(channelId = channelId_bc, id = 987451, amountMsat = cmd_bc.amountMsat, expiry = cmd_bc.expiry, paymentHash = cmd_bc.paymentHash, onionRoutingPacket = cmd_bc.onion)