Correct identities passed to generateSpend (#2199)

Pass well known identities instead of confidential into `generateSpend()`
This commit is contained in:
Ross Nicoll 2017-12-07 18:12:25 +00:00 committed by GitHub
parent 1375084936
commit ce859178eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -506,10 +506,9 @@ class CashTests {
private fun makeSpend(services: ServiceHub, amount: Amount<Currency>, dest: AbstractParty): WireTransaction { private fun makeSpend(services: ServiceHub, amount: Amount<Currency>, dest: AbstractParty): WireTransaction {
val ourIdentity = services.myInfo.singleIdentityAndCert() val ourIdentity = services.myInfo.singleIdentityAndCert()
val changeIdentity = services.keyManagementService.freshKeyAndCert(ourIdentity, false)
val tx = TransactionBuilder(DUMMY_NOTARY) val tx = TransactionBuilder(DUMMY_NOTARY)
database.transaction { database.transaction {
Cash.generateSpend(services, tx, amount, changeIdentity, dest) Cash.generateSpend(services, tx, amount, ourIdentity, dest)
} }
return tx.toWireTransaction(services) return tx.toWireTransaction(services)
} }
@ -605,11 +604,10 @@ class CashTests {
@Test @Test
fun generateSimpleSpendWithParties() { fun generateSimpleSpendWithParties() {
val changeIdentity = ourServices.keyManagementService.freshKeyAndCert(ourServices.myInfo.singleIdentityAndCert(), false)
database.transaction { database.transaction {
val tx = TransactionBuilder(DUMMY_NOTARY) 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]) assertEquals(vaultStatesUnconsumed.elementAt(2).ref, tx.inputStates()[0])
} }
@ -818,12 +816,11 @@ class CashTests {
fun multiSpend() { fun multiSpend() {
val tx = TransactionBuilder(DUMMY_NOTARY) val tx = TransactionBuilder(DUMMY_NOTARY)
database.transaction { database.transaction {
val changeIdentity = ourServices.keyManagementService.freshKeyAndCert(ourServices.myInfo.singleIdentityAndCert(), false)
val payments = listOf( val payments = listOf(
PartyAndAmount(miniCorpAnonymised, 400.DOLLARS), PartyAndAmount(miniCorpAnonymised, 400.DOLLARS),
PartyAndAmount(CHARLIE_ANONYMISED, 150.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) val wtx = tx.toWireTransaction(ourServices)
fun out(i: Int) = wtx.getOutput(i) as Cash.State fun out(i: Int) = wtx.getOutput(i) as Cash.State

View File

@ -531,6 +531,7 @@ class NodeVaultServiceTest {
val identity = services.myInfo.singleIdentityAndCert() val identity = services.myInfo.singleIdentityAndCert()
val anonymousIdentity = services.keyManagementService.freshKeyAndCert(identity, false) 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 thirdPartyIdentity = AnonymousParty(generateKeyPair().public)
val amount = Amount(1000, Issued(BOC.ref(1), GBP)) val amount = Amount(1000, Issued(BOC.ref(1), GBP))
@ -550,8 +551,7 @@ class NodeVaultServiceTest {
database.transaction { database.transaction {
val moveBuilder = TransactionBuilder(notary).apply { val moveBuilder = TransactionBuilder(notary).apply {
val changeIdentity = services.keyManagementService.freshKeyAndCert(identity, false) Cash.generateSpend(services, this, Amount(1000, GBP), identity, thirdPartyIdentity)
Cash.generateSpend(services, this, Amount(1000, GBP), changeIdentity, thirdPartyIdentity)
} }
val moveTx = moveBuilder.toWireTransaction(services) val moveTx = moveBuilder.toWireTransaction(services)
vaultService.notify(StatesToRecord.ONLY_RELEVANT, moveTx) vaultService.notify(StatesToRecord.ONLY_RELEVANT, moveTx)
@ -610,7 +610,7 @@ class NodeVaultServiceTest {
// Move cash // Move cash
val moveTxBuilder = database.transaction { val moveTxBuilder = database.transaction {
TransactionBuilder(newNotary).apply { 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) val moveTx = moveTxBuilder.toWireTransaction(services)