mirror of
https://github.com/corda/corda.git
synced 2024-12-27 08:22:35 +00:00
Add issue and pay sampler
This commit is contained in:
parent
c1c42c98e4
commit
936d25db16
@ -1,6 +1,8 @@
|
||||
package com.r3.corda.jmeter
|
||||
|
||||
import com.r3.corda.enterprise.perftestcordapp.DOLLARS
|
||||
import com.r3.corda.enterprise.perftestcordapp.POUNDS
|
||||
import com.r3.corda.enterprise.perftestcordapp.flows.CashIssueAndPaymentFlow
|
||||
import com.r3.corda.enterprise.perftestcordapp.flows.CashIssueFlow
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.identity.Party
|
||||
@ -19,12 +21,16 @@ abstract class AbstractSampler : BaseFlowSampler() {
|
||||
val notary = Argument("notaryName", "", "<meta>", "The X500 name of the notary.")
|
||||
}
|
||||
|
||||
protected fun getIdentities(rpc: CordaRPCOps, testContext: JavaSamplerContext) {
|
||||
if (!testContext.containsParameter(notary.name)) {
|
||||
throw IllegalStateException("You must specify the '${notary.name}' property.")
|
||||
protected fun getIdentity( rpc: CordaRPCOps, testContext: JavaSamplerContext, arg: Argument):Party{
|
||||
if (!testContext.containsParameter(arg.name)) {
|
||||
throw IllegalStateException("You must specify the '${arg.name}' property.")
|
||||
}
|
||||
val notaryName = CordaX500Name.parse(testContext.getParameter(notary.name))
|
||||
notaryIdentity = rpc.wellKnownPartyFromX500Name(notaryName) ?: throw IllegalStateException("Don't know $notaryName")
|
||||
val argName = CordaX500Name.parse(testContext.getParameter(arg.name))
|
||||
return rpc.wellKnownPartyFromX500Name(argName) ?: throw IllegalStateException("Don't know $argName")
|
||||
}
|
||||
|
||||
protected fun getNotaryIdentity(rpc: CordaRPCOps, testContext: JavaSamplerContext) {
|
||||
notaryIdentity = getIdentity(rpc,testContext, notary)
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +43,7 @@ class CashIssueSampler : AbstractSampler() {
|
||||
override val additionalArgs: Set<Argument> = setOf(notary)
|
||||
|
||||
override fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
|
||||
getIdentities(rpcProxy, testContext)
|
||||
getNotaryIdentity(rpcProxy, testContext)
|
||||
}
|
||||
|
||||
override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
|
||||
@ -47,5 +53,34 @@ class CashIssueSampler : AbstractSampler() {
|
||||
val amount = 1_100_000_000_000.DOLLARS
|
||||
return FlowInvoke<CashIssueFlow>(CashIssueFlow::class.java, arrayOf(amount, OpaqueBytes.of(1), notaryIdentity))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A sampler that issues cash and pays it to a specified party, thus invoking the notary and the payee
|
||||
* via P2P
|
||||
*/
|
||||
class CashIssueAndPaySampler : AbstractSampler() {
|
||||
companion object JMeterProperties{
|
||||
val otherParty = Argument("otherPartyName", "", "<meta>", "The X500 name of the payee.")
|
||||
}
|
||||
|
||||
lateinit var counterParty: Party
|
||||
|
||||
override fun setupTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
|
||||
getNotaryIdentity(rpcProxy,testContext)
|
||||
counterParty = getIdentity(rpcProxy, testContext, otherParty)
|
||||
}
|
||||
|
||||
|
||||
override fun createFlowInvoke(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext): FlowInvoke<*> {
|
||||
val amount = 2_000_000.POUNDS
|
||||
return FlowInvoke<CashIssueAndPaymentFlow>(CashIssueAndPaymentFlow::class.java, arrayOf(amount, OpaqueBytes.of(1), notaryIdentity, counterParty))
|
||||
}
|
||||
|
||||
override fun teardownTest(rpcProxy: CordaRPCOps, testContext: JavaSamplerContext) {
|
||||
}
|
||||
|
||||
override val additionalArgs: Set<Argument>
|
||||
get() = setOf(notary, otherParty)
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user