mirror of
https://github.com/corda/corda.git
synced 2024-12-27 08:22:35 +00:00
Fix perftestcordapp unit tests (#198)
This commit is contained in:
parent
9600622db7
commit
223737ebb8
@ -1,10 +1,14 @@
|
|||||||
package com.r3.corda.enterprise.perftestcordapp.contracts
|
package com.r3.corda.enterprise.perftestcordapp.contracts
|
||||||
|
|
||||||
|
import com.nhaarman.mockito_kotlin.doReturn
|
||||||
|
import com.nhaarman.mockito_kotlin.whenever
|
||||||
import com.r3.corda.enterprise.perftestcordapp.DOLLARS
|
import com.r3.corda.enterprise.perftestcordapp.DOLLARS
|
||||||
import com.r3.corda.enterprise.perftestcordapp.`issued by`
|
import com.r3.corda.enterprise.perftestcordapp.`issued by`
|
||||||
import com.r3.corda.enterprise.perftestcordapp.contracts.asset.*
|
import com.r3.corda.enterprise.perftestcordapp.contracts.asset.*
|
||||||
import net.corda.core.contracts.*
|
import net.corda.core.contracts.*
|
||||||
|
import net.corda.core.crypto.generateKeyPair
|
||||||
import net.corda.core.identity.AnonymousParty
|
import net.corda.core.identity.AnonymousParty
|
||||||
|
import net.corda.core.identity.CordaX500Name
|
||||||
import net.corda.core.identity.Party
|
import net.corda.core.identity.Party
|
||||||
import net.corda.core.node.services.Vault
|
import net.corda.core.node.services.Vault
|
||||||
import net.corda.core.node.services.VaultService
|
import net.corda.core.node.services.VaultService
|
||||||
@ -12,9 +16,12 @@ import net.corda.core.transactions.SignedTransaction
|
|||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
import net.corda.core.utilities.days
|
import net.corda.core.utilities.days
|
||||||
import net.corda.core.utilities.seconds
|
import net.corda.core.utilities.seconds
|
||||||
|
import net.corda.node.services.api.IdentityServiceInternal
|
||||||
import net.corda.testing.*
|
import net.corda.testing.*
|
||||||
import net.corda.testing.node.MockServices
|
import net.corda.testing.node.MockServices
|
||||||
|
import net.corda.testing.node.ledger
|
||||||
import net.corda.testing.node.makeTestIdentityService
|
import net.corda.testing.node.makeTestIdentityService
|
||||||
|
import net.corda.testing.node.transaction
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@ -34,6 +41,11 @@ interface CommercialPaperTestTemplate {
|
|||||||
fun getContract(): ContractClassName
|
fun getContract(): ContractClassName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val megaCorp = TestIdentity(CordaX500Name("MegaCorp", "London", "GB"))
|
||||||
|
private val MEGA_CORP get() = megaCorp.party
|
||||||
|
private val MEGA_CORP_IDENTITY get() = megaCorp.identity
|
||||||
|
private val MEGA_CORP_PUBKEY get() = megaCorp.pubkey
|
||||||
|
|
||||||
|
|
||||||
class KotlinCommercialPaperTest : CommercialPaperTestTemplate {
|
class KotlinCommercialPaperTest : CommercialPaperTestTemplate {
|
||||||
override fun getPaper(): CommercialPaper.State = CommercialPaper.State(
|
override fun getPaper(): CommercialPaper.State = CommercialPaper.State(
|
||||||
@ -68,6 +80,23 @@ class CommercialPaperTestsGeneric {
|
|||||||
companion object {
|
companion object {
|
||||||
@Parameterized.Parameters @JvmStatic
|
@Parameterized.Parameters @JvmStatic
|
||||||
fun data() = listOf(KotlinCommercialPaperTest(), KotlinCommercialPaperLegacyTest())
|
fun data() = listOf(KotlinCommercialPaperTest(), KotlinCommercialPaperLegacyTest())
|
||||||
|
|
||||||
|
private val dummyCashIssuer = TestIdentity(CordaX500Name("Snake Oil Issuer", "London", "GB"), 10)
|
||||||
|
private val DUMMY_CASH_ISSUER_IDENTITY get() = dummyCashIssuer.identity
|
||||||
|
private val DUMMY_CASH_ISSUER = dummyCashIssuer.ref(1)
|
||||||
|
private val alice = TestIdentity(ALICE_NAME, 70)
|
||||||
|
private val BIG_CORP_KEY = generateKeyPair()
|
||||||
|
private val dummyNotary = TestIdentity(DUMMY_NOTARY_NAME, 20)
|
||||||
|
private val miniCorp = TestIdentity(CordaX500Name("MiniCorp", "London", "GB"))
|
||||||
|
private val ALICE get() = alice.party
|
||||||
|
private val ALICE_KEY get() = alice.key
|
||||||
|
private val ALICE_PUBKEY get() = alice.pubkey
|
||||||
|
private val DUMMY_NOTARY get() = dummyNotary.party
|
||||||
|
private val DUMMY_NOTARY_IDENTITY get() = dummyNotary.identity
|
||||||
|
private val MINI_CORP get() = miniCorp.party
|
||||||
|
private val MINI_CORP_IDENTITY get() = miniCorp.identity
|
||||||
|
private val MINI_CORP_PUBKEY get() = miniCorp.pubkey
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter
|
@Parameterized.Parameter
|
||||||
@ -76,11 +105,17 @@ class CommercialPaperTestsGeneric {
|
|||||||
@JvmField
|
@JvmField
|
||||||
val testSerialization = SerializationEnvironmentRule()
|
val testSerialization = SerializationEnvironmentRule()
|
||||||
val issuer = MEGA_CORP.ref(123)
|
val issuer = MEGA_CORP.ref(123)
|
||||||
|
private val ledgerServices = MockServices(rigorousMock<IdentityServiceInternal>().also {
|
||||||
|
doReturn(MEGA_CORP).whenever(it).partyFromKey(MEGA_CORP_PUBKEY)
|
||||||
|
doReturn(MINI_CORP).whenever(it).partyFromKey(MINI_CORP_PUBKEY)
|
||||||
|
doReturn(null).whenever(it).partyFromKey(ALICE_PUBKEY)
|
||||||
|
}, MEGA_CORP.name)
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `trade lifecycle test`() {
|
fun `trade lifecycle test`() {
|
||||||
val someProfits = 1200.DOLLARS `issued by` issuer
|
val someProfits = 1200.DOLLARS `issued by` issuer
|
||||||
ledger {
|
ledgerServices.ledger(DUMMY_NOTARY) {
|
||||||
unverifiedTransaction {
|
unverifiedTransaction {
|
||||||
attachment(Cash.PROGRAM_ID)
|
attachment(Cash.PROGRAM_ID)
|
||||||
output(Cash.PROGRAM_ID, "alice's $900", 900.DOLLARS.CASH issuedBy issuer ownedBy ALICE)
|
output(Cash.PROGRAM_ID, "alice's $900", 900.DOLLARS.CASH issuedBy issuer ownedBy ALICE)
|
||||||
@ -148,6 +183,10 @@ class CommercialPaperTestsGeneric {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun transaction(script: TransactionDSL<TransactionDSLInterpreter>.() -> EnforceVerifyOrFail) = run {
|
||||||
|
ledgerServices.transaction(DUMMY_NOTARY, script)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `key mismatch at issue`() {
|
fun `key mismatch at issue`() {
|
||||||
transaction {
|
transaction {
|
||||||
@ -210,7 +249,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
private lateinit var aliceVaultService: VaultService
|
private lateinit var aliceVaultService: VaultService
|
||||||
private lateinit var alicesVault: Vault<ContractState>
|
private lateinit var alicesVault: Vault<ContractState>
|
||||||
|
|
||||||
private val notaryServices = MockServices(rigorousMock(), MEGA_CORP.name, DUMMY_NOTARY_KEY)
|
private val notaryServices = MockServices(rigorousMock(), MEGA_CORP.name, dummyNotary.key)
|
||||||
private val issuerServices = MockServices(rigorousMock(), MEGA_CORP.name, DUMMY_CASH_ISSUER_KEY)
|
private val issuerServices = MockServices(rigorousMock(), MEGA_CORP.name, DUMMY_CASH_ISSUER_KEY)
|
||||||
|
|
||||||
private lateinit var moveTX: SignedTransaction
|
private lateinit var moveTX: SignedTransaction
|
||||||
@ -226,7 +265,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
aliceVaultService = aliceServices.vaultService
|
aliceVaultService = aliceServices.vaultService
|
||||||
|
|
||||||
databaseAlice.transaction {
|
databaseAlice.transaction {
|
||||||
alicesVault = aliceServices.fillWithSomeTestCash(9000.DOLLARS, issuerServices, issuedBy = DUMMY_CASH_ISSUER)
|
alicesVault = aliceServices.fillWithSomeTestCash(9000.DOLLARS, issuerServices, issuedBy = DUMMY_CASH_ISSUER, outputNotary = DUMMY_NOTARY)
|
||||||
aliceVaultService = aliceServices.vaultService
|
aliceVaultService = aliceServices.vaultService
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +278,7 @@ class CommercialPaperTestsGeneric {
|
|||||||
bigCorpVaultService = bigCorpServices.vaultService
|
bigCorpVaultService = bigCorpServices.vaultService
|
||||||
|
|
||||||
databaseBigCorp.transaction {
|
databaseBigCorp.transaction {
|
||||||
bigCorpVault = bigCorpServices.fillWithSomeTestCash(13000.DOLLARS, issuerServices, issuedBy = DUMMY_CASH_ISSUER)
|
bigCorpVault = bigCorpServices.fillWithSomeTestCash(13000.DOLLARS, issuerServices, issuedBy = DUMMY_CASH_ISSUER, outputNotary = DUMMY_NOTARY)
|
||||||
bigCorpVaultService = bigCorpServices.vaultService
|
bigCorpVaultService = bigCorpServices.vaultService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,42 @@
|
|||||||
package com.r3.corda.enterprise.perftestcordapp.contracts.asset
|
package com.r3.corda.enterprise.perftestcordapp.contracts.asset
|
||||||
|
|
||||||
import com.r3.corda.enterprise.perftestcordapp.DOLLARS
|
import com.r3.corda.enterprise.perftestcordapp.DOLLARS
|
||||||
|
import com.r3.corda.enterprise.perftestcordapp.POUNDS
|
||||||
import com.r3.corda.enterprise.perftestcordapp.flows.CashException
|
import com.r3.corda.enterprise.perftestcordapp.flows.CashException
|
||||||
|
import com.r3.corda.enterprise.perftestcordapp.flows.CashIssueFlow
|
||||||
import com.r3.corda.enterprise.perftestcordapp.flows.CashPaymentFlow
|
import com.r3.corda.enterprise.perftestcordapp.flows.CashPaymentFlow
|
||||||
|
import net.corda.core.internal.concurrent.transpose
|
||||||
|
import net.corda.core.utilities.OpaqueBytes
|
||||||
import net.corda.core.utilities.getOrThrow
|
import net.corda.core.utilities.getOrThrow
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNodeParameters
|
import net.corda.testing.node.MockNodeParameters
|
||||||
import net.corda.testing.startFlow
|
import net.corda.testing.node.startFlow
|
||||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import java.util.Collections.nCopies
|
||||||
|
|
||||||
class CashSelectionH2Test {
|
class CashSelectionH2Test {
|
||||||
private val mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("net.corda.finance"))
|
private val mockNet = MockNetwork(threadPerNode = true, cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
||||||
|
|
||||||
@After
|
@After
|
||||||
fun cleanUp() {
|
fun cleanUp() {
|
||||||
mockNet.stopNodes()
|
mockNet.stopNodes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `selecting pennies amount larger than max int, which is split across multiple cash states`() {
|
||||||
|
val node = mockNet.createNode()
|
||||||
|
// The amount has to split across at least two states, probably to trigger the H2 accumulator variable during the
|
||||||
|
// spend operation below.
|
||||||
|
// Issuing Integer.MAX_VALUE will not cause an exception since PersistentCashState.pennies is a long
|
||||||
|
nCopies(2, Integer.MAX_VALUE).map { issueAmount ->
|
||||||
|
node.services.startFlow(CashIssueFlow(issueAmount.POUNDS, OpaqueBytes.of(1), mockNet.defaultNotaryIdentity)).resultFuture
|
||||||
|
}.transpose().getOrThrow()
|
||||||
|
// The spend must be more than the size of a single cash state to force the accumulator onto the second state.
|
||||||
|
node.services.startFlow(CashPaymentFlow((Integer.MAX_VALUE + 1L).POUNDS, node.info.legalIdentities[0])).resultFuture.getOrThrow()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `check does not hold connection over retries`() {
|
fun `check does not hold connection over retries`() {
|
||||||
val bankA = mockNet.createNode(MockNodeParameters(configOverrides = {
|
val bankA = mockNet.createNode(MockNodeParameters(configOverrides = {
|
||||||
|
@ -30,7 +30,9 @@ import net.corda.testing.*
|
|||||||
import net.corda.testing.contracts.DummyState
|
import net.corda.testing.contracts.DummyState
|
||||||
import net.corda.testing.node.MockServices
|
import net.corda.testing.node.MockServices
|
||||||
import net.corda.testing.node.MockServices.Companion.makeTestDatabaseAndMockServices
|
import net.corda.testing.node.MockServices.Companion.makeTestDatabaseAndMockServices
|
||||||
|
import net.corda.testing.node.ledger
|
||||||
import net.corda.testing.node.makeTestIdentityService
|
import net.corda.testing.node.makeTestIdentityService
|
||||||
|
import net.corda.testing.node.transaction
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
@ -52,7 +54,7 @@ import kotlin.test.*
|
|||||||
*/
|
*/
|
||||||
fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>,
|
fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>,
|
||||||
issuerServices: ServiceHub = this,
|
issuerServices: ServiceHub = this,
|
||||||
outputNotary: Party = DUMMY_NOTARY,
|
outputNotary: Party,
|
||||||
ref: OpaqueBytes = OpaqueBytes(ByteArray(1, { 1 })),
|
ref: OpaqueBytes = OpaqueBytes(ByteArray(1, { 1 })),
|
||||||
ownedBy: AbstractParty? = null,
|
ownedBy: AbstractParty? = null,
|
||||||
issuedBy: PartyAndReference = DUMMY_CASH_ISSUER): Vault<Cash.State> {
|
issuedBy: PartyAndReference = DUMMY_CASH_ISSUER): Vault<Cash.State> {
|
||||||
@ -73,6 +75,31 @@ fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CashTests {
|
class CashTests {
|
||||||
|
private companion object {
|
||||||
|
val alice = TestIdentity(ALICE_NAME, 70)
|
||||||
|
val BOB_PUBKEY = TestIdentity(BOB_NAME, 80).pubkey
|
||||||
|
val charlie = TestIdentity(CHARLIE_NAME, 90)
|
||||||
|
val DUMMY_CASH_ISSUER_IDENTITY = TestIdentity(CordaX500Name("Snake Oil Issuer", "London", "GB"), 10).identity
|
||||||
|
val dummyNotary = TestIdentity(DUMMY_NOTARY_NAME, 20)
|
||||||
|
val megaCorp = TestIdentity(CordaX500Name("MegaCorp", "London", "GB"))
|
||||||
|
val miniCorp = TestIdentity(CordaX500Name("MiniCorp", "London", "GB"))
|
||||||
|
val ALICE get() = alice.party
|
||||||
|
val ALICE_PUBKEY get() = alice.pubkey
|
||||||
|
val CHARLIE get() = charlie.party
|
||||||
|
val CHARLIE_IDENTITY get() = charlie.identity
|
||||||
|
val DUMMY_NOTARY get() = dummyNotary.party
|
||||||
|
val DUMMY_NOTARY_IDENTITY get() = dummyNotary.identity
|
||||||
|
val DUMMY_NOTARY_KEY get() = dummyNotary.key
|
||||||
|
val MEGA_CORP get() = megaCorp.party
|
||||||
|
val MEGA_CORP_IDENTITY get() = megaCorp.identity
|
||||||
|
val MEGA_CORP_KEY get() = megaCorp.key
|
||||||
|
val MEGA_CORP_PUBKEY get() = megaCorp.pubkey
|
||||||
|
val MINI_CORP get() = miniCorp.party
|
||||||
|
val MINI_CORP_IDENTITY get() = miniCorp.identity
|
||||||
|
val MINI_CORP_KEY get() = miniCorp.key
|
||||||
|
val MINI_CORP_PUBKEY get() = miniCorp.pubkey
|
||||||
|
}
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
@JvmField
|
@JvmField
|
||||||
val testSerialization = SerializationEnvironmentRule()
|
val testSerialization = SerializationEnvironmentRule()
|
||||||
@ -128,10 +155,10 @@ class CashTests {
|
|||||||
|
|
||||||
// Create some cash. Any attempt to spend >$500 will require multiple issuers to be involved.
|
// Create some cash. Any attempt to spend >$500 will require multiple issuers to be involved.
|
||||||
database.transaction {
|
database.transaction {
|
||||||
ourServices.fillWithSomeTestCash(issuerServices = megaCorpServices, ownedBy = ourIdentity, issuedBy = MEGA_CORP.ref(1), howMuch = 100.DOLLARS)
|
ourServices.fillWithSomeTestCash(issuerServices = megaCorpServices, ownedBy = ourIdentity, issuedBy = MEGA_CORP.ref(1), howMuch = 100.DOLLARS, outputNotary = DUMMY_NOTARY)
|
||||||
ourServices.fillWithSomeTestCash(issuerServices = megaCorpServices, ownedBy = ourIdentity, issuedBy = MEGA_CORP.ref(1), howMuch = 400.DOLLARS)
|
ourServices.fillWithSomeTestCash(issuerServices = megaCorpServices, ownedBy = ourIdentity, issuedBy = MEGA_CORP.ref(1), howMuch = 400.DOLLARS, outputNotary = DUMMY_NOTARY)
|
||||||
ourServices.fillWithSomeTestCash(issuerServices = miniCorpServices, ownedBy = ourIdentity, issuedBy = MINI_CORP.ref(1), howMuch = 80.DOLLARS)
|
ourServices.fillWithSomeTestCash(issuerServices = miniCorpServices, ownedBy = ourIdentity, issuedBy = MINI_CORP.ref(1), howMuch = 80.DOLLARS, outputNotary = DUMMY_NOTARY)
|
||||||
ourServices.fillWithSomeTestCash(issuerServices = miniCorpServices, ownedBy = ourIdentity, issuedBy = MINI_CORP.ref(1), howMuch = 80.SWISS_FRANCS)
|
ourServices.fillWithSomeTestCash(issuerServices = miniCorpServices, ownedBy = ourIdentity, issuedBy = MINI_CORP.ref(1), howMuch = 80.SWISS_FRANCS, outputNotary = DUMMY_NOTARY)
|
||||||
}
|
}
|
||||||
|
|
||||||
database.transaction {
|
database.transaction {
|
||||||
@ -150,6 +177,15 @@ class CashTests {
|
|||||||
database.close()
|
database.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun transaction(script: TransactionDSL<TransactionDSLInterpreter>.() -> EnforceVerifyOrFail) = run {
|
||||||
|
MockServices(rigorousMock<IdentityServiceInternal>().also {
|
||||||
|
doReturn(MEGA_CORP).whenever(it).partyFromKey(MEGA_CORP_PUBKEY)
|
||||||
|
doReturn(MINI_CORP).whenever(it).partyFromKey(MINI_CORP_PUBKEY)
|
||||||
|
doReturn(null).whenever(it).partyFromKey(ALICE_PUBKEY)
|
||||||
|
doReturn(null).whenever(it).partyFromKey(BOB_PUBKEY)
|
||||||
|
}, MEGA_CORP.name).transaction(DUMMY_NOTARY, script)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun trivial() {
|
fun trivial() {
|
||||||
transaction {
|
transaction {
|
||||||
@ -818,7 +854,7 @@ class CashTests {
|
|||||||
val mockService = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), rigorousMock<IdentityServiceInternal>().also {
|
val mockService = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), rigorousMock<IdentityServiceInternal>().also {
|
||||||
doReturn(MEGA_CORP).whenever(it).partyFromKey(MEGA_CORP_PUBKEY)
|
doReturn(MEGA_CORP).whenever(it).partyFromKey(MEGA_CORP_PUBKEY)
|
||||||
}, MEGA_CORP.name, MEGA_CORP_KEY)
|
}, MEGA_CORP.name, MEGA_CORP_KEY)
|
||||||
ledger(mockService) {
|
mockService.ledger(DUMMY_NOTARY) {
|
||||||
unverifiedTransaction {
|
unverifiedTransaction {
|
||||||
attachment(Cash.PROGRAM_ID)
|
attachment(Cash.PROGRAM_ID)
|
||||||
output(Cash.PROGRAM_ID, "MEGA_CORP cash",
|
output(Cash.PROGRAM_ID, "MEGA_CORP cash",
|
||||||
|
@ -7,12 +7,11 @@ import net.corda.core.identity.Party
|
|||||||
import net.corda.core.utilities.OpaqueBytes
|
import net.corda.core.utilities.OpaqueBytes
|
||||||
import net.corda.core.utilities.getOrThrow
|
import net.corda.core.utilities.getOrThrow
|
||||||
import net.corda.node.internal.StartedNode
|
import net.corda.node.internal.StartedNode
|
||||||
import net.corda.testing.BOC
|
import net.corda.testing.BOC_NAME
|
||||||
import net.corda.testing.chooseIdentity
|
|
||||||
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNetwork.MockNode
|
import net.corda.testing.node.MockNetwork.MockNode
|
||||||
import net.corda.testing.startFlow
|
import net.corda.testing.node.startFlow
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -31,10 +30,8 @@ class CashExitFlowTests {
|
|||||||
fun start() {
|
fun start() {
|
||||||
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(),
|
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(),
|
||||||
cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
||||||
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
|
bankOfCordaNode = mockNet.createPartyNode(BOC_NAME)
|
||||||
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
bankOfCorda = bankOfCordaNode.info.identityFromX500Name(BOC_NAME)
|
||||||
|
|
||||||
mockNet.runNetwork()
|
|
||||||
notary = mockNet.defaultNotaryIdentity
|
notary = mockNet.defaultNotaryIdentity
|
||||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture
|
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture
|
||||||
mockNet.runNetwork()
|
mockNet.runNetwork()
|
||||||
|
@ -14,6 +14,7 @@ import net.corda.testing.*
|
|||||||
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNetwork.MockNode
|
import net.corda.testing.node.MockNetwork.MockNode
|
||||||
|
import net.corda.testing.node.startFlow
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -31,8 +32,8 @@ class CashIssueAndPaymentFlowTests {
|
|||||||
@Before
|
@Before
|
||||||
fun start() {
|
fun start() {
|
||||||
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
||||||
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
|
bankOfCordaNode = mockNet.createPartyNode(BOC_NAME)
|
||||||
aliceNode = mockNet.createPartyNode(ALICE.name)
|
aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
||||||
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
||||||
mockNet.runNetwork()
|
mockNet.runNetwork()
|
||||||
notary = mockNet.defaultNotaryIdentity
|
notary = mockNet.defaultNotaryIdentity
|
||||||
|
@ -14,6 +14,7 @@ import net.corda.testing.*
|
|||||||
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNetwork.MockNode
|
import net.corda.testing.node.MockNetwork.MockNode
|
||||||
|
import net.corda.testing.node.startFlow
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -40,8 +41,8 @@ class CashIssueAndPayNoSelectionTests(private val anonymous: Boolean) {
|
|||||||
fun start() {
|
fun start() {
|
||||||
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(),
|
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(),
|
||||||
cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
||||||
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
|
bankOfCordaNode = mockNet.createPartyNode(BOC_NAME)
|
||||||
aliceNode = mockNet.createPartyNode(ALICE.name)
|
aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
||||||
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
||||||
mockNet.runNetwork()
|
mockNet.runNetwork()
|
||||||
notary = mockNet.defaultNotaryIdentity
|
notary = mockNet.defaultNotaryIdentity
|
||||||
|
@ -7,12 +7,11 @@ import net.corda.core.identity.Party
|
|||||||
import net.corda.core.utilities.OpaqueBytes
|
import net.corda.core.utilities.OpaqueBytes
|
||||||
import net.corda.core.utilities.getOrThrow
|
import net.corda.core.utilities.getOrThrow
|
||||||
import net.corda.node.internal.StartedNode
|
import net.corda.node.internal.StartedNode
|
||||||
import net.corda.testing.BOC
|
|
||||||
import net.corda.testing.BOC_NAME
|
import net.corda.testing.BOC_NAME
|
||||||
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNetwork.MockNode
|
import net.corda.testing.node.MockNetwork.MockNode
|
||||||
import net.corda.testing.startFlow
|
import net.corda.testing.node.startFlow
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -28,7 +27,7 @@ class CashIssueFlowTests {
|
|||||||
@Before
|
@Before
|
||||||
fun start() {
|
fun start() {
|
||||||
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
||||||
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
|
bankOfCordaNode = mockNet.createPartyNode(BOC_NAME)
|
||||||
bankOfCorda = bankOfCordaNode.info.identityFromX500Name(BOC_NAME)
|
bankOfCorda = bankOfCordaNode.info.identityFromX500Name(BOC_NAME)
|
||||||
notary = mockNet.defaultNotaryIdentity
|
notary = mockNet.defaultNotaryIdentity
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import net.corda.testing.*
|
|||||||
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
|
||||||
import net.corda.testing.node.MockNetwork
|
import net.corda.testing.node.MockNetwork
|
||||||
import net.corda.testing.node.MockNetwork.MockNode
|
import net.corda.testing.node.MockNetwork.MockNode
|
||||||
|
import net.corda.testing.node.startFlow
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -31,8 +32,8 @@ class CashPaymentFlowTests {
|
|||||||
@Before
|
@Before
|
||||||
fun start() {
|
fun start() {
|
||||||
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"))
|
||||||
bankOfCordaNode = mockNet.createPartyNode(BOC.name)
|
bankOfCordaNode = mockNet.createPartyNode(BOC_NAME)
|
||||||
aliceNode = mockNet.createPartyNode(ALICE.name)
|
aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
||||||
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
bankOfCorda = bankOfCordaNode.info.chooseIdentity()
|
||||||
mockNet.runNetwork()
|
mockNet.runNetwork()
|
||||||
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, mockNet.defaultNotaryIdentity)).resultFuture
|
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, mockNet.defaultNotaryIdentity)).resultFuture
|
||||||
|
@ -83,6 +83,10 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Parameterized.Parameters(name = "Anonymous = {0}")
|
@Parameterized.Parameters(name = "Anonymous = {0}")
|
||||||
fun data(): Collection<Boolean> = listOf(true, false)
|
fun data(): Collection<Boolean> = listOf(true, false)
|
||||||
|
|
||||||
|
private val dummyNotary = TestIdentity(DUMMY_NOTARY_NAME, 20)
|
||||||
|
private val MEGA_CORP = TestIdentity(CordaX500Name("MegaCorp", "London", "GB")).party
|
||||||
|
private val DUMMY_NOTARY get() = dummyNotary.party
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var mockNet: MockNetwork
|
private lateinit var mockNet: MockNetwork
|
||||||
@ -105,7 +109,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
// allow interruption half way through.
|
// allow interruption half way through.
|
||||||
mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages)
|
mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages)
|
||||||
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
||||||
ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) {
|
MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) {
|
||||||
val notaryNode = mockNet.defaultNotaryNode
|
val notaryNode = mockNet.defaultNotaryNode
|
||||||
val aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
val aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
||||||
val bobNode = mockNet.createPartyNode(BOB_NAME)
|
val bobNode = mockNet.createPartyNode(BOB_NAME)
|
||||||
@ -158,7 +162,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
fun `trade cash for commercial paper fails using soft locking`() {
|
fun `trade cash for commercial paper fails using soft locking`() {
|
||||||
mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages)
|
mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages)
|
||||||
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
||||||
ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) {
|
MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) {
|
||||||
val notaryNode = mockNet.defaultNotaryNode
|
val notaryNode = mockNet.defaultNotaryNode
|
||||||
val aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
val aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
||||||
val bobNode = mockNet.createPartyNode(BOB_NAME)
|
val bobNode = mockNet.createPartyNode(BOB_NAME)
|
||||||
@ -216,7 +220,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
fun `shutdown and restore`() {
|
fun `shutdown and restore`() {
|
||||||
mockNet = MockNetwork(cordappPackages = cordappPackages)
|
mockNet = MockNetwork(cordappPackages = cordappPackages)
|
||||||
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
||||||
ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) {
|
MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) {
|
||||||
val notaryNode = mockNet.defaultNotaryNode
|
val notaryNode = mockNet.defaultNotaryNode
|
||||||
val aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
val aliceNode = mockNet.createPartyNode(ALICE_NAME)
|
||||||
var bobNode = mockNet.createPartyNode(BOB_NAME)
|
var bobNode = mockNet.createPartyNode(BOB_NAME)
|
||||||
@ -338,9 +342,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val bob = bobNode.info.singleIdentity()
|
val bob = bobNode.info.singleIdentity()
|
||||||
val bank = bankNode.info.singleIdentity()
|
val bank = bankNode.info.singleIdentity()
|
||||||
val issuer = bank.ref(1, 2, 3)
|
val issuer = bank.ref(1, 2, 3)
|
||||||
|
aliceNode.services.ledger(DUMMY_NOTARY) {
|
||||||
ledger(aliceNode.services) {
|
|
||||||
|
|
||||||
// Insert a prospectus type attachment into the commercial paper transaction.
|
// Insert a prospectus type attachment into the commercial paper transaction.
|
||||||
val stream = ByteArrayOutputStream()
|
val stream = ByteArrayOutputStream()
|
||||||
JarOutputStream(stream).use {
|
JarOutputStream(stream).use {
|
||||||
@ -444,8 +446,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
val bank: Party = bankNode.info.singleIdentity()
|
val bank: Party = bankNode.info.singleIdentity()
|
||||||
val bob = bobNode.info.singleIdentity()
|
val bob = bobNode.info.singleIdentity()
|
||||||
val issuer = bank.ref(1, 2, 3)
|
val issuer = bank.ref(1, 2, 3)
|
||||||
|
aliceNode.services.ledger(DUMMY_NOTARY) {
|
||||||
ledger(aliceNode.services) {
|
|
||||||
// Insert a prospectus type attachment into the commercial paper transaction.
|
// Insert a prospectus type attachment into the commercial paper transaction.
|
||||||
val stream = ByteArrayOutputStream()
|
val stream = ByteArrayOutputStream()
|
||||||
JarOutputStream(stream).use {
|
JarOutputStream(stream).use {
|
||||||
@ -514,8 +515,8 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
fun `dependency with error on buyer side`() {
|
fun `dependency with error on buyer side`() {
|
||||||
mockNet = MockNetwork(cordappPackages = cordappPackages)
|
mockNet = MockNetwork(cordappPackages = cordappPackages)
|
||||||
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
||||||
ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) {
|
MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) {
|
||||||
runWithError(ledgerIdentityService,true, false, "at least one cash input")
|
runWithError(ledgerIdentityService, true, false, "at least one cash input")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,8 +524,8 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
|||||||
fun `dependency with error on seller side`() {
|
fun `dependency with error on seller side`() {
|
||||||
mockNet = MockNetwork(cordappPackages = cordappPackages)
|
mockNet = MockNetwork(cordappPackages = cordappPackages)
|
||||||
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
val ledgerIdentityService = rigorousMock<IdentityServiceInternal>()
|
||||||
ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) {
|
MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) {
|
||||||
runWithError(ledgerIdentityService,false, true, "Issuances have a time-window")
|
runWithError(ledgerIdentityService, false, true, "Issuances have a time-window")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +26,12 @@ include 'test-common'
|
|||||||
include 'test-utils'
|
include 'test-utils'
|
||||||
include 'smoke-test-utils'
|
include 'smoke-test-utils'
|
||||||
include 'node-driver'
|
include 'node-driver'
|
||||||
|
include 'perftestcordapp'
|
||||||
// Avoid making 'testing' a project, and allow build.gradle files to refer to these by their simple names:
|
// Avoid making 'testing' a project, and allow build.gradle files to refer to these by their simple names:
|
||||||
['test-common', 'test-utils', 'smoke-test-utils', 'node-driver'].each {
|
['test-common', 'test-utils', 'smoke-test-utils', 'node-driver'].each {
|
||||||
project(":$it").projectDir = new File("$settingsDir/testing/$it")
|
project(":$it").projectDir = new File("$settingsDir/testing/$it")
|
||||||
}
|
}
|
||||||
|
include 'tools:jmeter'
|
||||||
include 'tools:explorer'
|
include 'tools:explorer'
|
||||||
include 'tools:explorer:capsule'
|
include 'tools:explorer:capsule'
|
||||||
include 'tools:demobench'
|
include 'tools:demobench'
|
||||||
|
@ -3,7 +3,7 @@ package com.r3.corda.jmeter
|
|||||||
import net.corda.core.utilities.getOrThrow
|
import net.corda.core.utilities.getOrThrow
|
||||||
import net.corda.node.services.Permissions
|
import net.corda.node.services.Permissions
|
||||||
import net.corda.nodeapi.internal.config.User
|
import net.corda.nodeapi.internal.config.User
|
||||||
import net.corda.testing.DUMMY_NOTARY
|
import net.corda.testing.DUMMY_NOTARY_NAME
|
||||||
import net.corda.testing.node.NotarySpec
|
import net.corda.testing.node.NotarySpec
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
@ -20,11 +20,11 @@ class StartLocalPerfCorDapp {
|
|||||||
net.corda.testing.driver.driver(startNodesInProcess = false,
|
net.corda.testing.driver.driver(startNodesInProcess = false,
|
||||||
waitForAllNodesToFinish = true,
|
waitForAllNodesToFinish = true,
|
||||||
//isDebug = true,
|
//isDebug = true,
|
||||||
notarySpecs = listOf(NotarySpec(DUMMY_NOTARY.name, validating = false)),
|
notarySpecs = listOf(NotarySpec(DUMMY_NOTARY_NAME, validating = false)),
|
||||||
extraCordappPackagesToScan = listOf("com.r3.corda.enterprise.perftestcordapp")) {
|
extraCordappPackagesToScan = listOf("com.r3.corda.enterprise.perftestcordapp")) {
|
||||||
val (nodeA, nodeB) = listOf(
|
val (nodeA, nodeB) = listOf(
|
||||||
startNode(providedName = net.corda.testing.DUMMY_BANK_A.name, rpcUsers = listOf(demoUser), maximumHeapSize = "1G"),
|
startNode(providedName = net.corda.testing.DUMMY_BANK_A_NAME, rpcUsers = listOf(demoUser), maximumHeapSize = "1G"),
|
||||||
startNode(providedName = net.corda.testing.DUMMY_BANK_B.name, rpcUsers = listOf(demoUser), maximumHeapSize = "1G")
|
startNode(providedName = net.corda.testing.DUMMY_BANK_B_NAME, rpcUsers = listOf(demoUser), maximumHeapSize = "1G")
|
||||||
).map { it.getOrThrow() }
|
).map { it.getOrThrow() }
|
||||||
log.info("Nodes started!")
|
log.info("Nodes started!")
|
||||||
val input = BufferedReader(InputStreamReader(System.`in`))
|
val input = BufferedReader(InputStreamReader(System.`in`))
|
||||||
|
Loading…
Reference in New Issue
Block a user