diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt index 27898fefe7..76e81fc64b 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/CommercialPaperTests.kt @@ -1,10 +1,14 @@ 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.`issued by` import com.r3.corda.enterprise.perftestcordapp.contracts.asset.* import net.corda.core.contracts.* +import net.corda.core.crypto.generateKeyPair import net.corda.core.identity.AnonymousParty +import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.node.services.Vault 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.utilities.days import net.corda.core.utilities.seconds +import net.corda.node.services.api.IdentityServiceInternal import net.corda.testing.* import net.corda.testing.node.MockServices +import net.corda.testing.node.ledger import net.corda.testing.node.makeTestIdentityService +import net.corda.testing.node.transaction import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -34,6 +41,11 @@ interface CommercialPaperTestTemplate { 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 { override fun getPaper(): CommercialPaper.State = CommercialPaper.State( @@ -68,6 +80,23 @@ class CommercialPaperTestsGeneric { companion object { @Parameterized.Parameters @JvmStatic 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 @@ -76,11 +105,17 @@ class CommercialPaperTestsGeneric { @JvmField val testSerialization = SerializationEnvironmentRule() val issuer = MEGA_CORP.ref(123) + private val ledgerServices = MockServices(rigorousMock().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 fun `trade lifecycle test`() { val someProfits = 1200.DOLLARS `issued by` issuer - ledger { + ledgerServices.ledger(DUMMY_NOTARY) { unverifiedTransaction { attachment(Cash.PROGRAM_ID) 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.() -> EnforceVerifyOrFail) = run { + ledgerServices.transaction(DUMMY_NOTARY, script) + } + @Test fun `key mismatch at issue`() { transaction { @@ -210,7 +249,7 @@ class CommercialPaperTestsGeneric { private lateinit var aliceVaultService: VaultService private lateinit var alicesVault: Vault - 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 lateinit var moveTX: SignedTransaction @@ -226,7 +265,7 @@ class CommercialPaperTestsGeneric { aliceVaultService = aliceServices.vaultService 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 } @@ -239,7 +278,7 @@ class CommercialPaperTestsGeneric { bigCorpVaultService = bigCorpServices.vaultService 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 } diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashSelectionH2Test.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashSelectionH2Test.kt index 5af511b3ac..ab9e46a684 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashSelectionH2Test.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashSelectionH2Test.kt @@ -1,24 +1,42 @@ package com.r3.corda.enterprise.perftestcordapp.contracts.asset 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.CashIssueFlow 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.testing.node.MockNetwork 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.junit.After import org.junit.Test +import java.util.Collections.nCopies 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 fun cleanUp() { 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 fun `check does not hold connection over retries`() { val bankA = mockNet.createNode(MockNodeParameters(configOverrides = { diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt index cf4c86d5d2..dd53cbbdf7 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/contracts/asset/CashTests.kt @@ -30,7 +30,9 @@ import net.corda.testing.* import net.corda.testing.contracts.DummyState import net.corda.testing.node.MockServices 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.transaction import org.junit.After import org.junit.Before import org.junit.Rule @@ -52,7 +54,7 @@ import kotlin.test.* */ fun ServiceHub.fillWithSomeTestCash(howMuch: Amount, issuerServices: ServiceHub = this, - outputNotary: Party = DUMMY_NOTARY, + outputNotary: Party, ref: OpaqueBytes = OpaqueBytes(ByteArray(1, { 1 })), ownedBy: AbstractParty? = null, issuedBy: PartyAndReference = DUMMY_CASH_ISSUER): Vault { @@ -73,6 +75,31 @@ fun ServiceHub.fillWithSomeTestCash(howMuch: Amount, } 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 @JvmField val testSerialization = SerializationEnvironmentRule() @@ -128,10 +155,10 @@ class CashTests { // Create some cash. Any attempt to spend >$500 will require multiple issuers to be involved. 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 = 400.DOLLARS) - 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.SWISS_FRANCS) + 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, outputNotary = DUMMY_NOTARY) + 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, outputNotary = DUMMY_NOTARY) } database.transaction { @@ -150,6 +177,15 @@ class CashTests { database.close() } + private fun transaction(script: TransactionDSL.() -> EnforceVerifyOrFail) = run { + MockServices(rigorousMock().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 fun trivial() { transaction { @@ -818,7 +854,7 @@ class CashTests { val mockService = MockServices(listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset"), rigorousMock().also { doReturn(MEGA_CORP).whenever(it).partyFromKey(MEGA_CORP_PUBKEY) }, MEGA_CORP.name, MEGA_CORP_KEY) - ledger(mockService) { + mockService.ledger(DUMMY_NOTARY) { unverifiedTransaction { attachment(Cash.PROGRAM_ID) output(Cash.PROGRAM_ID, "MEGA_CORP cash", diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlowTests.kt index 84b0958e4f..c2cc2b7115 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashExitFlowTests.kt @@ -7,12 +7,11 @@ import net.corda.core.identity.Party import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.getOrThrow import net.corda.node.internal.StartedNode -import net.corda.testing.BOC -import net.corda.testing.chooseIdentity +import net.corda.testing.BOC_NAME import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork 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.Before import org.junit.Test @@ -31,10 +30,8 @@ class CashExitFlowTests { fun start() { mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset")) - bankOfCordaNode = mockNet.createPartyNode(BOC.name) - bankOfCorda = bankOfCordaNode.info.chooseIdentity() - - mockNet.runNetwork() + bankOfCordaNode = mockNet.createPartyNode(BOC_NAME) + bankOfCorda = bankOfCordaNode.info.identityFromX500Name(BOC_NAME) notary = mockNet.defaultNotaryIdentity val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)).resultFuture mockNet.runNetwork() diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentFlowTests.kt index 8033226110..80c1ed495c 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentFlowTests.kt @@ -14,6 +14,7 @@ import net.corda.testing.* import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork.MockNode +import net.corda.testing.node.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -31,8 +32,8 @@ class CashIssueAndPaymentFlowTests { @Before fun start() { mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset")) - bankOfCordaNode = mockNet.createPartyNode(BOC.name) - aliceNode = mockNet.createPartyNode(ALICE.name) + bankOfCordaNode = mockNet.createPartyNode(BOC_NAME) + aliceNode = mockNet.createPartyNode(ALICE_NAME) bankOfCorda = bankOfCordaNode.info.chooseIdentity() mockNet.runNetwork() notary = mockNet.defaultNotaryIdentity diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentNoSelectionFlowTest.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentNoSelectionFlowTest.kt index 891cc05164..d8e4f7c3b2 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentNoSelectionFlowTest.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueAndPaymentNoSelectionFlowTest.kt @@ -14,6 +14,7 @@ import net.corda.testing.* import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork.MockNode +import net.corda.testing.node.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -40,8 +41,8 @@ class CashIssueAndPayNoSelectionTests(private val anonymous: Boolean) { fun start() { mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset")) - bankOfCordaNode = mockNet.createPartyNode(BOC.name) - aliceNode = mockNet.createPartyNode(ALICE.name) + bankOfCordaNode = mockNet.createPartyNode(BOC_NAME) + aliceNode = mockNet.createPartyNode(ALICE_NAME) bankOfCorda = bankOfCordaNode.info.chooseIdentity() mockNet.runNetwork() notary = mockNet.defaultNotaryIdentity diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlowTests.kt index 467c1c7b0b..aea4d0ebd9 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashIssueFlowTests.kt @@ -7,12 +7,11 @@ import net.corda.core.identity.Party import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.getOrThrow import net.corda.node.internal.StartedNode -import net.corda.testing.BOC import net.corda.testing.BOC_NAME import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork 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.Before import org.junit.Test @@ -28,7 +27,7 @@ class CashIssueFlowTests { @Before fun start() { 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) notary = mockNet.defaultNotaryIdentity } diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlowTests.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlowTests.kt index a43515da84..dda8aec4c8 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlowTests.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/CashPaymentFlowTests.kt @@ -14,6 +14,7 @@ import net.corda.testing.* import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork.MockNode +import net.corda.testing.node.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -31,8 +32,8 @@ class CashPaymentFlowTests { @Before fun start() { mockNet = MockNetwork(servicePeerAllocationStrategy = RoundRobin(), cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset")) - bankOfCordaNode = mockNet.createPartyNode(BOC.name) - aliceNode = mockNet.createPartyNode(ALICE.name) + bankOfCordaNode = mockNet.createPartyNode(BOC_NAME) + aliceNode = mockNet.createPartyNode(ALICE_NAME) bankOfCorda = bankOfCordaNode.info.chooseIdentity() mockNet.runNetwork() val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, mockNet.defaultNotaryIdentity)).resultFuture diff --git a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt index 6e6861320b..34ff8c2a90 100644 --- a/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt +++ b/perftestcordapp/src/test/kotlin/com/r3/corda/enterprise/perftestcordapp/flows/TwoPartyTradeFlowTest.kt @@ -83,6 +83,10 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { @JvmStatic @Parameterized.Parameters(name = "Anonymous = {0}") fun data(): Collection = 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 @@ -105,7 +109,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { // allow interruption half way through. mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages) val ledgerIdentityService = rigorousMock() - ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { + MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) { val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_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`() { mockNet = MockNetwork(threadPerNode = true, cordappPackages = cordappPackages) val ledgerIdentityService = rigorousMock() - ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { + MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) { val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) val bobNode = mockNet.createPartyNode(BOB_NAME) @@ -216,7 +220,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { fun `shutdown and restore`() { mockNet = MockNetwork(cordappPackages = cordappPackages) val ledgerIdentityService = rigorousMock() - ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { + MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) { val notaryNode = mockNet.defaultNotaryNode val aliceNode = mockNet.createPartyNode(ALICE_NAME) var bobNode = mockNet.createPartyNode(BOB_NAME) @@ -338,9 +342,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val bob = bobNode.info.singleIdentity() val bank = bankNode.info.singleIdentity() val issuer = bank.ref(1, 2, 3) - - ledger(aliceNode.services) { - + aliceNode.services.ledger(DUMMY_NOTARY) { // Insert a prospectus type attachment into the commercial paper transaction. val stream = ByteArrayOutputStream() JarOutputStream(stream).use { @@ -444,8 +446,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val bank: Party = bankNode.info.singleIdentity() val bob = bobNode.info.singleIdentity() val issuer = bank.ref(1, 2, 3) - - ledger(aliceNode.services) { + aliceNode.services.ledger(DUMMY_NOTARY) { // Insert a prospectus type attachment into the commercial paper transaction. val stream = ByteArrayOutputStream() JarOutputStream(stream).use { @@ -514,8 +515,8 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { fun `dependency with error on buyer side`() { mockNet = MockNetwork(cordappPackages = cordappPackages) val ledgerIdentityService = rigorousMock() - ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { - runWithError(ledgerIdentityService,true, false, "at least one cash input") + MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) { + 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`() { mockNet = MockNetwork(cordappPackages = cordappPackages) val ledgerIdentityService = rigorousMock() - ledger(MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name)) { - runWithError(ledgerIdentityService,false, true, "Issuances have a time-window") + MockServices(cordappPackages, ledgerIdentityService, MEGA_CORP.name).ledger(DUMMY_NOTARY) { + runWithError(ledgerIdentityService, false, true, "Issuances have a time-window") } } diff --git a/settings.gradle b/settings.gradle index 1b6733dec8..e16e3ca0aa 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,10 +26,12 @@ include 'test-common' include 'test-utils' include 'smoke-test-utils' include 'node-driver' +include 'perftestcordapp' // 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 { project(":$it").projectDir = new File("$settingsDir/testing/$it") } +include 'tools:jmeter' include 'tools:explorer' include 'tools:explorer:capsule' include 'tools:demobench' diff --git a/tools/jmeter/src/test/kotlin/com/r3/corda/jmeter/StartLocalPerfCorDapp.kt b/tools/jmeter/src/test/kotlin/com/r3/corda/jmeter/StartLocalPerfCorDapp.kt index 6feea7f126..7f23b83893 100644 --- a/tools/jmeter/src/test/kotlin/com/r3/corda/jmeter/StartLocalPerfCorDapp.kt +++ b/tools/jmeter/src/test/kotlin/com/r3/corda/jmeter/StartLocalPerfCorDapp.kt @@ -3,7 +3,7 @@ package com.r3.corda.jmeter import net.corda.core.utilities.getOrThrow import net.corda.node.services.Permissions 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 org.slf4j.LoggerFactory import java.io.BufferedReader @@ -20,11 +20,11 @@ class StartLocalPerfCorDapp { net.corda.testing.driver.driver(startNodesInProcess = false, waitForAllNodesToFinish = 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")) { 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_B.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") ).map { it.getOrThrow() } log.info("Nodes started!") val input = BufferedReader(InputStreamReader(System.`in`))