mirror of
https://github.com/corda/corda.git
synced 2025-01-27 22:59:54 +00:00
Testing: Fix the wallet filler code.
This commit is contained in:
parent
8b24acf69e
commit
2dfcff1f31
@ -71,11 +71,12 @@ private fun calculateRandomlySizedAmounts(howMuch: Amount<Currency>, min: Int, m
|
|||||||
if (i < numStates - 1) {
|
if (i < numStates - 1) {
|
||||||
// Adjust the amount a bit up or down, to give more realistic amounts (not all identical).
|
// 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()
|
amounts[i] = baseSize + (baseSize / 2 * (rng.nextDouble() - 0.5)).toLong()
|
||||||
filledSoFar += baseSize
|
filledSoFar += amounts[i]
|
||||||
} else {
|
} else {
|
||||||
// Handle inexact rounding.
|
// Handle inexact rounding.
|
||||||
amounts[i] = howMuch.quantity - filledSoFar
|
amounts[i] = howMuch.quantity - filledSoFar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
check(amounts.sum() == howMuch.quantity)
|
||||||
return amounts
|
return amounts
|
||||||
}
|
}
|
@ -58,7 +58,7 @@ class WalletWithCashTest {
|
|||||||
assertEquals(29.01.DOLLARS `issued by` myPartyRef, state.amount)
|
assertEquals(29.01.DOLLARS `issued by` myPartyRef, state.amount)
|
||||||
assertEquals(ALICE_PUBKEY, state.owner)
|
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)
|
assertEquals(35.61.DOLLARS `issued by` myPartyRef, (w.states[1].state.data as Cash.State).amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user