diff --git a/contracts/src/main/kotlin/com/r3corda/contracts/testing/WalletFiller.kt b/contracts/src/main/kotlin/com/r3corda/contracts/testing/WalletFiller.kt index 2a9bd90fac..456b8dd391 100644 --- a/contracts/src/main/kotlin/com/r3corda/contracts/testing/WalletFiller.kt +++ b/contracts/src/main/kotlin/com/r3corda/contracts/testing/WalletFiller.kt @@ -66,6 +66,7 @@ private fun calculateRandomlySizedAmounts(howMuch: Amount, min: Int, m val numStates = min + Math.floor(rng.nextDouble() * (max - min)).toInt() val amounts = LongArray(numStates) val baseSize = howMuch.quantity / numStates + check(baseSize > 0) { baseSize } var filledSoFar = 0L for (i in 0..numStates - 1) { if (i < numStates - 1) { @@ -76,6 +77,7 @@ private fun calculateRandomlySizedAmounts(howMuch: Amount, min: Int, m // Handle inexact rounding. amounts[i] = howMuch.quantity - filledSoFar } + check(amounts[i] >= 0) { amounts[i] } } check(amounts.sum() == howMuch.quantity) return amounts