From ce859178ebbc6586d55855de48b1bfa75d6487ca Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Thu, 7 Dec 2017 18:12:25 +0000 Subject: [PATCH] Correct identities passed to generateSpend (#2199) Pass well known identities instead of confidential into `generateSpend()` --- .../net/corda/finance/contracts/asset/CashTests.kt | 9 +++------ .../corda/node/services/vault/NodeVaultServiceTest.kt | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/finance/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt b/finance/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt index 2cf9daa949..bb027e880c 100644 --- a/finance/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt +++ b/finance/src/test/kotlin/net/corda/finance/contracts/asset/CashTests.kt @@ -506,10 +506,9 @@ class CashTests { private fun makeSpend(services: ServiceHub, amount: Amount, dest: AbstractParty): WireTransaction { val ourIdentity = services.myInfo.singleIdentityAndCert() - val changeIdentity = services.keyManagementService.freshKeyAndCert(ourIdentity, false) val tx = TransactionBuilder(DUMMY_NOTARY) database.transaction { - Cash.generateSpend(services, tx, amount, changeIdentity, dest) + Cash.generateSpend(services, tx, amount, ourIdentity, dest) } return tx.toWireTransaction(services) } @@ -605,11 +604,10 @@ class CashTests { @Test fun generateSimpleSpendWithParties() { - val changeIdentity = ourServices.keyManagementService.freshKeyAndCert(ourServices.myInfo.singleIdentityAndCert(), false) database.transaction { val tx = TransactionBuilder(DUMMY_NOTARY) - Cash.generateSpend(ourServices, tx, 80.DOLLARS, changeIdentity, ALICE, setOf(MINI_CORP)) + Cash.generateSpend(ourServices, tx, 80.DOLLARS, ourServices.myInfo.singleIdentityAndCert(), ALICE, setOf(MINI_CORP)) assertEquals(vaultStatesUnconsumed.elementAt(2).ref, tx.inputStates()[0]) } @@ -818,12 +816,11 @@ class CashTests { fun multiSpend() { val tx = TransactionBuilder(DUMMY_NOTARY) database.transaction { - val changeIdentity = ourServices.keyManagementService.freshKeyAndCert(ourServices.myInfo.singleIdentityAndCert(), false) val payments = listOf( PartyAndAmount(miniCorpAnonymised, 400.DOLLARS), PartyAndAmount(CHARLIE_ANONYMISED, 150.DOLLARS) ) - Cash.generateSpend(ourServices, tx, payments, changeIdentity) + Cash.generateSpend(ourServices, tx, payments, ourServices.myInfo.singleIdentityAndCert()) } val wtx = tx.toWireTransaction(ourServices) fun out(i: Int) = wtx.getOutput(i) as Cash.State diff --git a/node/src/test/kotlin/net/corda/node/services/vault/NodeVaultServiceTest.kt b/node/src/test/kotlin/net/corda/node/services/vault/NodeVaultServiceTest.kt index 7bab864399..8002741b5c 100644 --- a/node/src/test/kotlin/net/corda/node/services/vault/NodeVaultServiceTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/vault/NodeVaultServiceTest.kt @@ -531,6 +531,7 @@ class NodeVaultServiceTest { val identity = services.myInfo.singleIdentityAndCert() val anonymousIdentity = services.keyManagementService.freshKeyAndCert(identity, false) + // We use a random key pair to pay to here, as we don't actually use the cash once sent val thirdPartyIdentity = AnonymousParty(generateKeyPair().public) val amount = Amount(1000, Issued(BOC.ref(1), GBP)) @@ -550,8 +551,7 @@ class NodeVaultServiceTest { database.transaction { val moveBuilder = TransactionBuilder(notary).apply { - val changeIdentity = services.keyManagementService.freshKeyAndCert(identity, false) - Cash.generateSpend(services, this, Amount(1000, GBP), changeIdentity, thirdPartyIdentity) + Cash.generateSpend(services, this, Amount(1000, GBP), identity, thirdPartyIdentity) } val moveTx = moveBuilder.toWireTransaction(services) vaultService.notify(StatesToRecord.ONLY_RELEVANT, moveTx) @@ -610,7 +610,7 @@ class NodeVaultServiceTest { // Move cash val moveTxBuilder = database.transaction { TransactionBuilder(newNotary).apply { - Cash.generateSpend(services, this, Amount(amount.quantity, GBP), anonymousIdentity, thirdPartyIdentity.party.anonymise()) + Cash.generateSpend(services, this, Amount(amount.quantity, GBP), identity, thirdPartyIdentity.party.anonymise()) } } val moveTx = moveTxBuilder.toWireTransaction(services)