Skip to content

Commit

Permalink
Add check for cmd failure during concurrent splice tests
Browse files Browse the repository at this point in the history
  • Loading branch information
remyers committed Jul 27, 2023
1 parent 1f6af5d commit f51710e
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ class NormalQuiescentStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteL
test("initiate quiescence concurrently (no pending changes)") { f =>
import f._

val cmd = CMD_SPLICE(TestProbe().ref, spliceIn_opt = Some(SpliceIn(500_000 sat, pushAmount = 0 msat)), spliceOut_opt = None)
val sender = TestProbe()
val cmd = CMD_SPLICE(sender.ref, spliceIn_opt = Some(SpliceIn(500_000 sat, pushAmount = 0 msat)), spliceOut_opt = None)
alice ! cmd
alice2bob.expectMsgType[Stfu]
bob ! cmd
Expand All @@ -389,13 +390,15 @@ class NormalQuiescentStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteL
alice2bob.forward(bob)
alice2bob.expectMsgType[SpliceInit]
eventually(assert(bob.stateData.asInstanceOf[DATA_NORMAL].spliceStatus == SpliceStatus.NonInitiatorQuiescent))
sender.expectMsgType[RES_FAILURE[CMD_SPLICE, ConcurrentRemoteSplice]]
}

test("initiate quiescence concurrently (pending changes on initiator side)") { f =>
import f._

addHtlc(10_000 msat, alice, bob, alice2bob, bob2alice)
val cmd = CMD_SPLICE(TestProbe().ref, spliceIn_opt = Some(SpliceIn(500_000 sat, pushAmount = 0 msat)), spliceOut_opt = None)
val sender = TestProbe()
val cmd = CMD_SPLICE(sender.ref, spliceIn_opt = Some(SpliceIn(500_000 sat, pushAmount = 0 msat)), spliceOut_opt = None)
alice ! cmd
alice2bob.expectNoMessage(100 millis) // alice isn't quiescent yet
bob ! cmd
Expand All @@ -405,14 +408,16 @@ class NormalQuiescentStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteL
alice2bob.expectMsgType[Stfu]
alice2bob.forward(bob)
assert(alice.stateData.asInstanceOf[DATA_NORMAL].spliceStatus == SpliceStatus.NonInitiatorQuiescent)
sender.expectMsgType[RES_FAILURE[CMD_SPLICE, ConcurrentRemoteSplice]]
bob2alice.expectMsgType[SpliceInit]
}

test("initiate quiescence concurrently (pending changes on non-initiator side)") { f =>
import f._

addHtlc(10_000 msat, bob, alice, bob2alice, alice2bob)
val cmd = CMD_SPLICE(TestProbe().ref, spliceIn_opt = Some(SpliceIn(500_000 sat, pushAmount = 0 msat)), spliceOut_opt = None)
val sender = TestProbe()
val cmd = CMD_SPLICE(sender.ref, spliceIn_opt = Some(SpliceIn(500_000 sat, pushAmount = 0 msat)), spliceOut_opt = None)
alice ! cmd
alice2bob.expectMsgType[Stfu]
bob ! cmd
Expand All @@ -422,6 +427,7 @@ class NormalQuiescentStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteL
bob2alice.expectMsgType[Stfu]
bob2alice.forward(alice)
assert(bob.stateData.asInstanceOf[DATA_NORMAL].spliceStatus == SpliceStatus.NonInitiatorQuiescent)
sender.expectMsgType[RES_FAILURE[CMD_SPLICE, ConcurrentRemoteSplice]]
alice2bob.expectMsgType[SpliceInit]
}

Expand Down

0 comments on commit f51710e

Please sign in to comment.