@@ -353,67 +353,73 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi
353
353
import f ._
354
354
connect(nodeParams, remoteNodeId, switchboard, router, connection, transport, peerConnection, peer)
355
355
356
- // The channel with A has a pending splice.
357
- val channelIdA = randomBytes32()
358
- val commitSigA1 = CommitSig (channelIdA, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (2 )))
359
- val commitSigA2 = CommitSig (channelIdA, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (2 )))
360
- // The channel with B has 2 pending splices.
361
- val channelIdB = randomBytes32()
362
- val commitSigB1 = CommitSig (channelIdB, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 )))
363
- val commitSigB2 = CommitSig (channelIdB, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 )))
364
- val commitSigB3 = CommitSig (channelIdB, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 )))
365
- // The channel with C doesn't have any pending splice.
366
- val channelIdC = randomBytes32()
367
- val commitSigC1 = CommitSig (channelIdC, randomBytes64(), Nil )
368
- // The channel with D doesn't have any pending splice, but the batch TLV is (incorrectly) set.
369
- val channelIdD = randomBytes32()
370
- val commitSigD1 = CommitSig (channelIdD, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (1 )))
356
+ // The first channel has a pending splice.
357
+ val channelId1 = randomBytes32()
358
+ val commitSigs1 = Seq (
359
+ CommitSig (channelId1, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (2 ))),
360
+ CommitSig (channelId1, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (2 ))),
361
+ )
362
+ // A second channel has 2 pending splices.
363
+ val channelId2 = randomBytes32()
364
+ val commitSigs2 = Seq (
365
+ CommitSig (channelId2, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 ))),
366
+ CommitSig (channelId2, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 ))),
367
+ CommitSig (channelId2, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 ))),
368
+ )
369
+ // Another channel doesn't have any pending splice.
370
+ val channelId3 = randomBytes32()
371
+ val commitSig3 = CommitSig (channelId3, randomBytes64(), Nil )
372
+ // Another channel doesn't have any pending splice, but the batch TLV is (incorrectly) set.
373
+ val channelId4 = randomBytes32()
374
+ val commitSig4 = CommitSig (channelId4, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (1 )))
371
375
372
376
// Older peers may not correctly group these messages on the wire: unrelated messages may be interleaved.
373
- // We start by receiving a partial batch from A and B .
374
- transport.send(peerConnection, commitSigA1 )
375
- transport.expectMsg(TransportHandler .ReadAck (commitSigA1 ))
376
- transport.send(peerConnection, commitSigB1 )
377
- transport.expectMsg(TransportHandler .ReadAck (commitSigB1 ))
378
- transport.send(peerConnection, commitSigB2 )
379
- transport.expectMsg(TransportHandler .ReadAck (commitSigB2 ))
377
+ // We start by receiving a partial batch from the first two channels .
378
+ transport.send(peerConnection, commitSigs1( 0 ) )
379
+ transport.expectMsg(TransportHandler .ReadAck (commitSigs1( 0 ) ))
380
+ transport.send(peerConnection, commitSigs2( 0 ) )
381
+ transport.expectMsg(TransportHandler .ReadAck (commitSigs2( 0 ) ))
382
+ transport.send(peerConnection, commitSigs2( 1 ) )
383
+ transport.expectMsg(TransportHandler .ReadAck (commitSigs2( 1 ) ))
380
384
peer.expectNoMessage(100 millis)
381
- // We then receive individual commit_sig messages from C and D .
382
- transport.send(peerConnection, commitSigC1 )
383
- transport.expectMsg(TransportHandler .ReadAck (commitSigC1 ))
384
- peer.expectMsg(commitSigC1 )
385
- transport.send(peerConnection, commitSigD1 )
386
- transport.expectMsg(TransportHandler .ReadAck (commitSigD1 ))
387
- peer.expectMsg(commitSigD1 )
388
- // Finally, we receive the end of A and B's batches.
389
- transport.send(peerConnection, commitSigA2 )
390
- transport.expectMsg(TransportHandler .ReadAck (commitSigA2 ))
391
- peer.expectMsg(CommitSigBatch (commitSigA1 :: commitSigA2 :: Nil ))
392
- transport.send(peerConnection, commitSigB3 )
393
- transport.expectMsg(TransportHandler .ReadAck (commitSigB3 ))
394
- peer.expectMsg(CommitSigBatch (commitSigB1 :: commitSigB2 :: commitSigB3 :: Nil ))
385
+ // We then receive individual commit_sig messages from the last two channels .
386
+ transport.send(peerConnection, commitSig3 )
387
+ transport.expectMsg(TransportHandler .ReadAck (commitSig3 ))
388
+ peer.expectMsg(commitSig3 )
389
+ transport.send(peerConnection, commitSig4 )
390
+ transport.expectMsg(TransportHandler .ReadAck (commitSig4 ))
391
+ peer.expectMsg(commitSig4 )
392
+ // Finally, we receive the end of the first two channels' batches.
393
+ transport.send(peerConnection, commitSigs1( 1 ) )
394
+ transport.expectMsg(TransportHandler .ReadAck (commitSigs1( 1 ) ))
395
+ peer.expectMsg(CommitSigBatch (commitSigs1 ))
396
+ transport.send(peerConnection, commitSigs2( 2 ) )
397
+ transport.expectMsg(TransportHandler .ReadAck (commitSigs2( 2 ) ))
398
+ peer.expectMsg(CommitSigBatch (commitSigs2 ))
395
399
peer.expectNoMessage(100 millis)
396
400
397
- // We then receive another batch of messages from A with unrelated channel messages in-between.
398
- val commitSigA3 = CommitSig (channelIdA, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 )))
399
- val commitSigA4 = CommitSig (channelIdA, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 )))
400
- val spliceLockedA = SpliceLocked (channelIdA, randomTxId())
401
- val commitSigA5 = CommitSig (channelIdA, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 )))
402
- transport.send(peerConnection, commitSigA3)
403
- transport.expectMsg(TransportHandler .ReadAck (commitSigA3))
404
- transport.send(peerConnection, commitSigA4)
405
- transport.expectMsg(TransportHandler .ReadAck (commitSigA4))
406
- transport.send(peerConnection, spliceLockedA)
407
- transport.expectMsg(TransportHandler .ReadAck (spliceLockedA))
408
- peer.expectMsg(spliceLockedA)
401
+ // We then receive another batch of messages from the first channel with unrelated channel messages in-between.
402
+ val commitSigs5 = Seq (
403
+ CommitSig (channelId1, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 ))),
404
+ CommitSig (channelId1, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 ))),
405
+ CommitSig (channelId1, randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (3 ))),
406
+ )
407
+ val spliceLocked = SpliceLocked (channelId1, randomTxId())
408
+ transport.send(peerConnection, commitSigs5(0 ))
409
+ transport.expectMsg(TransportHandler .ReadAck (commitSigs5(0 )))
410
+ transport.send(peerConnection, commitSigs5(1 ))
411
+ transport.expectMsg(TransportHandler .ReadAck (commitSigs5(1 )))
412
+ transport.send(peerConnection, spliceLocked)
413
+ transport.expectMsg(TransportHandler .ReadAck (spliceLocked))
414
+ peer.expectMsg(spliceLocked)
409
415
peer.expectNoMessage(100 millis)
410
- transport.send(peerConnection, commitSigA5 )
411
- transport.expectMsg(TransportHandler .ReadAck (commitSigA5 ))
412
- peer.expectMsg(CommitSigBatch (commitSigA3 :: commitSigA4 :: commitSigA5 :: Nil ))
416
+ transport.send(peerConnection, commitSigs5( 2 ) )
417
+ transport.expectMsg(TransportHandler .ReadAck (commitSigs5( 2 ) ))
418
+ peer.expectMsg(CommitSigBatch (commitSigs5 ))
413
419
peer.expectNoMessage(100 millis)
414
420
415
421
// We receive a batch that exceeds our threshold: we process them individually.
416
- val invalidCommitSigs = (0 until 30 ).map(_ => CommitSig (channelIdB , randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (30 ))))
422
+ val invalidCommitSigs = (0 until 30 ).map(_ => CommitSig (channelId2 , randomBytes64(), Nil , TlvStream (CommitSigTlv .BatchTlv (30 ))))
417
423
invalidCommitSigs.foreach(commitSig => {
418
424
transport.send(peerConnection, commitSig)
419
425
transport.expectMsg(TransportHandler .ReadAck (commitSig))
0 commit comments