diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/PtCurrencies.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/Currencies.kt similarity index 98% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/PtCurrencies.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/Currencies.kt index ffef67399c..29c8d1a5ed 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/PtCurrencies.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/Currencies.kt @@ -1,4 +1,4 @@ -@file:JvmName("PtCurrencies") +@file:JvmName("Currencies") package com.r3.corda.enterprise.perftestcordapp diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/PtCommercialPaper.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaper.kt similarity index 94% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/PtCommercialPaper.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaper.kt index aba7079ba6..c8ec2eb1fd 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/PtCommercialPaper.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaper.kt @@ -15,8 +15,8 @@ import net.corda.core.schemas.PersistentState import net.corda.core.schemas.QueryableState import net.corda.core.transactions.LedgerTransaction import net.corda.core.transactions.TransactionBuilder -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash -import com.r3.corda.enterprise.perftestcordapp.schemas.PtCommercialPaperSchemaV1 +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash +import com.r3.corda.enterprise.perftestcordapp.schemas.CommercialPaperSchemaV1 import com.r3.corda.enterprise.perftestcordapp.utils.sumCashBy import java.time.Instant import java.util.* @@ -43,12 +43,12 @@ import java.util.* * to do this in the Apache BVal project). */ -val CP_PROGRAM_ID = "com.r3.corda.enterprise.perftestcordapp.contracts.PtCommercialPaper" +val CP_PROGRAM_ID = "com.r3.corda.enterprise.perftestcordapp.contracts.CommercialPaper" // TODO: Generalise the notion of an owned instrument into a superclass/supercontract. Consider composition vs inheritance. -class PtCommercialPaper : Contract { +class CommercialPaper : Contract { companion object { - const val CP_PROGRAM_ID: ContractClassName = "com.r3.corda.enterprise.perftestcordapp.contracts.PtCommercialPaper" + const val CP_PROGRAM_ID: ContractClassName = "com.r3.corda.enterprise.perftestcordapp.contracts.CommercialPaper" } data class State( val issuance: PartyAndReference, @@ -69,13 +69,13 @@ class PtCommercialPaper : Contract { fun withMaturityDate(newMaturityDate: Instant): State = copy(maturityDate = newMaturityDate) /** Object Relational Mapping support. */ - override fun supportedSchemas(): Iterable = listOf(PtCommercialPaperSchemaV1) + override fun supportedSchemas(): Iterable = listOf(CommercialPaperSchemaV1) /** Additional used schemas would be added here (eg. CommercialPaperV2, ...) */ /** Object Relational Mapping support. */ override fun generateMappedObject(schema: MappedSchema): PersistentState { return when (schema) { - is PtCommercialPaperSchemaV1 -> PtCommercialPaperSchemaV1.PersistentCommercialPaperState( + is CommercialPaperSchemaV1 -> CommercialPaperSchemaV1.PersistentCommercialPaperState( issuanceParty = this.issuance.party.owningKey.toBase58String(), issuanceRef = this.issuance.reference.bytes, owner = this.owner.owningKey.toBase58String(), @@ -108,7 +108,7 @@ class PtCommercialPaper : Contract { // There are two possible things that can be done with this CP. The first is trading it. The second is redeeming // it for cash on or after the maturity date. - val command = tx.commands.requireSingleCommand() + val command = tx.commands.requireSingleCommand() val timeWindow: TimeWindow? = tx.timeWindow // Suppress compiler warning as 'key' is an unused variable when destructuring 'groups'. @@ -190,7 +190,7 @@ class PtCommercialPaper : Contract { @Suspendable fun generateRedeem(tx: TransactionBuilder, paper: StateAndRef, services: ServiceHub, ourIdentity: PartyAndCertificate) { // Add the cash movement using the states in our vault. - PtCash.generateSpend(services, tx, paper.state.data.faceValue.withoutIssuer(), ourIdentity, paper.state.data.owner) + Cash.generateSpend(services, tx, paper.state.data.faceValue.withoutIssuer(), ourIdentity, paper.state.data.owner) tx.addInputState(paper) tx.addCommand(Commands.Redeem(), paper.state.data.owner.owningKey) } diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/PtCash.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/Cash.kt similarity index 94% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/PtCash.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/Cash.kt index 715c454958..a17ce3884a 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/PtCash.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/Cash.kt @@ -19,7 +19,7 @@ import net.corda.core.transactions.LedgerTransaction import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.toBase58String -import com.r3.corda.enterprise.perftestcordapp.schemas.PtCashSchemaV1 +import com.r3.corda.enterprise.perftestcordapp.schemas.CashSchemaV1 import com.r3.corda.enterprise.perftestcordapp.utils.sumCash import com.r3.corda.enterprise.perftestcordapp.utils.sumCashOrNull import com.r3.corda.enterprise.perftestcordapp.utils.sumCashOrZero @@ -40,20 +40,20 @@ import java.util.concurrent.atomic.AtomicReference * Custom implementations must implement this interface and declare their implementation in * META-INF/services/net.corda.contracts.asset.CashSelection */ -interface PtCashSelection { +interface CashSelection { companion object { - val instance = AtomicReference() + val instance = AtomicReference() - fun getInstance(metadata: () -> java.sql.DatabaseMetaData): PtCashSelection { + fun getInstance(metadata: () -> java.sql.DatabaseMetaData): CashSelection { return instance.get() ?: { val _metadata = metadata() - val cashSelectionAlgos = ServiceLoader.load(PtCashSelection::class.java).toList() + val cashSelectionAlgos = ServiceLoader.load(CashSelection::class.java).toList() val cashSelectionAlgo = cashSelectionAlgos.firstOrNull { it.isCompatible(_metadata) } cashSelectionAlgo?.let { instance.set(cashSelectionAlgo) cashSelectionAlgo } ?: throw ClassNotFoundException("\nUnable to load compatible cash selection algorithm implementation for JDBC driver ($_metadata)." + - "\nPlease specify an implementation in META-INF/services/com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCashSelection") + "\nPlease specify an implementation in META-INF/services/com.r3.corda.enterprise.perftestcordapp.contracts.asset.CashSelection") }.invoke() } } @@ -86,7 +86,7 @@ interface PtCashSelection { onlyFromIssuerParties: Set = emptySet(), notary: Party? = null, lockId: UUID, - withIssuerRefs: Set = emptySet()): List> + withIssuerRefs: Set = emptySet()): List> } /** @@ -102,7 +102,7 @@ interface PtCashSelection { * At the same time, other contracts that just want money and don't care much who is currently holding it in their * vaults can ignore the issuer/depositRefs and just examine the amount fields. */ -class PtCash : PtOnLedgerAsset() { +class Cash : OnLedgerAsset() { override fun extractCommands(commands: Collection>): List> = commands.select() @@ -134,7 +134,7 @@ class PtCash : PtOnLedgerAsset() { /** Object Relational Mapping support. */ override fun generateMappedObject(schema: MappedSchema): PersistentState { return when (schema) { - is PtCashSchemaV1 -> PtCashSchemaV1.PersistentCashState( + is CashSchemaV1 -> CashSchemaV1.PersistentCashState( owner = this.owner, pennies = this.amount.quantity, currency = this.amount.token.product.currencyCode, @@ -147,7 +147,7 @@ class PtCash : PtOnLedgerAsset() { } /** Object Relational Mapping support. */ - override fun supportedSchemas(): Iterable = listOf(PtCashSchemaV1) + override fun supportedSchemas(): Iterable = listOf(CashSchemaV1) /** Additional used schemas would be added here (eg. CashSchemaV2, CashSchemaV3, ...) */ } // DOCEND 1 @@ -261,7 +261,7 @@ class PtCash : PtOnLedgerAsset() { } companion object { - const val PROGRAM_ID: ContractClassName = "com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash" + const val PROGRAM_ID: ContractClassName = "com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash" /** * Generate a transaction that moves an amount of currency to the given party, and sends any change back to @@ -381,27 +381,27 @@ class PtCash : PtOnLedgerAsset() { // Retrieve unspent and unlocked cash states that meet our spending criteria. val totalAmount = payments.map { it.amount }.sumOrThrow() - val cashSelection = PtCashSelection.getInstance({ services.jdbcSession().metaData }) + val cashSelection = CashSelection.getInstance({ services.jdbcSession().metaData }) val acceptableCoins = cashSelection.unconsumedCashStatesForSpending(services, totalAmount, onlyFromParties, tx.notary, tx.lockId) val revocationEnabled = false // Revocation is currently unsupported // Generate a new identity that change will be sent to for confidentiality purposes. This means that a // third party with a copy of the transaction (such as the notary) cannot identify who the change was // sent to val changeIdentity = services.keyManagementService.freshKeyAndCert(ourIdentity, revocationEnabled) - return PtOnLedgerAsset.generateSpend(tx, payments, acceptableCoins, + return OnLedgerAsset.generateSpend(tx, payments, acceptableCoins, changeIdentity.party.anonymise(), { state, quantity, owner -> deriveState(state, quantity, owner) }, - { PtCash().generateMoveCommand() }) + { Cash().generateMoveCommand() }) } } } // Small DSL extensions. -/** @suppress */ infix fun PtCash.State.`owned by`(owner: AbstractParty) = ownedBy(owner) -/** @suppress */ infix fun PtCash.State.`issued by`(party: AbstractParty) = issuedBy(party) -/** @suppress */ infix fun PtCash.State.`issued by`(deposit: PartyAndReference) = issuedBy(deposit) -/** @suppress */ infix fun PtCash.State.`with deposit`(deposit: PartyAndReference): PtCash.State = withDeposit(deposit) +/** @suppress */ infix fun Cash.State.`owned by`(owner: AbstractParty) = ownedBy(owner) +/** @suppress */ infix fun Cash.State.`issued by`(party: AbstractParty) = issuedBy(party) +/** @suppress */ infix fun Cash.State.`issued by`(deposit: PartyAndReference) = issuedBy(deposit) +/** @suppress */ infix fun Cash.State.`with deposit`(deposit: PartyAndReference): Cash.State = withDeposit(deposit) // Unit testing helpers. These could go in a separate file but it's hardly worth it for just a few functions. @@ -410,6 +410,6 @@ val DUMMY_CASH_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) } /** A dummy, randomly generated issuer party by the name of "Snake Oil Issuer" */ val DUMMY_CASH_ISSUER by lazy { Party(CordaX500Name(organisation = "Snake Oil Issuer", locality = "London", country = "GB"), DUMMY_CASH_ISSUER_KEY.public).ref(1) } /** An extension property that lets you write 100.DOLLARS.CASH */ -val Amount.CASH: PtCash.State get() = PtCash.State(Amount(quantity, Issued(DUMMY_CASH_ISSUER, token)), NULL_PARTY) +val Amount.CASH: Cash.State get() = Cash.State(Amount(quantity, Issued(DUMMY_CASH_ISSUER, token)), NULL_PARTY) /** An extension property that lets you get a cash state from an issued token, under the [NULL_PARTY] */ -val Amount>.STATE: PtCash.State get() = PtCash.State(this, NULL_PARTY) +val Amount>.STATE: Cash.State get() = Cash.State(this, NULL_PARTY) diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/PtOnLedgerAsset.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/OnLedgerAsset.kt similarity index 99% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/PtOnLedgerAsset.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/OnLedgerAsset.kt index 374ce000aa..36f92469ed 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/PtOnLedgerAsset.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/OnLedgerAsset.kt @@ -31,9 +31,9 @@ data class PartyAndAmount(val party: AbstractParty, val amount: Amount< * At the same time, other contracts that just want assets and don't care much who is currently holding it can ignore * the issuer/depositRefs and just examine the amount fields. */ -abstract class PtOnLedgerAsset> : Contract { +abstract class OnLedgerAsset> : Contract { companion object { - val log = loggerFor>() + val log = loggerFor>() /** * Generate a transaction that moves an amount of currency to the given pubkey. diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/cash/selection/PtCashSelectionH2Impl.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/cash/selection/CashSelectionH2Impl.kt similarity index 94% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/cash/selection/PtCashSelectionH2Impl.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/cash/selection/CashSelectionH2Impl.kt index 36e12f7a87..2bee35ba8a 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/cash/selection/PtCashSelectionH2Impl.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/cash/selection/CashSelectionH2Impl.kt @@ -3,8 +3,8 @@ package com.r3.corda.enterprise.perftestcordapp.contracts.asset.cash.selection import co.paralleluniverse.fibers.Suspendable import co.paralleluniverse.strands.Strand -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCashSelection +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.CashSelection import net.corda.core.contracts.Amount import net.corda.core.contracts.StateAndRef import net.corda.core.contracts.StateRef @@ -23,11 +23,11 @@ import java.util.* import java.util.concurrent.locks.ReentrantLock import kotlin.concurrent.withLock -class PtCashSelectionH2Impl : PtCashSelection { +class CashSelectionH2Impl : CashSelection { companion object { const val JDBC_DRIVER_NAME = "H2 JDBC Driver" - val log = loggerFor() + val log = loggerFor() } override fun isCompatible(metadata: DatabaseMetaData): Boolean { @@ -59,12 +59,12 @@ class PtCashSelectionH2Impl : PtCashSelection { onlyFromIssuerParties: Set, notary: Party?, lockId: UUID, - withIssuerRefs: Set): List> { + withIssuerRefs: Set): List> { val issuerKeysStr = onlyFromIssuerParties.fold("") { left, right -> left + "('${right.owningKey.toBase58String()}')," }.dropLast(1) val issuerRefsStr = withIssuerRefs.fold("") { left, right -> left + "('${right.bytes.toHexString()}')," }.dropLast(1) - val stateAndRefs = mutableListOf>() + val stateAndRefs = mutableListOf>() // We are using an H2 specific means of selecting a minimum set of rows that match a request amount of coins: // 1) There is no standard SQL mechanism of calculating a cumulative total on a field and restricting row selection on the @@ -106,7 +106,7 @@ class PtCashSelectionH2Impl : PtCashSelection { val txHash = SecureHash.parse(rs.getString(1)) val index = rs.getInt(2) val stateRef = StateRef(txHash, index) - val state = rs.getBytes(3).deserialize>(context = SerializationDefaults.STORAGE_CONTEXT) + val state = rs.getBytes(3).deserialize>(context = SerializationDefaults.STORAGE_CONTEXT) val pennies = rs.getLong(4) totalPennies = rs.getLong(5) val rowLockId = rs.getString(6) diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/AbstractPtCashFlow.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/AbstractCashFlow.kt similarity index 94% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/AbstractPtCashFlow.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/AbstractCashFlow.kt index 09c2af2dad..d1241e8ed3 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/AbstractPtCashFlow.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/AbstractCashFlow.kt @@ -16,7 +16,7 @@ import java.util.* /** * Initiates a flow that produces an Issue/Move or Exit Cash transaction. */ -abstract class AbstractPtCashFlow(override val progressTracker: ProgressTracker) : FlowLogic() { +abstract class AbstractCashFlow(override val progressTracker: ProgressTracker) : FlowLogic() { companion object { object GENERATING_ID : ProgressTracker.Step("Generating anonymous identities") object GENERATING_TX : ProgressTracker.Step("Generating transaction") diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashConfigDataFlow.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashConfigDataFlow.kt similarity index 95% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashConfigDataFlow.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashConfigDataFlow.kt index 14dc78df3c..cb4ec6d6a2 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashConfigDataFlow.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashConfigDataFlow.kt @@ -15,7 +15,7 @@ import java.util.* * Flow to obtain cash cordapp app configuration. */ @StartableByRPC -class PtCashConfigDataFlow : FlowLogic() { +class CashConfigDataFlow : FlowLogic() { companion object { private val supportedCurrencies = listOf(USD, GBP, CHF, EUR) } diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashExitFlow.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlow.kt similarity index 85% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashExitFlow.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlow.kt index a4384ceabe..53b8727a7d 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashExitFlow.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlow.kt @@ -13,8 +13,8 @@ import net.corda.core.serialization.CordaSerializable import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.ProgressTracker -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCashSelection +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.CashSelection import com.r3.corda.enterprise.perftestcordapp.issuedBy import java.util.* @@ -26,9 +26,9 @@ import java.util.* * issuer. */ @StartableByRPC -class PtCashExitFlow(private val amount: Amount, +class CashExitFlow(private val amount: Amount, private val issuerRef: OpaqueBytes, - progressTracker: ProgressTracker) : AbstractPtCashFlow(progressTracker) { + progressTracker: ProgressTracker) : AbstractCashFlow(progressTracker) { constructor(amount: Amount, issueRef: OpaqueBytes) : this(amount, issueRef, tracker()) constructor(request: ExitRequest) : this(request.amount, request.issueRef, tracker()) @@ -42,15 +42,15 @@ class PtCashExitFlow(private val amount: Amount, */ @Suspendable @Throws(PtCashException::class) - override fun call(): AbstractPtCashFlow.Result { + override fun call(): AbstractCashFlow.Result { progressTracker.currentStep = GENERATING_TX val builder = TransactionBuilder(notary = null) val issuer = ourIdentity.ref(issuerRef) - val exitStates = PtCashSelection + val exitStates = CashSelection .getInstance { serviceHub.jdbcSession().metaData } .unconsumedCashStatesForSpending(serviceHub, amount, setOf(issuer.party), builder.notary, builder.lockId, setOf(issuer.reference)) val signers = try { - PtCash().generateExit( + Cash().generateExit( builder, amount.issuedBy(issuer), exitStates) @@ -59,7 +59,7 @@ class PtCashExitFlow(private val amount: Amount, } // Work out who the owners of the burnt states were (specify page size so we don't silently drop any if > DEFAULT_PAGE_SIZE) - val inputStates = serviceHub.vaultQueryService.queryBy(VaultQueryCriteria(stateRefs = builder.inputStates()), + val inputStates = serviceHub.vaultQueryService.queryBy(VaultQueryCriteria(stateRefs = builder.inputStates()), PageSpecification(pageNumber = DEFAULT_PAGE_NUM, pageSize = builder.inputStates().size)).states // TODO: Is it safe to drop participants we don't know how to contact? Does not knowing how to contact them diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashIssueAndPaymentFlow.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentFlow.kt similarity index 88% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashIssueAndPaymentFlow.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentFlow.kt index bbcdc54e30..97708a0891 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashIssueAndPaymentFlow.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentFlow.kt @@ -21,12 +21,12 @@ import java.util.* * @param notary the notary to set on the output states. */ @StartableByRPC -class PtCashIssueAndPaymentFlow(val amount: Amount, +class CashIssueAndPaymentFlow(val amount: Amount, val issueRef: OpaqueBytes, val recipient: Party, val anonymous: Boolean, val notary: Party, - progressTracker: ProgressTracker) : AbstractPtCashFlow(progressTracker) { + progressTracker: ProgressTracker) : AbstractCashFlow(progressTracker) { constructor(amount: Amount, issueRef: OpaqueBytes, recipient: Party, @@ -36,8 +36,8 @@ class PtCashIssueAndPaymentFlow(val amount: Amount, @Suspendable override fun call(): Result { - subFlow(PtCashIssueFlow(amount, issueRef, notary)) - return subFlow(PtCashPaymentFlow(amount, recipient, anonymous)) + subFlow(CashIssueFlow(amount, issueRef, notary)) + return subFlow(CashPaymentFlow(amount, recipient, anonymous)) } @CordaSerializable diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashIssueFlow.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlow.kt similarity index 87% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashIssueFlow.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlow.kt index ae63863c69..d6f71fa1db 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashIssueFlow.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlow.kt @@ -8,7 +8,7 @@ import net.corda.core.serialization.CordaSerializable import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.ProgressTracker -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import com.r3.corda.enterprise.perftestcordapp.issuedBy import java.util.* @@ -24,21 +24,21 @@ import java.util.* * @param notary the notary to set on the output states. */ @StartableByRPC -class PtCashIssueFlow(private val amount: Amount, +class CashIssueFlow(private val amount: Amount, private val issuerBankPartyRef: OpaqueBytes, private val notary: Party, - progressTracker: ProgressTracker) : AbstractPtCashFlow(progressTracker) { + progressTracker: ProgressTracker) : AbstractCashFlow(progressTracker) { constructor(amount: Amount, issuerBankPartyRef: OpaqueBytes, notary: Party) : this(amount, issuerBankPartyRef, notary, tracker()) constructor(request: IssueRequest) : this(request.amount, request.issueRef, request.notary, tracker()) @Suspendable - override fun call(): AbstractPtCashFlow.Result { + override fun call(): AbstractCashFlow.Result { progressTracker.currentStep = GENERATING_TX val builder = TransactionBuilder(notary) val issuer = ourIdentity.ref(issuerBankPartyRef) - val signers = PtCash().generateIssue(builder, amount.issuedBy(issuer), ourIdentity, notary) + val signers = Cash().generateIssue(builder, amount.issuedBy(issuer), ourIdentity, notary) progressTracker.currentStep = SIGNING_TX val tx = serviceHub.signInitialTransaction(builder, signers) progressTracker.currentStep = FINALISING_TX diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashPaymentFlow.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlow.kt similarity index 92% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashPaymentFlow.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlow.kt index 1a29582f69..92b19ea5b5 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/PtCashPaymentFlow.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlow.kt @@ -10,7 +10,7 @@ import net.corda.core.identity.Party import net.corda.core.serialization.CordaSerializable import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import java.util.* /** @@ -23,12 +23,12 @@ import java.util.* * for testing purposes. */ @StartableByRPC -open class PtCashPaymentFlow( +open class CashPaymentFlow( val amount: Amount, val recipient: Party, val anonymous: Boolean, progressTracker: ProgressTracker, - val issuerConstraint: Set = emptySet()) : AbstractPtCashFlow(progressTracker) { + val issuerConstraint: Set = emptySet()) : AbstractCashFlow(progressTracker) { /** A straightforward constructor that constructs spends using cash states of any issuer. */ constructor(amount: Amount, recipient: Party) : this(amount, recipient, true, tracker()) /** A straightforward constructor that constructs spends using cash states of any issuer. */ @@ -36,7 +36,7 @@ open class PtCashPaymentFlow( constructor(request: PaymentRequest) : this(request.amount, request.recipient, request.anonymous, tracker(), request.issuerConstraint) @Suspendable - override fun call(): AbstractPtCashFlow.Result { + override fun call(): AbstractCashFlow.Result { progressTracker.currentStep = GENERATING_ID val txIdentities = if (anonymous) { subFlow(SwapIdentitiesFlow(recipient)) @@ -48,7 +48,7 @@ open class PtCashPaymentFlow( val builder = TransactionBuilder(notary = null) // TODO: Have some way of restricting this to states the caller controls val (spendTX, keysForSigning) = try { - PtCash.generateSpend(serviceHub, + Cash.generateSpend(serviceHub, builder, amount, ourIdentityAndCert, diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlow.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlow.kt index 54d0a0e7f4..a45ead941c 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlow.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlow.kt @@ -12,7 +12,7 @@ import net.corda.core.transactions.TransactionBuilder import net.corda.core.utilities.ProgressTracker import net.corda.core.utilities.seconds import net.corda.core.utilities.unwrap -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import com.r3.corda.enterprise.perftestcordapp.utils.sumCashBy import java.security.PublicKey import java.util.* @@ -219,7 +219,7 @@ object TwoPartyTradeFlow { val ptx = TransactionBuilder(notary) // Add input and output states for the movement of cash, by using the Cash contract to generate the states - val (tx, cashSigningPubKeys) = PtCash.generateSpend(serviceHub, ptx, tradeRequest.price, ourIdentityAndCert, tradeRequest.payToIdentity.party) + val (tx, cashSigningPubKeys) = Cash.generateSpend(serviceHub, ptx, tradeRequest.price, ourIdentityAndCert, tradeRequest.payToIdentity.party) // Add inputs/outputs/a command for the movement of the asset. tx.addInputState(assetForSale) diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/PtCashSchemaV1.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/CashSchemaV1.kt similarity index 89% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/PtCashSchemaV1.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/CashSchemaV1.kt index 8adbc28a28..21807a2873 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/PtCashSchemaV1.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/CashSchemaV1.kt @@ -13,14 +13,14 @@ import javax.persistence.Table /** * An object used to fully qualify the [CashSchema] family name (i.e. independent of version). */ -object PtCashSchema +object CashSchema /** * First version of a cash contract ORM schema that maps all fields of the [Cash] contract state as it stood * at the time of writing. */ @CordaSerializable -object PtCashSchemaV1 : MappedSchema(schemaFamily = PtCashSchema.javaClass, version = 1, mappedTypes = listOf(PersistentCashState::class.java)) { +object CashSchemaV1 : MappedSchema(schemaFamily = CashSchema.javaClass, version = 1, mappedTypes = listOf(PersistentCashState::class.java)) { @Entity @Table(name = "contract_cash_states", indexes = arrayOf(Index(name = "ccy_code_idx", columnList = "ccy_code"), diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/PtCommercialPaperSchemaV1.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/CommercialPaperSchemaV1.kt similarity index 89% rename from perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/PtCommercialPaperSchemaV1.kt rename to perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/CommercialPaperSchemaV1.kt index 9609eb0560..f263750c1d 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/PtCommercialPaperSchemaV1.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/schemas/CommercialPaperSchemaV1.kt @@ -11,14 +11,14 @@ import javax.persistence.Table /** * An object used to fully qualify the [CommercialPaperSchema] family name (i.e. independent of version). */ -object PtCommercialPaperSchema +object CommercialPaperSchema /** * First version of a commercial paper contract ORM schema that maps all fields of the [CommercialPaper] contract state * as it stood at the time of writing. */ @CordaSerializable -object PtCommercialPaperSchemaV1 : MappedSchema(schemaFamily = PtCommercialPaperSchema.javaClass, version = 1, mappedTypes = listOf(PersistentCommercialPaperState::class.java)) { +object CommercialPaperSchemaV1 : MappedSchema(schemaFamily = CommercialPaperSchema.javaClass, version = 1, mappedTypes = listOf(PersistentCommercialPaperState::class.java)) { @Entity @Table(name = "cp_states", indexes = arrayOf(Index(name = "ccy_code_index", columnList = "ccy_code"), diff --git a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/utils/StateSummingUtilities.kt b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/utils/StateSummingUtilities.kt index 2a70515997..9a6457b370 100644 --- a/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/utils/StateSummingUtilities.kt +++ b/perftestcordapp/src/main/kotlin/com/r3/corda/enterprise/perftestcordapp/utils/StateSummingUtilities.kt @@ -1,6 +1,6 @@ package com.r3.corda.enterprise.perftestcordapp.utils -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import net.corda.core.contracts.Amount import net.corda.core.contracts.Amount.Companion.sumOrNull import net.corda.core.contracts.Amount.Companion.sumOrThrow @@ -16,20 +16,20 @@ import java.util.* * if there are none, or if any of the cash states cannot be added together (i.e. are * different currencies or issuers). */ -fun Iterable.sumCashBy(owner: AbstractParty): Amount> = filterIsInstance().filter { it.owner == owner }.map { it.amount }.sumOrThrow() +fun Iterable.sumCashBy(owner: AbstractParty): Amount> = filterIsInstance().filter { it.owner == owner }.map { it.amount }.sumOrThrow() /** * Sums the cash states in the list, throwing an exception if there are none, or if any of the cash * states cannot be added together (i.e. are different currencies or issuers). */ -fun Iterable.sumCash(): Amount> = filterIsInstance().map { it.amount }.sumOrThrow() +fun Iterable.sumCash(): Amount> = filterIsInstance().map { it.amount }.sumOrThrow() /** Sums the cash states in the list, returning null if there are none. */ -fun Iterable.sumCashOrNull(): Amount>? = filterIsInstance().map { it.amount }.sumOrNull() +fun Iterable.sumCashOrNull(): Amount>? = filterIsInstance().map { it.amount }.sumOrNull() /** Sums the cash states in the list, returning zero of the given currency+issuer if there are none. */ fun Iterable.sumCashOrZero(currency: Issued): Amount> { - return filterIsInstance().map { it.amount }.sumOrZero(currency) + return filterIsInstance().map { it.amount }.sumOrZero(currency) } /** Sums the asset states in the list, returning null if there are none. */ diff --git a/perftestcordapp/src/main/resources/META-INF/services/com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCashSelection b/perftestcordapp/src/main/resources/META-INF/services/com.r3.corda.enterprise.perftestcordapp.contracts.asset.CashSelection similarity index 69% rename from perftestcordapp/src/main/resources/META-INF/services/com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCashSelection rename to perftestcordapp/src/main/resources/META-INF/services/com.r3.corda.enterprise.perftestcordapp.contracts.asset.CashSelection index 4785dc0294..c9ce8a6ee9 100644 --- a/perftestcordapp/src/main/resources/META-INF/services/com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCashSelection +++ b/perftestcordapp/src/main/resources/META-INF/services/com.r3.corda.enterprise.perftestcordapp.contracts.asset.CashSelection @@ -1,2 +1,2 @@ -com.r3.corda.enterprise.perftestcordapp.contracts.asset.cash.selection.PtCashSelectionH2Impl +com.r3.corda.enterprise.perftestcordapp.contracts.asset.cash.selection.CashSelectionH2Impl diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/PtCommercialPaperTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt similarity index 81% rename from perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/PtCommercialPaperTests.kt rename to perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt index 38c038e9ec..21577cd447 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/PtCommercialPaperTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt @@ -26,8 +26,8 @@ import kotlin.test.assertTrue // TODO: The generate functions aren't tested by these tests: add them. -interface PtCommercialPaperTestTemplate { - fun getPaper(): PtCommercialPaper.State +interface CommercialPaperTestTemplate { + fun getPaper(): CommercialPaper.State fun getIssueCommand(notary: Party): CommandData fun getRedeemCommand(notary: Party): CommandData fun getMoveCommand(): CommandData @@ -35,32 +35,32 @@ interface PtCommercialPaperTestTemplate { } -class KotlinCommercialPaperTest : PtCommercialPaperTestTemplate { - override fun getPaper(): PtCommercialPaper.State = PtCommercialPaper.State( +class KotlinCommercialPaperTest : CommercialPaperTestTemplate { + override fun getPaper(): CommercialPaper.State = CommercialPaper.State( issuance = MEGA_CORP.ref(123), owner = MEGA_CORP, faceValue = 1000.DOLLARS `issued by` MEGA_CORP.ref(123), maturityDate = TEST_TX_TIME + 7.days ) - override fun getIssueCommand(notary: Party): CommandData = PtCommercialPaper.Commands.Issue() - override fun getRedeemCommand(notary: Party): CommandData = PtCommercialPaper.Commands.Redeem() - override fun getMoveCommand(): CommandData = PtCommercialPaper.Commands.Move() - override fun getContract() = PtCommercialPaper.CP_PROGRAM_ID + override fun getIssueCommand(notary: Party): CommandData = CommercialPaper.Commands.Issue() + override fun getRedeemCommand(notary: Party): CommandData = CommercialPaper.Commands.Redeem() + override fun getMoveCommand(): CommandData = CommercialPaper.Commands.Move() + override fun getContract() = CommercialPaper.CP_PROGRAM_ID } -class KotlinCommercialPaperLegacyTest : PtCommercialPaperTestTemplate { - override fun getPaper(): PtCommercialPaper.State = PtCommercialPaper.State( +class KotlinCommercialPaperLegacyTest : CommercialPaperTestTemplate { + override fun getPaper(): CommercialPaper.State = CommercialPaper.State( issuance = MEGA_CORP.ref(123), owner = MEGA_CORP, faceValue = 1000.DOLLARS `issued by` MEGA_CORP.ref(123), maturityDate = TEST_TX_TIME + 7.days ) - override fun getIssueCommand(notary: Party): CommandData = PtCommercialPaper.Commands.Issue() - override fun getRedeemCommand(notary: Party): CommandData = PtCommercialPaper.Commands.Redeem() - override fun getMoveCommand(): CommandData = PtCommercialPaper.Commands.Move() - override fun getContract() = PtCommercialPaper.CP_PROGRAM_ID + override fun getIssueCommand(notary: Party): CommandData = CommercialPaper.Commands.Issue() + override fun getRedeemCommand(notary: Party): CommandData = CommercialPaper.Commands.Redeem() + override fun getMoveCommand(): CommandData = CommercialPaper.Commands.Move() + override fun getContract() = CommercialPaper.CP_PROGRAM_ID } @RunWith(Parameterized::class) @@ -71,7 +71,7 @@ class CommercialPaperTestsGeneric { } @Parameterized.Parameter - lateinit var thisTest: PtCommercialPaperTestTemplate + lateinit var thisTest: CommercialPaperTestTemplate val issuer = MEGA_CORP.ref(123) @@ -80,14 +80,14 @@ class CommercialPaperTestsGeneric { val someProfits = 1200.DOLLARS `issued by` issuer ledger { unverifiedTransaction { - attachment(PtCash.PROGRAM_ID) - output(PtCash.PROGRAM_ID, "alice's $900", 900.DOLLARS.CASH `issued by` issuer `owned by` ALICE) - output(PtCash.PROGRAM_ID, "some profits", someProfits.STATE `owned by` MEGA_CORP) + attachment(Cash.PROGRAM_ID) + output(Cash.PROGRAM_ID, "alice's $900", 900.DOLLARS.CASH `issued by` issuer `owned by` ALICE) + output(Cash.PROGRAM_ID, "some profits", someProfits.STATE `owned by` MEGA_CORP) } // Some CP is issued onto the ledger by MegaCorp. transaction("Issuance") { - attachments(CP_PROGRAM_ID, PtCommercialPaper.CP_PROGRAM_ID) + attachments(CP_PROGRAM_ID, CommercialPaper.CP_PROGRAM_ID) output(thisTest.getContract(), "paper") { thisTest.getPaper() } command(MEGA_CORP_PUBKEY) { thisTest.getIssueCommand(DUMMY_NOTARY) } timeWindow(TEST_TX_TIME) @@ -97,12 +97,12 @@ class CommercialPaperTestsGeneric { // The CP is sold to alice for her $900, $100 less than the face value. At 10% interest after only 7 days, // that sounds a bit too good to be true! transaction("Trade") { - attachments(PtCash.PROGRAM_ID, PtCommercialPaper.CP_PROGRAM_ID) + attachments(Cash.PROGRAM_ID, CommercialPaper.CP_PROGRAM_ID) input("paper") input("alice's $900") - output(PtCash.PROGRAM_ID, "borrowed $900") { 900.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP } - output(thisTest.getContract(), "alice's paper") { "paper".output().withOwner(ALICE) } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID, "borrowed $900") { 900.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP } + output(thisTest.getContract(), "alice's paper") { "paper".output().withOwner(ALICE) } + command(ALICE_PUBKEY) { Cash.Commands.Move() } command(MEGA_CORP_PUBKEY) { thisTest.getMoveCommand() } this.verifies() } @@ -110,16 +110,16 @@ class CommercialPaperTestsGeneric { // Time passes, and Alice redeem's her CP for $1000, netting a $100 profit. MegaCorp has received $1200 // as a single payment from somewhere and uses it to pay Alice off, keeping the remaining $200 as change. transaction("Redemption") { - attachments(CP_PROGRAM_ID, PtCommercialPaper.CP_PROGRAM_ID) + attachments(CP_PROGRAM_ID, CommercialPaper.CP_PROGRAM_ID) input("alice's paper") input("some profits") fun TransactionDSL.outputs(aliceGetsBack: Amount>) { - output(PtCash.PROGRAM_ID, "Alice's profit") { aliceGetsBack.STATE `owned by` ALICE } - output(PtCash.PROGRAM_ID, "Change") { (someProfits - aliceGetsBack).STATE `owned by` MEGA_CORP } + output(Cash.PROGRAM_ID, "Alice's profit") { aliceGetsBack.STATE `owned by` ALICE } + output(Cash.PROGRAM_ID, "Change") { (someProfits - aliceGetsBack).STATE `owned by` MEGA_CORP } } - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Move() } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Move() } command(ALICE_PUBKEY) { thisTest.getRedeemCommand(DUMMY_NOTARY) } tweak { @@ -137,7 +137,7 @@ class CommercialPaperTestsGeneric { timeWindow(TEST_TX_TIME + 8.days) tweak { - output(thisTest.getContract()) { "paper".output() } + output(thisTest.getContract()) { "paper".output() } this `fails with` "must be destroyed" } @@ -245,7 +245,7 @@ class CommercialPaperTestsGeneric { // BigCorpâ„¢ issues $10,000 of commercial paper, to mature in 30 days, owned initially by itself. val faceValue = 10000.DOLLARS `issued by` DUMMY_CASH_ISSUER val issuance = bigCorpServices.myInfo.chooseIdentity().ref(1) - val issueBuilder = PtCommercialPaper().generateIssue(issuance, faceValue, TEST_TX_TIME + 30.days, DUMMY_NOTARY) + val issueBuilder = CommercialPaper().generateIssue(issuance, faceValue, TEST_TX_TIME + 30.days, DUMMY_NOTARY) issueBuilder.setTimeWindow(TEST_TX_TIME, 30.seconds) val issuePtx = bigCorpServices.signInitialTransaction(issueBuilder) val issueTx = notaryServices.addSignature(issuePtx) @@ -254,8 +254,8 @@ class CommercialPaperTestsGeneric { // Alice pays $9000 to BigCorp to own some of their debt. moveTX = run { val builder = TransactionBuilder(DUMMY_NOTARY) - PtCash.generateSpend(aliceServices, builder, 9000.DOLLARS, AnonymousParty(bigCorpServices.key.public)) - PtCommercialPaper().generateMove(builder, issueTx.tx.outRef(0), AnonymousParty(aliceServices.key.public)) + Cash.generateSpend(aliceServices, builder, 9000.DOLLARS, AnonymousParty(bigCorpServices.key.public)) + CommercialPaper().generateMove(builder, issueTx.tx.outRef(0), AnonymousParty(aliceServices.key.public)) val ptx = aliceServices.signInitialTransaction(builder) val ptx2 = bigCorpServices.addSignature(ptx) val stx = notaryServices.addSignature(ptx2) @@ -276,7 +276,7 @@ class CommercialPaperTestsGeneric { fun makeRedeemTX(time: Instant): Pair { val builder = TransactionBuilder(DUMMY_NOTARY) builder.setTimeWindow(time, 30.seconds) - PtCommercialPaper().generateRedeem(builder, moveTX.tx.outRef(1), bigCorpServices, bigCorpServices.myInfo.chooseIdentityAndCert()) + CommercialPaper().generateRedeem(builder, moveTX.tx.outRef(1), bigCorpServices, bigCorpServices.myInfo.chooseIdentityAndCert()) val ptx = aliceServices.signInitialTransaction(builder) val ptx2 = bigCorpServices.addSignature(ptx) val stx = notaryServices.addSignature(ptx2) diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/PtCashTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt similarity index 66% rename from perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/PtCashTests.kt rename to perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt index 20aa08907b..c58ff06be3 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/PtCashTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt @@ -53,14 +53,14 @@ fun ServiceHub.fillWithSomeTestCash(howMuch: Amount, rng: Random = Random(), ref: OpaqueBytes = OpaqueBytes(ByteArray(1, { 1 })), ownedBy: AbstractParty? = null, - issuedBy: PartyAndReference = DUMMY_CASH_ISSUER): Vault { + issuedBy: PartyAndReference = DUMMY_CASH_ISSUER): Vault { val amounts = calculateRandomlySizedAmounts(howMuch, atLeastThisManyStates, atMostThisManyStates, rng) val myKey = ownedBy?.owningKey ?: myInfo.chooseIdentity().owningKey val anonParty = AnonymousParty(myKey) // We will allocate one state to one transaction, for simplicities sake. - val cash = PtCash() + val cash = Cash() val transactions: List = amounts.map { pennies -> val issuance = TransactionBuilder(null as Party?) cash.generateIssue(issuance, Amount(pennies, Issued(issuedBy.copy(reference = ref), howMuch.token)), anonParty, outputNotary) @@ -72,17 +72,17 @@ fun ServiceHub.fillWithSomeTestCash(howMuch: Amount, // Get all the StateRefs of all the generated transactions. val states = transactions.flatMap { stx -> - stx.tx.outputs.indices.map { i -> stx.tx.outRef(i) } + stx.tx.outputs.indices.map { i -> stx.tx.outRef(i) } } return Vault(states) } -class PtCashTests : TestDependencyInjectionBase() { +class CashTests : TestDependencyInjectionBase() { val defaultRef = OpaqueBytes(ByteArray(1, { 1 })) val defaultIssuer = MEGA_CORP.ref(defaultRef) - val inState = PtCash.State( + val inState = Cash.State( amount = 1000.DOLLARS `issued by` defaultIssuer, owner = AnonymousParty(ALICE_PUBKEY) ) @@ -90,7 +90,7 @@ class PtCashTests : TestDependencyInjectionBase() { val issuerInState = inState.copy(owner = defaultIssuer.party) val outState = issuerInState.copy(owner = AnonymousParty(BOB_PUBKEY)) - fun PtCash.State.editDepositRef(ref: Byte) = copy( + fun Cash.State.editDepositRef(ref: Byte) = copy( amount = Amount(amount.quantity, token = amount.token.copy(amount.token.issuer.copy(reference = OpaqueBytes.of(ref)))) ) @@ -98,7 +98,7 @@ class PtCashTests : TestDependencyInjectionBase() { lateinit var megaCorpServices: MockServices val vault: VaultService get() = miniCorpServices.vaultService lateinit var database: CordaPersistence - lateinit var vaultStatesUnconsumed: List> + lateinit var vaultStatesUnconsumed: List> @Before fun setUp() { @@ -120,7 +120,7 @@ class PtCashTests : TestDependencyInjectionBase() { ownedBy = OUR_IDENTITY_1, issuedBy = MINI_CORP.ref(1), issuerServices = miniCorpServices) } database.transaction { - vaultStatesUnconsumed = miniCorpServices.vaultQueryService.queryBy().states + vaultStatesUnconsumed = miniCorpServices.vaultQueryService.queryBy().states } resetTestSerialization() } @@ -133,35 +133,35 @@ class PtCashTests : TestDependencyInjectionBase() { @Test fun trivial() { transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } tweak { - output(PtCash.PROGRAM_ID) { outState.copy(amount = 2000.DOLLARS `issued by` defaultIssuer) } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID) { outState.copy(amount = 2000.DOLLARS `issued by` defaultIssuer) } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" } tweak { - output(PtCash.PROGRAM_ID) { outState } + output(Cash.PROGRAM_ID) { outState } command(ALICE_PUBKEY) { DummyCommandData } // Invalid command - this `fails with` "required com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash.Commands.Move command" + this `fails with` "required com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash.Commands.Move command" } tweak { - output(PtCash.PROGRAM_ID) { outState } - command(BOB_PUBKEY) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID) { outState } + command(BOB_PUBKEY) { Cash.Commands.Move() } this `fails with` "the owning keys are a subset of the signing keys" } tweak { - output(PtCash.PROGRAM_ID) { outState } - output(PtCash.PROGRAM_ID) { outState `issued by` MINI_CORP } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID) { outState } + output(Cash.PROGRAM_ID) { outState `issued by` MINI_CORP } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "at least one cash input" } // Simple reallocation works. tweak { - output(PtCash.PROGRAM_ID) { outState } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID) { outState } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this.verifies() } } @@ -171,10 +171,10 @@ class PtCashTests : TestDependencyInjectionBase() { fun `issue by move`() { // Check we can't "move" money into existence. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { DummyState() } - output(PtCash.PROGRAM_ID) { outState } - command(MINI_CORP_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { DummyState() } + output(Cash.PROGRAM_ID) { outState } + command(MINI_CORP_PUBKEY) { Cash.Commands.Move() } this `fails with` "there is at least one cash input for this group" } @@ -185,20 +185,20 @@ class PtCashTests : TestDependencyInjectionBase() { // Check we can issue money only as long as the issuer institution is a command signer, i.e. any recognised // institution is allowed to issue as much cash as they want. transaction { - attachment(PtCash.PROGRAM_ID) - output(PtCash.PROGRAM_ID) { outState } - command(ALICE_PUBKEY) { PtCash.Commands.Issue() } + attachment(Cash.PROGRAM_ID) + output(Cash.PROGRAM_ID) { outState } + command(ALICE_PUBKEY) { Cash.Commands.Issue() } this `fails with` "output states are issued by a command signer" } transaction { - attachment(PtCash.PROGRAM_ID) - output(PtCash.PROGRAM_ID) { - PtCash.State( + attachment(Cash.PROGRAM_ID) + output(Cash.PROGRAM_ID) { + Cash.State( amount = 1000.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = AnonymousParty(ALICE_PUBKEY) ) } - command(MINI_CORP_PUBKEY) { PtCash.Commands.Issue() } + command(MINI_CORP_PUBKEY) { Cash.Commands.Issue() } this.verifies() } } @@ -208,14 +208,14 @@ class PtCashTests : TestDependencyInjectionBase() { initialiseTestSerialization() // Test generation works. val tx: WireTransaction = TransactionBuilder(notary = null).apply { - PtCash().generateIssue(this, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = AnonymousParty(ALICE_PUBKEY), notary = DUMMY_NOTARY) + Cash().generateIssue(this, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = AnonymousParty(ALICE_PUBKEY), notary = DUMMY_NOTARY) }.toWireTransaction(miniCorpServices) assertTrue(tx.inputs.isEmpty()) - val s = tx.outputsOfType().single() + val s = tx.outputsOfType().single() assertEquals(100.DOLLARS `issued by` MINI_CORP.ref(12, 34), s.amount) assertEquals(MINI_CORP as AbstractParty, s.amount.token.issuer.party) assertEquals(AnonymousParty(ALICE_PUBKEY), s.owner) - assertTrue(tx.commands[0].value is PtCash.Commands.Issue) + assertTrue(tx.commands[0].value is Cash.Commands.Issue) assertEquals(MINI_CORP_PUBKEY, tx.commands[0].signers[0]) } @@ -225,7 +225,7 @@ class PtCashTests : TestDependencyInjectionBase() { // Test issuance from an issued amount val amount = 100.DOLLARS `issued by` MINI_CORP.ref(12, 34) val tx: WireTransaction = TransactionBuilder(notary = null).apply { - PtCash().generateIssue(this, amount, owner = AnonymousParty(ALICE_PUBKEY), notary = DUMMY_NOTARY) + Cash().generateIssue(this, amount, owner = AnonymousParty(ALICE_PUBKEY), notary = DUMMY_NOTARY) }.toWireTransaction(miniCorpServices) assertTrue(tx.inputs.isEmpty()) assertEquals(tx.outputs[0], tx.outputs[0]) @@ -235,49 +235,49 @@ class PtCashTests : TestDependencyInjectionBase() { fun `extended issue examples`() { // We can consume $1000 in a transaction and output $2000 as long as it's signed by an issuer. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { issuerInState } - output(PtCash.PROGRAM_ID) { inState.copy(amount = inState.amount * 2) } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { issuerInState } + output(Cash.PROGRAM_ID) { inState.copy(amount = inState.amount * 2) } // Move fails: not allowed to summon money. tweak { - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" } // Issue works. tweak { - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Issue() } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Issue() } this.verifies() } } // Can't use an issue command to lower the amount. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - output(PtCash.PROGRAM_ID) { inState.copy(amount = inState.amount.splitEvenly(2).first()) } - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Issue() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + output(Cash.PROGRAM_ID) { inState.copy(amount = inState.amount.splitEvenly(2).first()) } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Issue() } this `fails with` "output values sum to more than the inputs" } // Can't have an issue command that doesn't actually issue money. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - output(PtCash.PROGRAM_ID) { inState } - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Issue() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + output(Cash.PROGRAM_ID) { inState } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Issue() } this `fails with` "output values sum to more than the inputs" } // Can't have any other commands if we have an issue command (because the issue command overrules them) transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - output(PtCash.PROGRAM_ID) { inState.copy(amount = inState.amount * 2) } - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Issue() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + output(Cash.PROGRAM_ID) { inState.copy(amount = inState.amount * 2) } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Issue() } tweak { - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Issue() } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Issue() } this `fails with` "there is only a single issue command" } this.verifies() @@ -294,40 +294,40 @@ class PtCashTests : TestDependencyInjectionBase() { // Issue some cash var ptx = TransactionBuilder(DUMMY_NOTARY) - PtCash().generateIssue(ptx, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = MINI_CORP, notary = DUMMY_NOTARY) + Cash().generateIssue(ptx, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = MINI_CORP, notary = DUMMY_NOTARY) val tx = miniCorpServices.signInitialTransaction(ptx) // Include the previously issued cash in a new issuance command ptx = TransactionBuilder(DUMMY_NOTARY) - ptx.addInputState(tx.tx.outRef(0)) - PtCash().generateIssue(ptx, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = MINI_CORP, notary = DUMMY_NOTARY) + ptx.addInputState(tx.tx.outRef(0)) + Cash().generateIssue(ptx, 100.DOLLARS `issued by` MINI_CORP.ref(12, 34), owner = MINI_CORP, notary = DUMMY_NOTARY) } @Test fun testMergeSplit() { // Splitting value works. transaction { - attachment(PtCash.PROGRAM_ID) - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + command(ALICE_PUBKEY) { Cash.Commands.Move() } tweak { - input(PtCash.PROGRAM_ID) { inState } + input(Cash.PROGRAM_ID) { inState } val splits4 = inState.amount.splitEvenly(4) - for (i in 0..3) output(PtCash.PROGRAM_ID) { inState.copy(amount = splits4[i]) } + for (i in 0..3) output(Cash.PROGRAM_ID) { inState.copy(amount = splits4[i]) } this.verifies() } // Merging 4 inputs into 2 outputs works. tweak { val splits2 = inState.amount.splitEvenly(2) val splits4 = inState.amount.splitEvenly(4) - for (i in 0..3) input(PtCash.PROGRAM_ID) { inState.copy(amount = splits4[i]) } - for (i in 0..1) output(PtCash.PROGRAM_ID) { inState.copy(amount = splits2[i]) } + for (i in 0..3) input(Cash.PROGRAM_ID) { inState.copy(amount = splits4[i]) } + for (i in 0..1) output(Cash.PROGRAM_ID) { inState.copy(amount = splits2[i]) } this.verifies() } // Merging 2 inputs into 1 works. tweak { val splits2 = inState.amount.splitEvenly(2) - for (i in 0..1) input(PtCash.PROGRAM_ID) { inState.copy(amount = splits2[i]) } - output(PtCash.PROGRAM_ID) { inState } + for (i in 0..1) input(Cash.PROGRAM_ID) { inState.copy(amount = splits2[i]) } + output(Cash.PROGRAM_ID) { inState } this.verifies() } } @@ -336,18 +336,18 @@ class PtCashTests : TestDependencyInjectionBase() { @Test fun zeroSizedValues() { transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - input(PtCash.PROGRAM_ID) { inState.copy(amount = 0.DOLLARS `issued by` defaultIssuer) } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + input(Cash.PROGRAM_ID) { inState.copy(amount = 0.DOLLARS `issued by` defaultIssuer) } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "zero sized inputs" } transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - output(PtCash.PROGRAM_ID) { inState } - output(PtCash.PROGRAM_ID) { inState.copy(amount = 0.DOLLARS `issued by` defaultIssuer) } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + output(Cash.PROGRAM_ID) { inState } + output(Cash.PROGRAM_ID) { inState.copy(amount = 0.DOLLARS `issued by` defaultIssuer) } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "zero sized outputs" } } @@ -356,59 +356,59 @@ class PtCashTests : TestDependencyInjectionBase() { fun trivialMismatches() { // Can't change issuer. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - output(PtCash.PROGRAM_ID) { outState `issued by` MINI_CORP } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + output(Cash.PROGRAM_ID) { outState `issued by` MINI_CORP } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" } // Can't change deposit reference when splitting. transaction { - attachment(PtCash.PROGRAM_ID) + attachment(Cash.PROGRAM_ID) val splits2 = inState.amount.splitEvenly(2) - input(PtCash.PROGRAM_ID) { inState } - for (i in 0..1) output(PtCash.PROGRAM_ID) { outState.copy(amount = splits2[i]).editDepositRef(i.toByte()) } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + input(Cash.PROGRAM_ID) { inState } + for (i in 0..1) output(Cash.PROGRAM_ID) { outState.copy(amount = splits2[i]).editDepositRef(i.toByte()) } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" } // Can't mix currencies. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - output(PtCash.PROGRAM_ID) { outState.copy(amount = 800.DOLLARS `issued by` defaultIssuer) } - output(PtCash.PROGRAM_ID) { outState.copy(amount = 200.POUNDS `issued by` defaultIssuer) } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + output(Cash.PROGRAM_ID) { outState.copy(amount = 800.DOLLARS `issued by` defaultIssuer) } + output(Cash.PROGRAM_ID) { outState.copy(amount = 200.POUNDS `issued by` defaultIssuer) } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" } transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - input(PtCash.PROGRAM_ID) { + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + input(Cash.PROGRAM_ID) { inState.copy( amount = 150.POUNDS `issued by` defaultIssuer, owner = AnonymousParty(BOB_PUBKEY) ) } - output(PtCash.PROGRAM_ID) { outState.copy(amount = 1150.DOLLARS `issued by` defaultIssuer) } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID) { outState.copy(amount = 1150.DOLLARS `issued by` defaultIssuer) } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" } // Can't have superfluous input states from different issuers. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - input(PtCash.PROGRAM_ID) { inState `issued by` MINI_CORP } - output(PtCash.PROGRAM_ID) { outState } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + input(Cash.PROGRAM_ID) { inState `issued by` MINI_CORP } + output(Cash.PROGRAM_ID) { outState } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" } // Can't combine two different deposits at the same issuer. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - input(PtCash.PROGRAM_ID) { inState.editDepositRef(3) } - output(PtCash.PROGRAM_ID) { outState.copy(amount = inState.amount * 2).editDepositRef(3) } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + input(Cash.PROGRAM_ID) { inState.editDepositRef(3) } + output(Cash.PROGRAM_ID) { outState.copy(amount = inState.amount * 2).editDepositRef(3) } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "for reference [01]" } } @@ -417,22 +417,22 @@ class PtCashTests : TestDependencyInjectionBase() { fun exitLedger() { // Single input/output straightforward case. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { issuerInState } - output(PtCash.PROGRAM_ID) { issuerInState.copy(amount = issuerInState.amount - (200.DOLLARS `issued by` defaultIssuer)) } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { issuerInState } + output(Cash.PROGRAM_ID) { issuerInState.copy(amount = issuerInState.amount - (200.DOLLARS `issued by` defaultIssuer)) } tweak { - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Exit(100.DOLLARS `issued by` defaultIssuer) } - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Move() } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Exit(100.DOLLARS `issued by` defaultIssuer) } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" } tweak { - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Exit(200.DOLLARS `issued by` defaultIssuer) } - this `fails with` "required com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash.Commands.Move command" + command(MEGA_CORP_PUBKEY) { Cash.Commands.Exit(200.DOLLARS `issued by` defaultIssuer) } + this `fails with` "required com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash.Commands.Move command" tweak { - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Move() } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Move() } this.verifies() } } @@ -443,21 +443,21 @@ class PtCashTests : TestDependencyInjectionBase() { fun `exit ledger with multiple issuers`() { // Multi-issuer case. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { issuerInState } - input(PtCash.PROGRAM_ID) { issuerInState.copy(owner = MINI_CORP) `issued by` MINI_CORP } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { issuerInState } + input(Cash.PROGRAM_ID) { issuerInState.copy(owner = MINI_CORP) `issued by` MINI_CORP } - output(PtCash.PROGRAM_ID) { issuerInState.copy(amount = issuerInState.amount - (200.DOLLARS `issued by` defaultIssuer)) `issued by` MINI_CORP } - output(PtCash.PROGRAM_ID) { issuerInState.copy(owner = MINI_CORP, amount = issuerInState.amount - (200.DOLLARS `issued by` defaultIssuer)) } + output(Cash.PROGRAM_ID) { issuerInState.copy(amount = issuerInState.amount - (200.DOLLARS `issued by` defaultIssuer)) `issued by` MINI_CORP } + output(Cash.PROGRAM_ID) { issuerInState.copy(owner = MINI_CORP, amount = issuerInState.amount - (200.DOLLARS `issued by` defaultIssuer)) } - command(MEGA_CORP_PUBKEY, MINI_CORP_PUBKEY) { PtCash.Commands.Move() } + command(MEGA_CORP_PUBKEY, MINI_CORP_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Exit(200.DOLLARS `issued by` defaultIssuer) } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Exit(200.DOLLARS `issued by` defaultIssuer) } this `fails with` "the amounts balance" - command(MINI_CORP_PUBKEY) { PtCash.Commands.Exit(200.DOLLARS `issued by` MINI_CORP.ref(defaultRef)) } + command(MINI_CORP_PUBKEY) { Cash.Commands.Exit(200.DOLLARS `issued by` MINI_CORP.ref(defaultRef)) } this.verifies() } } @@ -466,11 +466,11 @@ class PtCashTests : TestDependencyInjectionBase() { fun `exit cash not held by its issuer`() { // Single input/output straightforward case. transaction { - attachment(PtCash.PROGRAM_ID) - input(PtCash.PROGRAM_ID) { inState } - output(PtCash.PROGRAM_ID) { outState.copy(amount = inState.amount - (200.DOLLARS `issued by` defaultIssuer)) } - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Exit(200.DOLLARS `issued by` defaultIssuer) } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + input(Cash.PROGRAM_ID) { inState } + output(Cash.PROGRAM_ID) { outState.copy(amount = inState.amount - (200.DOLLARS `issued by` defaultIssuer)) } + command(MEGA_CORP_PUBKEY) { Cash.Commands.Exit(200.DOLLARS `issued by` defaultIssuer) } + command(ALICE_PUBKEY) { Cash.Commands.Move() } this `fails with` "the amounts balance" } } @@ -478,27 +478,27 @@ class PtCashTests : TestDependencyInjectionBase() { @Test fun multiIssuer() { transaction { - attachment(PtCash.PROGRAM_ID) + attachment(Cash.PROGRAM_ID) // Gather 2000 dollars from two different issuers. - input(PtCash.PROGRAM_ID) { inState } - input(PtCash.PROGRAM_ID) { inState `issued by` MINI_CORP } - command(ALICE_PUBKEY) { PtCash.Commands.Move() } + input(Cash.PROGRAM_ID) { inState } + input(Cash.PROGRAM_ID) { inState `issued by` MINI_CORP } + command(ALICE_PUBKEY) { Cash.Commands.Move() } // Can't merge them together. tweak { - output(PtCash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY), amount = 2000.DOLLARS `issued by` defaultIssuer) } + output(Cash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY), amount = 2000.DOLLARS `issued by` defaultIssuer) } this `fails with` "the amounts balance" } // Missing MiniCorp deposit tweak { - output(PtCash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY)) } - output(PtCash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY)) } + output(Cash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY)) } + output(Cash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY)) } this `fails with` "the amounts balance" } // This works. - output(PtCash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY)) } - output(PtCash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY)) `issued by` MINI_CORP } + output(Cash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY)) } + output(Cash.PROGRAM_ID) { inState.copy(owner = AnonymousParty(BOB_PUBKEY)) `issued by` MINI_CORP } this.verifies() } } @@ -507,13 +507,13 @@ class PtCashTests : TestDependencyInjectionBase() { fun multiCurrency() { // Check we can do an atomic currency trade tx. transaction { - attachment(PtCash.PROGRAM_ID) - val pounds = PtCash.State(658.POUNDS `issued by` MINI_CORP.ref(3, 4, 5), AnonymousParty(BOB_PUBKEY)) - input(PtCash.PROGRAM_ID) { inState `owned by` AnonymousParty(ALICE_PUBKEY) } - input(PtCash.PROGRAM_ID) { pounds } - output(PtCash.PROGRAM_ID) { inState `owned by` AnonymousParty(BOB_PUBKEY) } - output(PtCash.PROGRAM_ID) { pounds `owned by` AnonymousParty(ALICE_PUBKEY) } - command(ALICE_PUBKEY, BOB_PUBKEY) { PtCash.Commands.Move() } + attachment(Cash.PROGRAM_ID) + val pounds = Cash.State(658.POUNDS `issued by` MINI_CORP.ref(3, 4, 5), AnonymousParty(BOB_PUBKEY)) + input(Cash.PROGRAM_ID) { inState `owned by` AnonymousParty(ALICE_PUBKEY) } + input(Cash.PROGRAM_ID) { pounds } + output(Cash.PROGRAM_ID) { inState `owned by` AnonymousParty(BOB_PUBKEY) } + output(Cash.PROGRAM_ID) { pounds `owned by` AnonymousParty(ALICE_PUBKEY) } + command(ALICE_PUBKEY, BOB_PUBKEY) { Cash.Commands.Move() } this.verifies() } @@ -531,7 +531,7 @@ class PtCashTests : TestDependencyInjectionBase() { fun makeCash(amount: Amount, corp: Party, depositRef: Byte = 1) = StateAndRef( - TransactionState(PtCash.State(amount `issued by` corp.ref(depositRef), OUR_IDENTITY_1), PtCash.PROGRAM_ID, DUMMY_NOTARY), + TransactionState(Cash.State(amount `issued by` corp.ref(depositRef), OUR_IDENTITY_1), Cash.PROGRAM_ID, DUMMY_NOTARY), StateRef(SecureHash.randomSHA256(), Random().nextInt(32)) ) @@ -547,14 +547,14 @@ class PtCashTests : TestDependencyInjectionBase() { */ private fun makeExit(amount: Amount, corp: Party, depositRef: Byte = 1): WireTransaction { val tx = TransactionBuilder(DUMMY_NOTARY) - PtCash().generateExit(tx, Amount(amount.quantity, Issued(corp.ref(depositRef), amount.token)), WALLET) + Cash().generateExit(tx, Amount(amount.quantity, Issued(corp.ref(depositRef), amount.token)), WALLET) return tx.toWireTransaction(miniCorpServices) } private fun makeSpend(amount: Amount, dest: AbstractParty): WireTransaction { val tx = TransactionBuilder(DUMMY_NOTARY) database.transaction { - PtCash.generateSpend(miniCorpServices, tx, amount, dest) + Cash.generateSpend(miniCorpServices, tx, amount, dest) } return tx.toWireTransaction(miniCorpServices) } @@ -569,8 +569,8 @@ class PtCashTests : TestDependencyInjectionBase() { assertEquals(WALLET[0].ref, wtx.inputs[0]) assertEquals(0, wtx.outputs.size) - val expectedMove = PtCash.Commands.Move() - val expectedExit = PtCash.Commands.Exit(Amount(10000, Issued(MEGA_CORP.ref(1), USD))) + val expectedMove = Cash.Commands.Move() + val expectedExit = Cash.Commands.Exit(Amount(10000, Issued(MEGA_CORP.ref(1), USD))) assertEquals(listOf(expectedMove, expectedExit), wtx.commands.map { it.value }) } @@ -631,7 +631,7 @@ class PtCashTests : TestDependencyInjectionBase() { initialiseTestSerialization() assertFailsWith { val tx = TransactionBuilder(DUMMY_NOTARY) - PtCash().generateExit(tx, Amount(100, Issued(CHARLIE.ref(1), GBP)), emptyList()) + Cash().generateExit(tx, Amount(100, Issued(CHARLIE.ref(1), GBP)), emptyList()) } } @@ -647,7 +647,7 @@ class PtCashTests : TestDependencyInjectionBase() { val vaultState = vaultStatesUnconsumed.elementAt(0) assertEquals(vaultState.ref, wtx.inputs[0]) assertEquals(vaultState.state.data.copy(owner = THEIR_IDENTITY_1), wtx.getOutput(0)) - assertEquals(OUR_IDENTITY_1.owningKey, wtx.commands.single { it.value is PtCash.Commands.Move }.signers[0]) + assertEquals(OUR_IDENTITY_1.owningKey, wtx.commands.single { it.value is Cash.Commands.Move }.signers[0]) } } @@ -657,7 +657,7 @@ class PtCashTests : TestDependencyInjectionBase() { database.transaction { val tx = TransactionBuilder(DUMMY_NOTARY) - PtCash.generateSpend(miniCorpServices, tx, 80.DOLLARS, ALICE, setOf(MINI_CORP)) + Cash.generateSpend(miniCorpServices, tx, 80.DOLLARS, ALICE, setOf(MINI_CORP)) assertEquals(vaultStatesUnconsumed.elementAt(2).ref, tx.inputStates()[0]) } @@ -675,18 +675,18 @@ class PtCashTests : TestDependencyInjectionBase() { val vaultState = vaultStatesUnconsumed.elementAt(0) val changeAmount = 90.DOLLARS `issued by` defaultIssuer val likelyChangeState = wtx.outputs.map(TransactionState<*>::data).filter { state -> - if (state is PtCash.State) { + if (state is Cash.State) { state.amount == changeAmount } else { false } }.single() - val changeOwner = (likelyChangeState as PtCash.State).owner + val changeOwner = (likelyChangeState as Cash.State).owner assertEquals(1, miniCorpServices.keyManagementService.filterMyKeys(setOf(changeOwner.owningKey)).toList().size) assertEquals(vaultState.ref, wtx.inputs[0]) assertEquals(vaultState.state.data.copy(owner = THEIR_IDENTITY_1, amount = 10.DOLLARS `issued by` defaultIssuer), wtx.outputs[0].data) assertEquals(vaultState.state.data.copy(amount = changeAmount, owner = changeOwner), wtx.outputs[1].data) - assertEquals(OUR_IDENTITY_1.owningKey, wtx.commands.single { it.value is PtCash.Commands.Move }.signers[0]) + assertEquals(OUR_IDENTITY_1.owningKey, wtx.commands.single { it.value is Cash.Commands.Move }.signers[0]) } } @@ -704,7 +704,7 @@ class PtCashTests : TestDependencyInjectionBase() { assertEquals(vaultState0.ref, wtx.inputs[0]) assertEquals(vaultState1.ref, wtx.inputs[1]) assertEquals(vaultState0.state.data.copy(owner = THEIR_IDENTITY_1, amount = 500.DOLLARS `issued by` defaultIssuer), wtx.getOutput(0)) - assertEquals(OUR_IDENTITY_1.owningKey, wtx.commands.single { it.value is PtCash.Commands.Move }.signers[0]) + assertEquals(OUR_IDENTITY_1.owningKey, wtx.commands.single { it.value is Cash.Commands.Move }.signers[0]) } } @@ -718,15 +718,15 @@ class PtCashTests : TestDependencyInjectionBase() { wtx } database.transaction { - val vaultState0: StateAndRef = vaultStatesUnconsumed.elementAt(0) - val vaultState1: StateAndRef = vaultStatesUnconsumed.elementAt(1) - val vaultState2: StateAndRef = vaultStatesUnconsumed.elementAt(2) + val vaultState0: StateAndRef = vaultStatesUnconsumed.elementAt(0) + val vaultState1: StateAndRef = vaultStatesUnconsumed.elementAt(1) + val vaultState2: StateAndRef = vaultStatesUnconsumed.elementAt(2) assertEquals(vaultState0.ref, wtx.inputs[0]) assertEquals(vaultState1.ref, wtx.inputs[1]) assertEquals(vaultState2.ref, wtx.inputs[2]) assertEquals(vaultState0.state.data.copy(owner = THEIR_IDENTITY_1, amount = 500.DOLLARS `issued by` defaultIssuer), wtx.outputs[1].data) assertEquals(vaultState2.state.data.copy(owner = THEIR_IDENTITY_1), wtx.outputs[0].data) - assertEquals(OUR_IDENTITY_1.owningKey, wtx.commands.single { it.value is PtCash.Commands.Move }.signers[0]) + assertEquals(OUR_IDENTITY_1.owningKey, wtx.commands.single { it.value is Cash.Commands.Move }.signers[0]) } } @@ -751,9 +751,9 @@ class PtCashTests : TestDependencyInjectionBase() { */ @Test fun aggregation() { - val fiveThousandDollarsFromMega = PtCash.State(5000.DOLLARS `issued by` MEGA_CORP.ref(2), MEGA_CORP) - val twoThousandDollarsFromMega = PtCash.State(2000.DOLLARS `issued by` MEGA_CORP.ref(2), MINI_CORP) - val oneThousandDollarsFromMini = PtCash.State(1000.DOLLARS `issued by` MINI_CORP.ref(3), MEGA_CORP) + val fiveThousandDollarsFromMega = Cash.State(5000.DOLLARS `issued by` MEGA_CORP.ref(2), MEGA_CORP) + val twoThousandDollarsFromMega = Cash.State(2000.DOLLARS `issued by` MEGA_CORP.ref(2), MINI_CORP) + val oneThousandDollarsFromMini = Cash.State(1000.DOLLARS `issued by` MINI_CORP.ref(3), MEGA_CORP) // Obviously it must be possible to aggregate states with themselves assertEquals(fiveThousandDollarsFromMega.amount.token, fiveThousandDollarsFromMega.amount.token) @@ -767,7 +767,7 @@ class PtCashTests : TestDependencyInjectionBase() { // States cannot be aggregated if the currency differs assertNotEquals(oneThousandDollarsFromMini.amount.token, - PtCash.State(1000.POUNDS `issued by` MINI_CORP.ref(3), MEGA_CORP).amount.token) + Cash.State(1000.POUNDS `issued by` MINI_CORP.ref(3), MEGA_CORP).amount.token) // States cannot be aggregated if the reference differs assertNotEquals(fiveThousandDollarsFromMega.amount.token, (fiveThousandDollarsFromMega `with deposit` defaultIssuer).amount.token) @@ -777,9 +777,9 @@ class PtCashTests : TestDependencyInjectionBase() { @Test fun `summing by owner`() { val states = listOf( - PtCash.State(1000.DOLLARS `issued by` defaultIssuer, MINI_CORP), - PtCash.State(2000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), - PtCash.State(4000.DOLLARS `issued by` defaultIssuer, MEGA_CORP) + Cash.State(1000.DOLLARS `issued by` defaultIssuer, MINI_CORP), + Cash.State(2000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), + Cash.State(4000.DOLLARS `issued by` defaultIssuer, MEGA_CORP) ) assertEquals(6000.DOLLARS `issued by` defaultIssuer, states.sumCashBy(MEGA_CORP)) } @@ -787,31 +787,31 @@ class PtCashTests : TestDependencyInjectionBase() { @Test(expected = UnsupportedOperationException::class) fun `summing by owner throws`() { val states = listOf( - PtCash.State(2000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), - PtCash.State(4000.DOLLARS `issued by` defaultIssuer, MEGA_CORP) + Cash.State(2000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), + Cash.State(4000.DOLLARS `issued by` defaultIssuer, MEGA_CORP) ) states.sumCashBy(MINI_CORP) } @Test fun `summing no currencies`() { - val states = emptyList() + val states = emptyList() assertEquals(0.POUNDS `issued by` defaultIssuer, states.sumCashOrZero(GBP `issued by` defaultIssuer)) assertNull(states.sumCashOrNull()) } @Test(expected = UnsupportedOperationException::class) fun `summing no currencies throws`() { - val states = emptyList() + val states = emptyList() states.sumCash() } @Test fun `summing a single currency`() { val states = listOf( - PtCash.State(1000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), - PtCash.State(2000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), - PtCash.State(4000.DOLLARS `issued by` defaultIssuer, MEGA_CORP) + Cash.State(1000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), + Cash.State(2000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), + Cash.State(4000.DOLLARS `issued by` defaultIssuer, MEGA_CORP) ) // Test that summing everything produces the total number of dollars val expected = 7000.DOLLARS `issued by` defaultIssuer @@ -822,8 +822,8 @@ class PtCashTests : TestDependencyInjectionBase() { @Test(expected = IllegalArgumentException::class) fun `summing multiple currencies`() { val states = listOf( - PtCash.State(1000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), - PtCash.State(4000.POUNDS `issued by` defaultIssuer, MEGA_CORP) + Cash.State(1000.DOLLARS `issued by` defaultIssuer, MEGA_CORP), + Cash.State(4000.POUNDS `issued by` defaultIssuer, MEGA_CORP) ) // Test that summing everything fails because we're mixing units states.sumCash() @@ -836,9 +836,9 @@ class PtCashTests : TestDependencyInjectionBase() { ledger(mockService) { unverifiedTransaction { - attachment(PtCash.PROGRAM_ID) - output(PtCash.PROGRAM_ID, "MEGA_CORP cash") { - PtCash.State( + attachment(Cash.PROGRAM_ID) + output(Cash.PROGRAM_ID, "MEGA_CORP cash") { + Cash.State( amount = 1000.DOLLARS `issued by` MEGA_CORP.ref(1, 1), owner = MEGA_CORP ) @@ -846,20 +846,20 @@ class PtCashTests : TestDependencyInjectionBase() { } transaction { - attachment(PtCash.PROGRAM_ID) + attachment(Cash.PROGRAM_ID) input("MEGA_CORP cash") - output(PtCash.PROGRAM_ID, "MEGA_CORP cash 2", "MEGA_CORP cash".output().copy(owner = AnonymousParty(ALICE_PUBKEY)) ) - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID, "MEGA_CORP cash 2", "MEGA_CORP cash".output().copy(owner = AnonymousParty(ALICE_PUBKEY)) ) + command(MEGA_CORP_PUBKEY) { Cash.Commands.Move() } this.verifies() } tweak { transaction { - attachment(PtCash.PROGRAM_ID) + attachment(Cash.PROGRAM_ID) input("MEGA_CORP cash") // We send it to another pubkey so that the transaction is not identical to the previous one - output(PtCash.PROGRAM_ID, "MEGA_CORP cash 3", "MEGA_CORP cash".output().copy(owner = ALICE)) - command(MEGA_CORP_PUBKEY) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID, "MEGA_CORP cash 3", "MEGA_CORP cash".output().copy(owner = ALICE)) + command(MEGA_CORP_PUBKEY) { Cash.Commands.Move() } this.verifies() } this.fails() @@ -878,10 +878,10 @@ class PtCashTests : TestDependencyInjectionBase() { PartyAndAmount(THEIR_IDENTITY_1, 400.DOLLARS), PartyAndAmount(THEIR_IDENTITY_2, 150.DOLLARS) ) - PtCash.generateSpend(miniCorpServices, tx, payments) + Cash.generateSpend(miniCorpServices, tx, payments) } val wtx = tx.toWireTransaction(miniCorpServices) - fun out(i: Int) = wtx.getOutput(i) as PtCash.State + fun out(i: Int) = wtx.getOutput(i) as Cash.State assertEquals(4, wtx.outputs.size) assertEquals(80.DOLLARS, out(0).amount.withoutIssuer()) assertEquals(320.DOLLARS, out(1).amount.withoutIssuer()) diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashExitFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashExitFlowTests.kt index e65c743615..20e2b737cc 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashExitFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashExitFlowTests.kt @@ -4,11 +4,11 @@ import net.corda.core.identity.Party import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.getOrThrow import com.r3.corda.enterprise.perftestcordapp.flows.PtCashException -import com.r3.corda.enterprise.perftestcordapp.flows.PtCashExitFlow -import com.r3.corda.enterprise.perftestcordapp.flows.PtCashIssueFlow +import com.r3.corda.enterprise.perftestcordapp.flows.CashExitFlow +import com.r3.corda.enterprise.perftestcordapp.flows.CashIssueFlow import com.r3.corda.enterprise.perftestcordapp.DOLLARS import com.r3.corda.enterprise.perftestcordapp.`issued by` -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import net.corda.node.internal.StartedNode import net.corda.testing.chooseIdentity import net.corda.testing.getDefaultNotary @@ -43,7 +43,7 @@ class CashExitFlowTests { mockNet.runNetwork() notary = bankOfCordaNode.services.getDefaultNotary() - val future = bankOfCordaNode.services.startFlow(PtCashIssueFlow(initialBalance, ref, notary)).resultFuture + val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture mockNet.runNetwork() future.getOrThrow() } @@ -57,20 +57,20 @@ class CashExitFlowTests { @Test fun `exit some cash`() { val exitAmount = 500.DOLLARS - val future = bankOfCordaNode.services.startFlow(PtCashExitFlow(exitAmount, ref)).resultFuture + val future = bankOfCordaNode.services.startFlow(CashExitFlow(exitAmount, ref)).resultFuture mockNet.runNetwork() val exitTx = future.getOrThrow().stx.tx val expected = (initialBalance - exitAmount).`issued by`(bankOfCorda.ref(ref)) assertEquals(1, exitTx.inputs.size) assertEquals(1, exitTx.outputs.size) - val output = exitTx.outputsOfType().single() + val output = exitTx.outputsOfType().single() assertEquals(expected, output.amount) } @Test fun `exit zero cash`() { val expected = 0.DOLLARS - val future = bankOfCordaNode.services.startFlow(PtCashExitFlow(expected, ref)).resultFuture + val future = bankOfCordaNode.services.startFlow(CashExitFlow(expected, ref)).resultFuture mockNet.runNetwork() assertFailsWith { future.getOrThrow() diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashIssueFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashIssueFlowTests.kt index d355d264ff..3538535ba5 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashIssueFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashIssueFlowTests.kt @@ -5,9 +5,9 @@ import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.getOrThrow import com.r3.corda.enterprise.perftestcordapp.DOLLARS import com.r3.corda.enterprise.perftestcordapp.`issued by` -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import net.corda.node.internal.StartedNode -import com.r3.corda.enterprise.perftestcordapp.flows.PtCashIssueFlow +import com.r3.corda.enterprise.perftestcordapp.flows.CashIssueFlow import net.corda.testing.chooseIdentity import net.corda.testing.getDefaultNotary import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin @@ -49,10 +49,10 @@ class CashIssueFlowTests { fun `issue some cash`() { val expected = 500.DOLLARS val ref = OpaqueBytes.of(0x01) - val future = bankOfCordaNode.services.startFlow(PtCashIssueFlow(expected, ref, notary)).resultFuture + val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary)).resultFuture mockNet.runNetwork() val issueTx = future.getOrThrow().stx - val output = issueTx.tx.outputsOfType().single() + val output = issueTx.tx.outputsOfType().single() assertEquals(expected.`issued by`(bankOfCorda.ref(ref)), output.amount) } @@ -60,7 +60,7 @@ class CashIssueFlowTests { fun `issue zero cash`() { val expected = 0.DOLLARS val ref = OpaqueBytes.of(0x01) - val future = bankOfCordaNode.services.startFlow(PtCashIssueFlow(expected, ref, notary)).resultFuture + val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary)).resultFuture mockNet.runNetwork() assertFailsWith { future.getOrThrow() diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashPaymentFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashPaymentFlowTests.kt index 5c1372d02c..ba3834947c 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashPaymentFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/CashPaymentFlowTests.kt @@ -8,10 +8,10 @@ import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.getOrThrow import com.r3.corda.enterprise.perftestcordapp.DOLLARS import com.r3.corda.enterprise.perftestcordapp.`issued by` -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import com.r3.corda.enterprise.perftestcordapp.flows.PtCashException -import com.r3.corda.enterprise.perftestcordapp.flows.PtCashIssueFlow -import com.r3.corda.enterprise.perftestcordapp.flows.PtCashPaymentFlow +import com.r3.corda.enterprise.perftestcordapp.flows.CashIssueFlow +import com.r3.corda.enterprise.perftestcordapp.flows.CashPaymentFlow import net.corda.node.internal.StartedNode import net.corda.testing.chooseIdentity import net.corda.testing.expect @@ -45,7 +45,7 @@ class CashPaymentFlowTests { bankOfCordaNode = nodes.partyNodes[0] bankOfCorda = bankOfCordaNode.info.chooseIdentity() notary = notaryNode.services.getDefaultNotary() - val future = bankOfCordaNode.services.startFlow(PtCashIssueFlow(initialBalance, ref, notary)).resultFuture + val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture mockNet.runNetwork() future.getOrThrow() } @@ -64,10 +64,10 @@ class CashPaymentFlowTests { bankOfCordaNode.database.transaction { // Register for vault updates val criteria = QueryCriteria.VaultQueryCriteria(status = Vault.StateStatus.ALL) - val (_, vaultUpdatesBoc) = bankOfCordaNode.services.vaultQueryService.trackBy(criteria) - val (_, vaultUpdatesBankClient) = notaryNode.services.vaultQueryService.trackBy(criteria) + val (_, vaultUpdatesBoc) = bankOfCordaNode.services.vaultQueryService.trackBy(criteria) + val (_, vaultUpdatesBankClient) = notaryNode.services.vaultQueryService.trackBy(criteria) - val future = bankOfCordaNode.services.startFlow(PtCashPaymentFlow(expectedPayment, + val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expectedPayment, payTo)).resultFuture mockNet.runNetwork() future.getOrThrow() @@ -99,7 +99,7 @@ class CashPaymentFlowTests { fun `pay more than we have`() { val payTo = notaryNode.info.chooseIdentity() val expected = 4000.DOLLARS - val future = bankOfCordaNode.services.startFlow(PtCashPaymentFlow(expected, + val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected, payTo)).resultFuture mockNet.runNetwork() assertFailsWith { @@ -111,7 +111,7 @@ class CashPaymentFlowTests { fun `pay zero cash`() { val payTo = notaryNode.info.chooseIdentity() val expected = 0.DOLLARS - val future = bankOfCordaNode.services.startFlow(PtCashPaymentFlow(expected, + val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected, payTo)).resultFuture mockNet.runNetwork() assertFailsWith { diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/TwoPartyTradeFlowTest.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/TwoPartyTradeFlowTest.kt index c560f8d576..baf21c7eca 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/TwoPartyTradeFlowTest.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/flows/TwoPartyTradeFlowTest.kt @@ -28,9 +28,9 @@ import net.corda.core.utilities.toNonEmptySet import net.corda.core.utilities.unwrap import com.r3.corda.enterprise.perftestcordapp.DOLLARS import com.r3.corda.enterprise.perftestcordapp.`issued by` -import com.r3.corda.enterprise.perftestcordapp.contracts.PtCommercialPaper +import com.r3.corda.enterprise.perftestcordapp.contracts.CommercialPaper import com.r3.corda.enterprise.perftestcordapp.contracts.asset.CASH -import com.r3.corda.enterprise.perftestcordapp.contracts.asset.PtCash +import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash import com.r3.corda.enterprise.perftestcordapp.contracts.asset.`issued by` import com.r3.corda.enterprise.perftestcordapp.contracts.asset.`owned by` import com.r3.corda.enterprise.perftestcordapp.flows.TwoPartyTradeFlow.Buyer @@ -583,7 +583,7 @@ class TwoPartyTradeFlowTests { require(serviceHub.networkMapCache.isNotary(it.notaryIdentity)) { "${it.notaryIdentity} is not a notary" } it } - return subFlow(Buyer(sellerSession, notary, price, PtCommercialPaper.State::class.java, anonymous)) + return subFlow(Buyer(sellerSession, notary, price, CommercialPaper.State::class.java, anonymous)) } } @@ -680,13 +680,13 @@ class TwoPartyTradeFlowTests { // wants to sell to Bob. val eb1 = transaction(transactionBuilder = TransactionBuilder(notary = notary)) { // Issued money to itself. - output(PtCash.PROGRAM_ID, "elbonian money 1", notary = notary) { 800.DOLLARS.CASH `issued by` issuer `owned by` interimOwner } - output(PtCash.PROGRAM_ID, "elbonian money 2", notary = notary) { 1000.DOLLARS.CASH `issued by` issuer `owned by` interimOwner } + output(Cash.PROGRAM_ID, "elbonian money 1", notary = notary) { 800.DOLLARS.CASH `issued by` issuer `owned by` interimOwner } + output(Cash.PROGRAM_ID, "elbonian money 2", notary = notary) { 1000.DOLLARS.CASH `issued by` issuer `owned by` interimOwner } if (!withError) { - command(issuer.party.owningKey) { PtCash.Commands.Issue() } + command(issuer.party.owningKey) { Cash.Commands.Issue() } } else { // Put a broken command on so at least a signature is created - command(issuer.party.owningKey) { PtCash.Commands.Move() } + command(issuer.party.owningKey) { Cash.Commands.Move() } } timeWindow(TEST_TX_TIME) if (withError) { @@ -699,16 +699,16 @@ class TwoPartyTradeFlowTests { // Bob gets some cash onto the ledger from BoE val bc1 = transaction(transactionBuilder = TransactionBuilder(notary = notary)) { input("elbonian money 1") - output(PtCash.PROGRAM_ID, "bob cash 1", notary = notary) { 800.DOLLARS.CASH `issued by` issuer `owned by` owner } - command(interimOwner.owningKey) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID, "bob cash 1", notary = notary) { 800.DOLLARS.CASH `issued by` issuer `owned by` owner } + command(interimOwner.owningKey) { Cash.Commands.Move() } this.verifies() } val bc2 = transaction(transactionBuilder = TransactionBuilder(notary = notary)) { input("elbonian money 2") - output(PtCash.PROGRAM_ID, "bob cash 2", notary = notary) { 300.DOLLARS.CASH `issued by` issuer `owned by` owner } - output(PtCash.PROGRAM_ID, notary = notary) { 700.DOLLARS.CASH `issued by` issuer `owned by` interimOwner } // Change output. - command(interimOwner.owningKey) { PtCash.Commands.Move() } + output(Cash.PROGRAM_ID, "bob cash 2", notary = notary) { 300.DOLLARS.CASH `issued by` issuer `owned by` owner } + output(Cash.PROGRAM_ID, notary = notary) { 700.DOLLARS.CASH `issued by` issuer `owned by` interimOwner } // Change output. + command(interimOwner.owningKey) { Cash.Commands.Move() } this.verifies() } @@ -724,10 +724,10 @@ class TwoPartyTradeFlowTests { attachmentID: SecureHash?, notary: Party): Pair, List> { val ap = transaction(transactionBuilder = TransactionBuilder(notary = notary)) { - output(PtCommercialPaper.CP_PROGRAM_ID, "alice's paper", notary = notary) { - PtCommercialPaper.State(issuer, owner, amount, TEST_TX_TIME + 7.days) + output(CommercialPaper.CP_PROGRAM_ID, "alice's paper", notary = notary) { + CommercialPaper.State(issuer, owner, amount, TEST_TX_TIME + 7.days) } - command(issuer.party.owningKey) { PtCommercialPaper.Commands.Issue() } + command(issuer.party.owningKey) { CommercialPaper.Commands.Issue() } if (!withError) timeWindow(time = TEST_TX_TIME) if (attachmentID != null)