From 2dfcff1f31784670ca63336f68ea84fdfa2e4ab2 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Fri, 24 Jun 2016 14:57:24 +0200 Subject: [PATCH] Testing: Fix the wallet filler code. --- .../main/kotlin/com/r3corda/contracts/testing/WalletFiller.kt | 3 ++- .../kotlin/com/r3corda/node/services/WalletWithCashTest.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 b1ba2a87e2..ec7bec2404 100644 --- a/contracts/src/main/kotlin/com/r3corda/contracts/testing/WalletFiller.kt +++ b/contracts/src/main/kotlin/com/r3corda/contracts/testing/WalletFiller.kt @@ -71,11 +71,12 @@ private fun calculateRandomlySizedAmounts(howMuch: Amount, min: Int, m if (i < numStates - 1) { // Adjust the amount a bit up or down, to give more realistic amounts (not all identical). amounts[i] = baseSize + (baseSize / 2 * (rng.nextDouble() - 0.5)).toLong() - filledSoFar += baseSize + filledSoFar += amounts[i] } else { // Handle inexact rounding. amounts[i] = howMuch.quantity - filledSoFar } } + check(amounts.sum() == howMuch.quantity) return amounts } \ No newline at end of file diff --git a/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt b/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt index 1107f610ab..3cfe70e806 100644 --- a/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt +++ b/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt @@ -58,7 +58,7 @@ class WalletWithCashTest { assertEquals(29.01.DOLLARS `issued by` myPartyRef, state.amount) assertEquals(ALICE_PUBKEY, state.owner) - assertEquals(33.34.DOLLARS `issued by` myPartyRef, (w.states[2].state.data as Cash.State).amount) + assertEquals(35.38.DOLLARS `issued by` myPartyRef, (w.states[2].state.data as Cash.State).amount) assertEquals(35.61.DOLLARS `issued by` myPartyRef, (w.states[1].state.data as Cash.State).amount) }