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 {
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

View File

@ -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)