mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-23 22:46:44 +01:00
parent
41d1fc26a9
commit
4969845401
2 changed files with 24 additions and 2 deletions
|
@ -90,7 +90,9 @@ object Commitments extends Logging {
|
||||||
// let's compute the current commitment *as seen by them* with this change taken into account
|
// let's compute the current commitment *as seen by them* with this change taken into account
|
||||||
val add = UpdateAddHtlc(commitments.channelId, commitments.localNextHtlcId, cmd.amountMsat, cmd.paymentHash, cmd.expiry, cmd.onion)
|
val add = UpdateAddHtlc(commitments.channelId, commitments.localNextHtlcId, cmd.amountMsat, cmd.paymentHash, cmd.expiry, cmd.onion)
|
||||||
val commitments1 = addLocalProposal(commitments, add).copy(localNextHtlcId = commitments.localNextHtlcId + 1)
|
val commitments1 = addLocalProposal(commitments, add).copy(localNextHtlcId = commitments.localNextHtlcId + 1)
|
||||||
val reduced = CommitmentSpec.reduce(commitments1.remoteCommit.spec, commitments1.remoteChanges.acked, commitments1.localChanges.proposed)
|
// we need to base the next current commitment on the last sig we sent, even if we didn't yet receive their revocation
|
||||||
|
val remoteCommit1 = commitments1.remoteNextCommitInfo.left.toOption.map(_.nextRemoteCommit).getOrElse(commitments1.remoteCommit)
|
||||||
|
val reduced = CommitmentSpec.reduce(remoteCommit1.spec, commitments1.remoteChanges.acked, commitments1.localChanges.proposed)
|
||||||
|
|
||||||
val htlcValueInFlight = UInt64(reduced.htlcs.map(_.add.amountMsat).sum)
|
val htlcValueInFlight = UInt64(reduced.htlcs.map(_.add.amountMsat).sum)
|
||||||
if (htlcValueInFlight > commitments1.remoteParams.maxHtlcValueInFlightMsat) {
|
if (htlcValueInFlight > commitments1.remoteParams.maxHtlcValueInFlightMsat) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import akka.actor.Status.Failure
|
||||||
import akka.testkit.{TestFSMRef, TestProbe}
|
import akka.testkit.{TestFSMRef, TestProbe}
|
||||||
import fr.acinq.bitcoin.Crypto.Scalar
|
import fr.acinq.bitcoin.Crypto.Scalar
|
||||||
import fr.acinq.bitcoin.{BinaryData, Crypto, Satoshi, ScriptFlags, Transaction}
|
import fr.acinq.bitcoin.{BinaryData, Crypto, Satoshi, ScriptFlags, Transaction}
|
||||||
import fr.acinq.eclair.TestConstants.Bob
|
import fr.acinq.eclair.TestConstants.{Alice, Bob}
|
||||||
import fr.acinq.eclair.blockchain._
|
import fr.acinq.eclair.blockchain._
|
||||||
import fr.acinq.eclair.channel.states.StateTestsHelperMethods
|
import fr.acinq.eclair.channel.states.StateTestsHelperMethods
|
||||||
import fr.acinq.eclair.channel.{Data, State, _}
|
import fr.acinq.eclair.channel.{Data, State, _}
|
||||||
|
@ -212,6 +212,26 @@ class NormalStateSpec extends TestkitBaseClass with StateTestsHelperMethods {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("recv CMD_ADD_HTLC (while waiting for a revocation)") { case (alice, _, alice2bob, _, _, _, relayer) =>
|
||||||
|
within(30 seconds) {
|
||||||
|
val sender = TestProbe()
|
||||||
|
val add1 = CMD_ADD_HTLC(TestConstants.fundingSatoshis * 2/3 * 1000, "11" * 32, 400144)
|
||||||
|
sender.send(alice, add1)
|
||||||
|
sender.expectMsg("ok")
|
||||||
|
alice2bob.expectMsgType[UpdateAddHtlc]
|
||||||
|
relayer.expectMsgType[AddHtlcSucceeded]
|
||||||
|
sender.send(alice, CMD_SIGN)
|
||||||
|
sender.expectMsg("ok")
|
||||||
|
alice2bob.expectMsgType[CommitSig]
|
||||||
|
// this is over channel-capacity
|
||||||
|
val add2 = CMD_ADD_HTLC(TestConstants.fundingSatoshis * 2/3 * 1000, "22" * 32, 400144)
|
||||||
|
sender.send(alice, add2)
|
||||||
|
sender.expectMsgType[Failure]
|
||||||
|
relayer.expectMsgType[AddHtlcFailed]
|
||||||
|
alice2bob.expectNoMsg(200 millis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test("recv CMD_ADD_HTLC (while waiting for Shutdown)") { case (alice, _, alice2bob, _, alice2blockchain, _, _) =>
|
test("recv CMD_ADD_HTLC (while waiting for Shutdown)") { case (alice, _, alice2bob, _, alice2blockchain, _, _) =>
|
||||||
within(30 seconds) {
|
within(30 seconds) {
|
||||||
val sender = TestProbe()
|
val sender = TestProbe()
|
||||||
|
|
Loading…
Add table
Reference in a new issue