Skip to content

Commit

Permalink
Refactor and improve some channel tests (#1654)
Browse files Browse the repository at this point in the history
* Add a few more tests around channel_reestablish scenarios.
* Enrich existing tests and refactor common parts.
  • Loading branch information
t-bast authored Jan 19, 2021
1 parent 9c4ab7d commit 81f15aa
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui
awaitCond(bob.stateName == CLOSED)
}


test("recv OpenChannel (reserve below dust)") { f =>
import f._
val open = alice2bob.expectMsgType[OpenChannel]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,15 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
sender.expectMsgType[RES_FAILURE[CMD_CLOSE, CannotCloseWithUnsignedOutgoingHtlcs]]
}

test("recv CMD_CLOSE (with unacked received htlcs)") { f =>
import f._
val sender = TestProbe()
addHtlc(50000000 msat, alice, bob, alice2bob, bob2alice)
bob ! CMD_CLOSE(sender.ref, None)
sender.expectMsgType[RES_SUCCESS[CMD_CLOSE]]
bob2alice.expectMsgType[Shutdown]
}

test("recv CMD_CLOSE (with invalid final script)") { f =>
import f._
val sender = TestProbe()
Expand Down Expand Up @@ -2002,6 +2011,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with

bob ! CMD_FULFILL_HTLC(htlc.id, r, commit = true)
bob2alice.expectMsgType[UpdateFulfillHtlc]
bob2alice.expectMsgType[CommitSig]
bob ! CurrentBlockCount((htlc.cltvExpiry - Bob.nodeParams.fulfillSafetyBeforeTimeout).toLong)

val ChannelErrorOccurred(_, _, _, _, LocalError(err), isFatal) = listener.expectMsgType[ChannelErrorOccurred]
Expand Down Expand Up @@ -2035,6 +2045,7 @@ class NormalStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with

bob ! CMD_FULFILL_HTLC(htlc.id, r, commit = false)
bob2alice.expectMsgType[UpdateFulfillHtlc]
bob2alice.expectNoMsg(500 millis)
bob ! CurrentBlockCount((htlc.cltvExpiry - Bob.nodeParams.fulfillSafetyBeforeTimeout).toLong)

val ChannelErrorOccurred(_, _, _, _, LocalError(err), isFatal) = listener.expectMsgType[ChannelErrorOccurred]
Expand Down
Loading

0 comments on commit 81f15aa

Please sign in to comment.