Skip to content

Commit 781c349

Browse files
committed
shorter test
1 parent 0476f07 commit 781c349

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

eclair-core/src/test/scala/fr/acinq/eclair/io/SwitchboardSpec.scala

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,12 @@ class SwitchboardSpec extends TestKitBaseClass with AnyFunSuiteLike {
165165
sendFeatures(nodeParams, List(ChannelCodecsSpec.normal), remoteNodeId, nodeParams.features.initFeatures(), expectedSync = false)
166166
}
167167

168-
def dummyDataNormal(capacity: Satoshi, remoteNodeId: PublicKey): DATA_NORMAL = {
169-
val channelFeatures = ChannelFeatures(Features.DualFunding)
170-
val localParams = LocalParams(nodeId = null, fundingKeyPath = null, dustLimit = null, maxHtlcValueInFlightMsat = 1000 msat, initialRequestedChannelReserve_opt = None, htlcMinimum = null, toSelfDelay = null, maxAcceptedHtlcs = 1, isChannelOpener = true, paysCommitTxFees = true, upfrontShutdownScript_opt = null, walletStaticPaymentBasepoint = None, initFeatures = null)
171-
val remoteParams = RemoteParams(nodeId = remoteNodeId, dustLimit = null, maxHtlcValueInFlightMsat = UInt64(1000), initialRequestedChannelReserve_opt = None, htlcMinimum = null, toSelfDelay = null, maxAcceptedHtlcs = 1, revocationBasepoint = null, paymentBasepoint = null, delayedPaymentBasepoint = null, htlcBasepoint = null, initFeatures = null, upfrontShutdownScript_opt = null)
172-
val channelFlags = ChannelFlags(announceChannel = true)
173-
val params = ChannelParams(channelId = null, channelConfig = null, channelFeatures = channelFeatures, localParams = localParams, remoteParams = remoteParams, channelFlags = channelFlags)
174-
val commitTx = CommitTx(input = InputInfo(outPoint = OutPoint(hash= TxHash(ByteVector32.Zeroes), index = 0), txOut = TxOut(amount = capacity, publicKeyScript = ByteVector.empty), redeemScript = ByteVector.empty), tx = null)
175-
val commitTxAndRemoteSig = CommitTxAndRemoteSig(commitTx, ByteVector64.Zeroes)
176-
val localCommit = LocalCommit(index = 0, spec = null, commitTxAndRemoteSig = commitTxAndRemoteSig, htlcTxsAndRemoteSigs = null)
177-
val remoteCommit = RemoteCommit(index = 0, spec = null, txid = null, remotePerCommitmentPoint = null)
178-
val active = Commitment(fundingTxIndex = 0, firstRemoteCommitIndex = 0, remoteFundingPubKey = null, localFundingStatus = null, remoteFundingStatus = null, localCommit = localCommit, remoteCommit = remoteCommit, nextRemoteCommit_opt = null)
179-
val commitments = Commitments(params = params, changes = null, active = List(active), inactive = Nil, remoteNextCommitInfo = null, remotePerCommitmentSecrets = null, originChannels = null, remoteChannelData_opt = null)
180-
DATA_NORMAL(commitments = commitments, aliases = null, lastAnnouncement_opt = None, channelUpdate = null, localShutdown = null, remoteShutdown = null, closingFeerates = null, spliceStatus = NoSplice)
168+
def dummyDataNormal(remoteNodeId: PublicKey, capacity: Satoshi): DATA_NORMAL = {
169+
val data = ChannelCodecsSpec.normal.modify(_.commitments.params.remoteParams.nodeId).setTo(remoteNodeId)
170+
.modify(_.commitments.active).apply(_.map(_.modify(_.localCommit.commitTxAndRemoteSig.commitTx.input.txOut.amount).setTo(capacity)))
171+
assert(data.remoteNodeId == remoteNodeId)
172+
assert(data.commitments.capacity == capacity)
173+
data
181174
}
182175

183176
test("only sync with top peers if no whitelist") {
@@ -186,10 +179,10 @@ class SwitchboardSpec extends TestKitBaseClass with AnyFunSuiteLike {
186179
val (probe, peer, peerConnection) = (TestProbe(), TestProbe(), TestProbe())
187180
val switchboard = TestActorRef(new Switchboard(nodeParams, FakePeerFactory(probe, peer)))
188181
switchboard ! Switchboard.Init(List(
189-
dummyDataNormal(Satoshi(500), alice),
190-
dummyDataNormal(Satoshi(600), alice),
191-
dummyDataNormal(Satoshi(1000), bob),
192-
dummyDataNormal(Satoshi(2000), carol),
182+
dummyDataNormal(alice, Satoshi(500)),
183+
dummyDataNormal(alice, Satoshi(600)),
184+
dummyDataNormal(bob, Satoshi(1000)),
185+
dummyDataNormal(carol, Satoshi(2000)),
193186
))
194187

195188
switchboard ! PeerConnection.Authenticated(peerConnection.ref, alice, outgoing = true)
@@ -211,10 +204,10 @@ class SwitchboardSpec extends TestKitBaseClass with AnyFunSuiteLike {
211204
val (probe, peer, peerConnection) = (TestProbe(), TestProbe(), TestProbe())
212205
val switchboard = TestActorRef(new Switchboard(nodeParams, FakePeerFactory(probe, peer)))
213206
switchboard ! Switchboard.Init(List(
214-
dummyDataNormal(Satoshi(500), alice),
215-
dummyDataNormal(Satoshi(600), alice),
216-
dummyDataNormal(Satoshi(1000), bob),
217-
dummyDataNormal(Satoshi(2000), carol),
207+
dummyDataNormal(alice, Satoshi(500)),
208+
dummyDataNormal(alice, Satoshi(600)),
209+
dummyDataNormal(bob, Satoshi(1000)),
210+
dummyDataNormal(carol, Satoshi(2000)),
218211
))
219212

220213
switchboard ! PeerConnection.Authenticated(peerConnection.ref, alice, outgoing = true)

0 commit comments

Comments
 (0)