@@ -427,17 +427,19 @@ class CommitmentsSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
427
427
toRemote = maxPendingHtlcAmount * 2 * 10 + Random .nextInt(1000000000 ).msat)
428
428
var c = CommitmentsSpec .makeCommitments(t.toLocal, t.toRemote, t.feeRatePerKw, t.dustLimit, t.isInitiator)
429
429
// Add some initial HTLCs to the pending list (bigger commit tx).
430
- for (_ <- 0 to t.pendingHtlcs) {
430
+ for (_ <- 1 to t.pendingHtlcs) {
431
431
val amount = Random .nextInt(maxPendingHtlcAmount.toLong.toInt).msat.max(1 msat)
432
432
val (_, cmdAdd) = makeCmdAdd(amount, randomKey().publicKey, f.currentBlockHeight)
433
433
sendAdd(c, cmdAdd, f.currentBlockHeight, feeConfNoMismatch) match {
434
434
case Right ((cc, _)) => c = cc
435
435
case Left (e) => ignore(s " $t -> could not setup initial htlcs: $e" )
436
436
}
437
437
}
438
- val (_, cmdAdd) = makeCmdAdd(c.availableBalanceForSend, randomKey().publicKey, f.currentBlockHeight)
439
- val result = sendAdd(c, cmdAdd, f.currentBlockHeight, feeConfNoMismatch)
440
- assert(result.isRight, s " $t -> $result" )
438
+ if (c.availableBalanceForSend > 0 .msat) {
439
+ val (_, cmdAdd) = makeCmdAdd(c.availableBalanceForSend, randomKey().publicKey, f.currentBlockHeight)
440
+ val result = sendAdd(c, cmdAdd, f.currentBlockHeight, feeConfNoMismatch)
441
+ assert(result.isRight, s " $t -> $result" )
442
+ }
441
443
}
442
444
}
443
445
@@ -455,18 +457,20 @@ class CommitmentsSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
455
457
toRemote = maxPendingHtlcAmount * 2 * 10 + Random .nextInt(1000000000 ).msat)
456
458
var c = CommitmentsSpec .makeCommitments(t.toLocal, t.toRemote, t.feeRatePerKw, t.dustLimit, t.isInitiator)
457
459
// Add some initial HTLCs to the pending list (bigger commit tx).
458
- for (_ <- 0 to t.pendingHtlcs) {
460
+ for (_ <- 1 to t.pendingHtlcs) {
459
461
val amount = Random .nextInt(maxPendingHtlcAmount.toLong.toInt).msat.max(1 msat)
460
462
val add = UpdateAddHtlc (randomBytes32(), c.remoteNextHtlcId, amount, randomBytes32(), CltvExpiry (f.currentBlockHeight), TestConstants .emptyOnionPacket, None )
461
463
receiveAdd(c, add, feeConfNoMismatch) match {
462
464
case Right (cc) => c = cc
463
465
case Left (e) => ignore(s " $t -> could not setup initial htlcs: $e" )
464
466
}
465
467
}
466
- val add = UpdateAddHtlc (randomBytes32(), c.remoteNextHtlcId, c.availableBalanceForReceive, randomBytes32(), CltvExpiry (f.currentBlockHeight), TestConstants .emptyOnionPacket, None )
467
- receiveAdd(c, add, feeConfNoMismatch) match {
468
- case Right (_) => ()
469
- case Left (e) => fail(s " $t -> $e" )
468
+ if (c.availableBalanceForReceive > 0 .msat) {
469
+ val add = UpdateAddHtlc (randomBytes32(), c.remoteNextHtlcId, c.availableBalanceForReceive, randomBytes32(), CltvExpiry (f.currentBlockHeight), TestConstants .emptyOnionPacket, None )
470
+ receiveAdd(c, add, feeConfNoMismatch) match {
471
+ case Right (_) => ()
472
+ case Left (e) => fail(s " $t -> $e" )
473
+ }
470
474
}
471
475
}
472
476
}
0 commit comments