mirror of
https://github.com/corda/corda.git
synced 2025-06-16 14:18:20 +00:00
Minor: Pass reference into fillWithSomeTestCash()
Reference is now a parameter to fillWithSomeTestCash() so that the caller can be clear on the reference to use.
This commit is contained in:
@ -5,6 +5,7 @@ import com.r3corda.core.contracts.Amount
|
|||||||
import com.r3corda.core.contracts.TransactionBuilder
|
import com.r3corda.core.contracts.TransactionBuilder
|
||||||
import com.r3corda.core.crypto.Party
|
import com.r3corda.core.crypto.Party
|
||||||
import com.r3corda.core.node.ServiceHub
|
import com.r3corda.core.node.ServiceHub
|
||||||
|
import com.r3corda.core.serialization.OpaqueBytes
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object WalletFiller {
|
object WalletFiller {
|
||||||
@ -18,7 +19,8 @@ object WalletFiller {
|
|||||||
* the central bank, well ... that'd be a different story altogether.
|
* the central bank, well ... that'd be a different story altogether.
|
||||||
*/
|
*/
|
||||||
fun fillWithSomeTestCash(services: ServiceHub, notary: Party, howMuch: Amount<Currency>, atLeastThisManyStates: Int = 3,
|
fun fillWithSomeTestCash(services: ServiceHub, notary: Party, howMuch: Amount<Currency>, atLeastThisManyStates: Int = 3,
|
||||||
atMostThisManyStates: Int = 10, rng: Random = Random()) {
|
atMostThisManyStates: Int = 10, rng: Random = Random(),
|
||||||
|
ref: OpaqueBytes = OpaqueBytes(ByteArray(1, { 0 }))) {
|
||||||
val amounts = calculateRandomlySizedAmounts(howMuch, atLeastThisManyStates, atMostThisManyStates, rng)
|
val amounts = calculateRandomlySizedAmounts(howMuch, atLeastThisManyStates, atMostThisManyStates, rng)
|
||||||
|
|
||||||
val myIdentity = services.storageService.myLegalIdentity
|
val myIdentity = services.storageService.myLegalIdentity
|
||||||
@ -29,7 +31,7 @@ object WalletFiller {
|
|||||||
val transactions = amounts.map { pennies ->
|
val transactions = amounts.map { pennies ->
|
||||||
// This line is what makes the cash self issued. We just use zero as our deposit reference: we don't need
|
// This line is what makes the cash self issued. We just use zero as our deposit reference: we don't need
|
||||||
// this field as there's no other database or source of truth we need to sync with.
|
// this field as there's no other database or source of truth we need to sync with.
|
||||||
val depositRef = myIdentity.ref(0)
|
val depositRef = myIdentity.ref(ref)
|
||||||
|
|
||||||
val issuance = TransactionBuilder()
|
val issuance = TransactionBuilder()
|
||||||
val freshKey = services.keyManagementService.freshKey()
|
val freshKey = services.keyManagementService.freshKey()
|
||||||
|
@ -5,6 +5,7 @@ import com.r3corda.core.contracts.*
|
|||||||
import com.r3corda.core.crypto.SecureHash
|
import com.r3corda.core.crypto.SecureHash
|
||||||
import com.r3corda.core.node.services.Wallet
|
import com.r3corda.core.node.services.Wallet
|
||||||
import com.r3corda.core.node.services.WalletService
|
import com.r3corda.core.node.services.WalletService
|
||||||
|
import com.r3corda.core.serialization.OpaqueBytes
|
||||||
import com.r3corda.core.serialization.SingletonSerializeAsToken
|
import com.r3corda.core.serialization.SingletonSerializeAsToken
|
||||||
import com.r3corda.core.utilities.loggerFor
|
import com.r3corda.core.utilities.loggerFor
|
||||||
import com.r3corda.core.utilities.trace
|
import com.r3corda.core.utilities.trace
|
||||||
|
@ -8,6 +8,7 @@ import com.r3corda.core.contracts.verifyToLedgerTransaction
|
|||||||
import com.r3corda.core.node.ServiceHub
|
import com.r3corda.core.node.ServiceHub
|
||||||
import com.r3corda.core.node.services.testing.MockKeyManagementService
|
import com.r3corda.core.node.services.testing.MockKeyManagementService
|
||||||
import com.r3corda.core.node.services.testing.MockStorageService
|
import com.r3corda.core.node.services.testing.MockStorageService
|
||||||
|
import com.r3corda.core.serialization.OpaqueBytes
|
||||||
import com.r3corda.core.testing.*
|
import com.r3corda.core.testing.*
|
||||||
import com.r3corda.core.utilities.BriefLogFormatter
|
import com.r3corda.core.utilities.BriefLogFormatter
|
||||||
import com.r3corda.node.internal.testing.WalletFiller
|
import com.r3corda.node.internal.testing.WalletFiller
|
||||||
@ -40,10 +41,11 @@ class NodeWalletServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
fun splits() {
|
fun splits() {
|
||||||
val (wallet, services) = make()
|
val (wallet, services) = make()
|
||||||
|
val ref = OpaqueBytes(ByteArray(1, {0}))
|
||||||
|
|
||||||
kms.nextKeys += Array(3) { ALICE_KEY }
|
kms.nextKeys += Array(3) { ALICE_KEY }
|
||||||
// Fix the PRNG so that we get the same splits every time.
|
// Fix the PRNG so that we get the same splits every time.
|
||||||
WalletFiller.fillWithSomeTestCash(services, DUMMY_NOTARY, 100.DOLLARS, 3, 3, Random(0L))
|
WalletFiller.fillWithSomeTestCash(services, DUMMY_NOTARY, 100.DOLLARS, 3, 3, Random(0L), ref)
|
||||||
|
|
||||||
val w = wallet.currentWallet
|
val w = wallet.currentWallet
|
||||||
assertEquals(3, w.states.size)
|
assertEquals(3, w.states.size)
|
||||||
|
Reference in New Issue
Block a user