mirror of
https://github.com/ACINQ/eclair.git
synced 2025-03-27 02:37:06 +01:00
Merge branch 'master' of github.com:ACINQ/eclair
This commit is contained in:
commit
759b65d5d3
5 changed files with 49 additions and 11 deletions
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>fr.acinq.eclair</groupId>
|
||||
<artifactId>eclair_2.11</artifactId>
|
||||
<version>0.2-gossip-SNAPSHOT</version>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>eclair-demo_2.11</artifactId>
|
||||
|
|
|
@ -128,7 +128,7 @@ object Commitments {
|
|||
}
|
||||
|
||||
def sendFail(commitments: Commitments, cmd: CMD_FAIL_HTLC): (Commitments, update_fail_htlc) = {
|
||||
commitments.theirChanges.acked.collectFirst { case u: update_add_htlc if u.id == cmd.id => u } match {
|
||||
commitments.ourCommit.spec.htlcs.collectFirst { case u: Htlc if u.add.id == cmd.id => u } match {
|
||||
case Some(htlc) =>
|
||||
val fail = update_fail_htlc(cmd.id, fail_reason(ByteString.copyFromUtf8(cmd.reason)))
|
||||
val commitments1 = addOurProposal(commitments, fail)
|
||||
|
@ -138,9 +138,8 @@ object Commitments {
|
|||
}
|
||||
|
||||
def receiveFail(commitments: Commitments, fail: update_fail_htlc): Commitments = {
|
||||
commitments.ourChanges.acked.collectFirst { case u: update_add_htlc if u.id == fail.id => u } match {
|
||||
case Some(htlc) =>
|
||||
addTheirProposal(commitments, fail)
|
||||
commitments.theirCommit.spec.htlcs.collectFirst { case u: Htlc if u.add.id == fail.id => u } match {
|
||||
case Some(htlc) => addTheirProposal(commitments, fail)
|
||||
case None => throw new RuntimeException(s"unknown htlc id=${fail.id}") // TODO : we should fail the channel
|
||||
}
|
||||
}
|
||||
|
@ -233,8 +232,8 @@ object Commitments {
|
|||
}
|
||||
|
||||
def makeOurTxTemplate(commitments: Commitments): TxTemplate = {
|
||||
Helpers.makeOurTxTemplate(commitments.ourParams, commitments.theirParams, commitments.ourCommit.publishableTx.txIn,
|
||||
Helpers.revocationHash(commitments.ourParams.shaSeed, commitments.ourCommit.index), commitments.ourCommit.spec)
|
||||
Helpers.makeOurTxTemplate(commitments.ourParams, commitments.theirParams, commitments.ourCommit.publishableTx.txIn,
|
||||
Helpers.revocationHash(commitments.ourParams.shaSeed, commitments.ourCommit.index), commitments.ourCommit.spec)
|
||||
}
|
||||
|
||||
def makeTheirTxTemplate(commitments: Commitments): TxTemplate = {
|
||||
|
|
|
@ -381,7 +381,7 @@ class NormalStateSpec extends TestKit(ActorSystem("test")) with fixture.FunSuite
|
|||
}
|
||||
}
|
||||
|
||||
test("recv update_fulfill_htlc") { case (alice, bob, alice2bob, bob2alice, _, _) =>
|
||||
test("recv update_fulfill_htlc (sender has not signed)") { case (alice, bob, alice2bob, bob2alice, _, _) =>
|
||||
within(30 seconds) {
|
||||
val sender = TestProbe()
|
||||
val (r, htlc) = addHtlc(500000, alice, bob, alice2bob, bob2alice)
|
||||
|
@ -400,6 +400,25 @@ class NormalStateSpec extends TestKit(ActorSystem("test")) with fixture.FunSuite
|
|||
}
|
||||
}
|
||||
|
||||
test("recv update_fulfill_htlc (sender has signed)") { case (alice, bob, alice2bob, bob2alice, _, _) =>
|
||||
within(30 seconds) {
|
||||
val sender = TestProbe()
|
||||
val (r, htlc) = addHtlc(500000, alice, bob, alice2bob, bob2alice)
|
||||
sign(alice, bob, alice2bob, bob2alice)
|
||||
sign(bob, alice, bob2alice, alice2bob)
|
||||
sender.send(bob, CMD_FULFILL_HTLC(htlc.id, r))
|
||||
sender.expectMsg("ok")
|
||||
val fulfill = bob2alice.expectMsgType[update_fulfill_htlc]
|
||||
|
||||
// actual test begins
|
||||
val initialState = alice.stateData.asInstanceOf[DATA_NORMAL]
|
||||
bob2alice.forward(alice)
|
||||
awaitCond(alice.stateData == initialState.copy(
|
||||
commitments = initialState.commitments.copy(theirChanges = initialState.commitments.theirChanges.copy(initialState.commitments.theirChanges.proposed :+ fulfill)),
|
||||
downstreams = Map()))
|
||||
}
|
||||
}
|
||||
|
||||
test("recv update_fulfill_htlc (unknown htlc id)") { case (alice, _, alice2bob, _, alice2blockchain, _) =>
|
||||
within(30 seconds) {
|
||||
val tx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.ourCommit.publishableTx
|
||||
|
@ -455,7 +474,7 @@ class NormalStateSpec extends TestKit(ActorSystem("test")) with fixture.FunSuite
|
|||
}
|
||||
}
|
||||
|
||||
test("recv update_fail_htlc") { case (alice, bob, alice2bob, bob2alice, _, _) =>
|
||||
test("recv update_fail_htlc (sender has not signed)") { case (alice, bob, alice2bob, bob2alice, _, _) =>
|
||||
within(30 seconds) {
|
||||
val sender = TestProbe()
|
||||
val (r, htlc) = addHtlc(500000, alice, bob, alice2bob, bob2alice)
|
||||
|
@ -474,6 +493,26 @@ class NormalStateSpec extends TestKit(ActorSystem("test")) with fixture.FunSuite
|
|||
}
|
||||
}
|
||||
|
||||
test("recv update_fail_htlc (sender has signed") { case (alice, bob, alice2bob, bob2alice, _, _) =>
|
||||
within(30 seconds) {
|
||||
val sender = TestProbe()
|
||||
val (r, htlc) = addHtlc(500000, alice, bob, alice2bob, bob2alice)
|
||||
sign(alice, bob, alice2bob, bob2alice)
|
||||
sign(bob, alice, bob2alice, alice2bob)
|
||||
|
||||
sender.send(bob, CMD_FAIL_HTLC(htlc.id, "some reason"))
|
||||
sender.expectMsg("ok")
|
||||
val fulfill = bob2alice.expectMsgType[update_fail_htlc]
|
||||
|
||||
// actual test begins
|
||||
val initialState = alice.stateData.asInstanceOf[DATA_NORMAL]
|
||||
bob2alice.forward(alice)
|
||||
awaitCond(alice.stateData == initialState.copy(
|
||||
commitments = initialState.commitments.copy(theirChanges = initialState.commitments.theirChanges.copy(initialState.commitments.theirChanges.proposed :+ fulfill)),
|
||||
downstreams = Map()))
|
||||
}
|
||||
}
|
||||
|
||||
test("recv update_fail_htlc (unknown htlc id)") { case (alice, _, alice2bob, _, alice2blockchain, _) =>
|
||||
within(30 seconds) {
|
||||
val tx = alice.stateData.asInstanceOf[DATA_NORMAL].commitments.ourCommit.publishableTx
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>fr.acinq.eclair</groupId>
|
||||
<artifactId>eclair_2.11</artifactId>
|
||||
<version>0.2-gossip-SNAPSHOT</version>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>lightning-types_2.11</artifactId>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>fr.acinq.eclair</groupId>
|
||||
<artifactId>eclair_2.11</artifactId>
|
||||
<version>0.2-gossip-SNAPSHOT</version>
|
||||
<version>0.2-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
|
|
Loading…
Add table
Reference in a new issue