Skip to content

Commit 806d277

Browse files
committed
Improve tests
1 parent 439643c commit 806d277

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForAcceptChannelStateSpec.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS
8080
import f._
8181
val accept = bob2alice.expectMsgType[AcceptChannel]
8282
// Since https://github.com/lightningnetwork/lightning-rfc/pull/714 we must include an empty upfront_shutdown_script.
83-
assert(accept.tlvStream.get[ChannelTlv.UpfrontShutdownScriptTlv] === Some(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.empty)))
83+
assert(accept.upfrontShutdownScript_opt === Some(ByteVector.empty))
8484
assert(accept.channelType_opt === Some(ChannelTypes.Standard))
8585
bob2alice.forward(alice)
8686
awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL)
@@ -92,6 +92,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS
9292
assert(accept.channelType_opt === Some(ChannelTypes.AnchorOutputs))
9393
bob2alice.forward(alice)
9494
awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL)
95+
assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType === ChannelTypes.AnchorOutputs)
9596
}
9697

9798
test("recv AcceptChannel (channel type not set)", Tag(ChannelStateTestsTags.AnchorOutputs)) { f =>
@@ -102,6 +103,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS
102103
// they both activated anchor outputs so it is the default choice anyway.
103104
bob2alice.forward(alice, accept.copy(tlvStream = TlvStream(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.empty))))
104105
awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL)
106+
assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType === ChannelTypes.AnchorOutputs)
105107
}
106108

107109
test("recv AcceptChannel (non-default channel type)", Tag(ChannelStateTestsTags.AnchorOutputs), Tag("standard-channel-type")) { f =>
@@ -111,6 +113,7 @@ class WaitForAcceptChannelStateSpec extends TestKitBaseClass with FixtureAnyFunS
111113
assert(accept.channelType_opt === Some(ChannelTypes.Standard))
112114
bob2alice.forward(alice, accept)
113115
awaitCond(alice.stateName == WAIT_FOR_FUNDING_INTERNAL)
116+
assert(alice.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_INTERNAL].channelFeatures.channelType === ChannelTypes.Standard)
114117
}
115118

116119
test("recv AcceptChannel (non-default channel type not set)", Tag(ChannelStateTestsTags.AnchorOutputs), Tag("standard-channel-type")) { f =>

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/a/WaitForOpenChannelStateSpec.scala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui
4949

5050
import setup._
5151
val channelConfig = ChannelConfig.standard
52-
val (aliceParams, bobParams, channelType) = computeFeatures(setup, test.tags)
52+
val (aliceParams, bobParams, defaultChannelType) = computeFeatures(setup, test.tags)
53+
val channelType = if (test.tags.contains("standard-channel-type")) ChannelTypes.Standard else defaultChannelType
5354
val initialFeeratePerKw = if (channelType == ChannelTypes.AnchorOutputs) TestConstants.anchorOutputsFeeratePerKw else TestConstants.feeratePerKw
5455
val aliceInit = Init(aliceParams.initFeatures)
5556
val bobInit = Init(bobParams.initFeatures)
@@ -65,11 +66,12 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui
6566
import f._
6667
val open = alice2bob.expectMsgType[OpenChannel]
6768
// Since https://github.com/lightningnetwork/lightning-rfc/pull/714 we must include an empty upfront_shutdown_script.
68-
assert(open.tlvStream.get[ChannelTlv.UpfrontShutdownScriptTlv] === Some(ChannelTlv.UpfrontShutdownScriptTlv(ByteVector.empty)))
69+
assert(open.upfrontShutdownScript_opt === Some(ByteVector.empty))
6970
// We always send a channel type, even for standard channels.
7071
assert(open.channelType_opt === Some(ChannelTypes.Standard))
7172
alice2bob.forward(bob)
7273
awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED)
74+
assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.Standard)
7375
}
7476

7577
test("recv OpenChannel (anchor outputs)", Tag(ChannelStateTestsTags.AnchorOutputs)) { f =>
@@ -78,6 +80,16 @@ class WaitForOpenChannelStateSpec extends TestKitBaseClass with FixtureAnyFunSui
7880
assert(open.channelType_opt === Some(ChannelTypes.AnchorOutputs))
7981
alice2bob.forward(bob)
8082
awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED)
83+
assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.AnchorOutputs)
84+
}
85+
86+
test("recv OpenChannel (non-default channel type)", Tag(ChannelStateTestsTags.AnchorOutputs), Tag("standard-channel-type")) { f =>
87+
import f._
88+
val open = alice2bob.expectMsgType[OpenChannel]
89+
assert(open.channelType_opt === Some(ChannelTypes.Standard))
90+
alice2bob.forward(bob)
91+
awaitCond(bob.stateName == WAIT_FOR_FUNDING_CREATED)
92+
assert(bob.stateData.asInstanceOf[DATA_WAIT_FOR_FUNDING_CREATED].channelFeatures.channelType === ChannelTypes.Standard)
8193
}
8294

8395
test("recv OpenChannel (invalid chain)") { f =>

0 commit comments

Comments
 (0)