From 9dc5ce2161a51f90ea482c53968378b582fc1045 Mon Sep 17 00:00:00 2001 From: Anthony Keenan Date: Wed, 28 Feb 2018 17:03:32 +0000 Subject: [PATCH] Apply new test api to enterprise tests --- .../net/corda/core/flows/FlowsInJavaTest.java | 1 - .../net/corda/node/NodePerformanceTests.kt | 116 ------------------ .../node/services/MySQLNotaryServiceTests.kt | 26 ++-- .../test/node/NodeStatePersistenceTests.kt | 8 +- .../contracts/CommercialPaperTests.kt | 1 + .../contracts/asset/CashSelectionH2Test.kt | 11 +- .../contracts/asset/CashTests.kt | 2 +- .../flows/CashExitFlowTests.kt | 7 +- .../flows/CashIssueAndPaymentFlowTests.kt | 8 +- .../CashIssueAndPaymentNoSelectionFlowTest.kt | 8 +- .../flows/CashIssueFlowTests.kt | 5 +- .../flows/CashPaymentFlowTests.kt | 18 +-- .../flows/TwoPartyTradeFlowTest.kt | 9 +- .../views/cordapps/iou/NewTransaction.kt | 4 +- 14 files changed, 51 insertions(+), 173 deletions(-) delete mode 100644 node/src/integration-test/kotlin/net/corda/node/NodePerformanceTests.kt diff --git a/core/src/test/java/net/corda/core/flows/FlowsInJavaTest.java b/core/src/test/java/net/corda/core/flows/FlowsInJavaTest.java index ea39a8be0f..0bb65bb89b 100644 --- a/core/src/test/java/net/corda/core/flows/FlowsInJavaTest.java +++ b/core/src/test/java/net/corda/core/flows/FlowsInJavaTest.java @@ -15,7 +15,6 @@ import java.util.concurrent.Future; import static java.util.Collections.emptyList; import static net.corda.testing.core.TestUtils.singleIdentity; -import static net.corda.testing.node.NodeTestUtils.startFlow; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.junit.Assert.fail; diff --git a/node/src/integration-test/kotlin/net/corda/node/NodePerformanceTests.kt b/node/src/integration-test/kotlin/net/corda/node/NodePerformanceTests.kt deleted file mode 100644 index 09412296b5..0000000000 --- a/node/src/integration-test/kotlin/net/corda/node/NodePerformanceTests.kt +++ /dev/null @@ -1,116 +0,0 @@ -package net.corda.node - -import co.paralleluniverse.fibers.Suspendable -import com.google.common.base.Stopwatch -import net.corda.client.rpc.CordaRPCClient -import net.corda.core.flows.FlowLogic -import net.corda.core.flows.StartableByRPC -import net.corda.core.internal.concurrent.transpose -import net.corda.core.messaging.startFlow -import net.corda.core.utilities.OpaqueBytes -import net.corda.core.utilities.getOrThrow -import net.corda.core.utilities.minutes -import net.corda.finance.DOLLARS -import net.corda.finance.flows.CashIssueFlow -import net.corda.finance.flows.CashPaymentFlow -import net.corda.node.services.Permissions.Companion.startFlow -import net.corda.testing.core.DUMMY_NOTARY_NAME -import net.corda.testing.driver.DriverParameters -import net.corda.testing.driver.InProcess -import net.corda.testing.node.User -import net.corda.testing.driver.driver -import net.corda.testing.driver.internal.internalServices -import net.corda.testing.internal.performance.div -import net.corda.testing.node.NotarySpec -import net.corda.testing.node.internal.internalDriver -import net.corda.testing.node.internal.performance.startPublishingFixedRateInjector -import net.corda.testing.node.internal.performance.startReporter -import net.corda.testing.node.internal.performance.startTightLoopInjector -import org.junit.Ignore -import org.junit.Test -import java.util.* -import java.util.concurrent.TimeUnit -import kotlin.streams.toList - -@Ignore("Run these locally") -class NodePerformanceTests { - @StartableByRPC - class EmptyFlow : FlowLogic() { - @Suspendable - override fun call() { - } - } - - private data class FlowMeasurementResult( - val flowPerSecond: Double, - val averageMs: Double - ) - - @Test - fun `empty flow per second`() { - driver(DriverParameters(startNodesInProcess = true)) { - val a = startNode(rpcUsers = listOf(User("A", "A", setOf(startFlow())))).get() - - CordaRPCClient(a.rpcAddress).use("A", "A") { connection -> - val timings = Collections.synchronizedList(ArrayList()) - val N = 10000 - val overallTiming = Stopwatch.createStarted().apply { - startTightLoopInjector( - parallelism = 8, - numberOfInjections = N, - queueBound = 50 - ) { - val timing = Stopwatch.createStarted().apply { - connection.proxy.startFlow(::EmptyFlow).returnValue.get() - }.stop().elapsed(TimeUnit.MICROSECONDS) - timings.add(timing) - } - }.stop().elapsed(TimeUnit.MICROSECONDS) - println( - FlowMeasurementResult( - flowPerSecond = N / (overallTiming * 0.000001), - averageMs = timings.average() * 0.001 - ) - ) - } - } - } - - @Test - fun `empty flow rate`() { - internalDriver(startNodesInProcess = true) { - val a = startNode(rpcUsers = listOf(User("A", "A", setOf(startFlow())))).get() - a as InProcess - val metricRegistry = startReporter(this.shutdownManager, a.internalServices.monitoringService.metrics) - CordaRPCClient(a.rpcAddress).use("A", "A") { connection -> - startPublishingFixedRateInjector(metricRegistry, 8, 5.minutes, 2000L / TimeUnit.SECONDS) { - connection.proxy.startFlow(::EmptyFlow).returnValue.get() - } - } - } - } - - @Test - fun `self pay rate`() { - val user = User("A", "A", setOf(startFlow(), startFlow())) - internalDriver( - notarySpecs = listOf(NotarySpec(DUMMY_NOTARY_NAME, rpcUsers = listOf(user))), - startNodesInProcess = true, - extraCordappPackagesToScan = listOf("net.corda.finance") - ) { - val notary = defaultNotaryNode.getOrThrow() as InProcess - val metricRegistry = startReporter(this.shutdownManager, notary.internalServices.monitoringService.metrics) - CordaRPCClient(notary.rpcAddress).use("A", "A") { connection -> - println("ISSUING") - val doneFutures = (1..100).toList().parallelStream().map { - connection.proxy.startFlow(::CashIssueFlow, 1.DOLLARS, OpaqueBytes.of(0), defaultNotaryIdentity).returnValue - }.toList() - doneFutures.transpose().get() - println("STARTING PAYMENT") - startPublishingFixedRateInjector(metricRegistry, 8, 5.minutes, 100L / TimeUnit.SECONDS) { - connection.proxy.startFlow(::CashPaymentFlow, 1.DOLLARS, defaultNotaryIdentity).returnValue.get() - } - } - } - } -} \ No newline at end of file diff --git a/node/src/integration-test/kotlin/net/corda/node/services/MySQLNotaryServiceTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/MySQLNotaryServiceTests.kt index 60317e1ccf..8486cb67e7 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/MySQLNotaryServiceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/MySQLNotaryServiceTests.kt @@ -20,15 +20,15 @@ import net.corda.nodeapi.internal.DevIdentityGenerator import net.corda.nodeapi.internal.network.NetworkParametersCopier import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.contracts.DummyContract -import net.corda.testing.core.chooseIdentity import net.corda.testing.core.dummyCommand +import net.corda.testing.core.singleIdentity import net.corda.testing.internal.IntegrationTest import net.corda.testing.internal.IntegrationTestSchemas -import net.corda.testing.node.MockNodeParameters import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties import net.corda.testing.node.inMemoryH2DataSourceConfig import net.corda.testing.node.internal.InternalMockNetwork -import net.corda.testing.node.startFlow +import net.corda.testing.node.internal.InternalMockNodeParameters +import net.corda.testing.node.internal.startFlow import org.junit.After import org.junit.Before import org.junit.ClassRule @@ -77,22 +77,22 @@ class MySQLNotaryServiceTests : IntegrationTest() { val firstTxBuilder = TransactionBuilder(notaryParty) .addInputState(inputState) - .addCommand(dummyCommand(node.services.myInfo.chooseIdentity().owningKey)) + .addCommand(dummyCommand(node.services.myInfo.singleIdentity().owningKey)) val firstSpendTx = node.services.signInitialTransaction(firstTxBuilder) - val firstSpend = node.services.startFlow(NotaryFlow.Client(firstSpendTx)) + val firstSpend = node.services.startFlow(NotaryFlow.Client(firstSpendTx)).resultFuture mockNet.runNetwork() firstSpend.getOrThrow() val secondSpendBuilder = TransactionBuilder(notaryParty).withItems(inputState).run { - val dummyState = DummyContract.SingleOwnerState(0, node.info.chooseIdentity()) + val dummyState = DummyContract.SingleOwnerState(0, node.info.singleIdentity()) addOutputState(dummyState, DummyContract.PROGRAM_ID) - addCommand(dummyCommand(node.services.myInfo.chooseIdentity().owningKey)) + addCommand(dummyCommand(node.services.myInfo.singleIdentity().owningKey)) this } val secondSpendTx = node.services.signInitialTransaction(secondSpendBuilder) - val secondSpend = node.services.startFlow(NotaryFlow.Client(secondSpendTx)) + val secondSpend = node.services.startFlow(NotaryFlow.Client(secondSpendTx)).resultFuture mockNet.runNetwork() @@ -107,14 +107,14 @@ class MySQLNotaryServiceTests : IntegrationTest() { val txBuilder = TransactionBuilder(notaryParty) .addInputState(inputState) - .addCommand(dummyCommand(node.services.myInfo.chooseIdentity().owningKey)) + .addCommand(dummyCommand(node.services.myInfo.singleIdentity().owningKey)) val spendTx = node.services.signInitialTransaction(txBuilder) - val notarise = node.services.startFlow(NotaryFlow.Client(spendTx)) + val notarise = node.services.startFlow(NotaryFlow.Client(spendTx)).resultFuture mockNet.runNetwork() val signature = notarise.get().single() - val notariseRetry = node.services.startFlow(NotaryFlow.Client(spendTx)) + val notariseRetry = node.services.startFlow(NotaryFlow.Client(spendTx)).resultFuture mockNet.runNetwork() val signatureRetry = notariseRetry.get().single() @@ -132,7 +132,7 @@ class MySQLNotaryServiceTests : IntegrationTest() { setProperty("autoCommit", "false") } return mockNet.createUnstartedNode( - MockNodeParameters( + InternalMockNodeParameters( legalName = notaryName, entropyRoot = BigInteger.valueOf(60L), configOverrides = { @@ -145,7 +145,7 @@ class MySQLNotaryServiceTests : IntegrationTest() { private fun issueState(node: StartedNode, notary: Party): StateAndRef<*> { return node.database.transaction { - val builder = DummyContract.generateInitial(Random().nextInt(), notary, node.info.chooseIdentity().ref(0)) + val builder = DummyContract.generateInitial(Random().nextInt(), notary, node.info.singleIdentity().ref(0)) val stx = node.services.signInitialTransaction(builder) node.services.recordTransactions(stx) StateAndRef(builder.outputStates().first(), StateRef(stx.id, 0)) diff --git a/node/src/integration-test/kotlin/net/corda/test/node/NodeStatePersistenceTests.kt b/node/src/integration-test/kotlin/net/corda/test/node/NodeStatePersistenceTests.kt index d4831f0ed0..abdffb2720 100644 --- a/node/src/integration-test/kotlin/net/corda/test/node/NodeStatePersistenceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/test/node/NodeStatePersistenceTests.kt @@ -22,18 +22,12 @@ import net.corda.node.services.Permissions.Companion.invokeRpc import net.corda.node.services.Permissions.Companion.startFlow import net.corda.testing.core.* import net.corda.testing.driver.DriverParameters -import net.corda.testing.driver.PortAllocation import net.corda.testing.driver.driver +import net.corda.testing.driver.internal.RandomFree import net.corda.testing.internal.IntegrationTest import net.corda.testing.internal.IntegrationTestSchemas import net.corda.testing.internal.toDatabaseSchemaName import net.corda.testing.node.User -import net.corda.testing.node.User -import net.corda.testing.core.singleIdentity -import net.corda.testing.driver.DriverParameters -import net.corda.testing.driver.PortAllocation -import net.corda.testing.driver.driver -import net.corda.testing.driver.internal.RandomFree import org.junit.Assume.assumeFalse import org.junit.ClassRule import org.junit.Test 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 e967e99c7e..f280e1c1c4 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 @@ -20,6 +20,7 @@ import net.corda.testing.core.* import net.corda.testing.dsl.EnforceVerifyOrFail import net.corda.testing.dsl.TransactionDSL import net.corda.testing.dsl.TransactionDSLInterpreter +import net.corda.testing.internal.TEST_TX_TIME import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices import net.corda.testing.node.ledger 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 6e8a3c5ecb..0a49dd8a9b 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 @@ -10,7 +10,6 @@ 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.node.startFlow import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.After import org.junit.Test @@ -33,10 +32,10 @@ class CashSelectionH2Test { // 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)) + node.startFlow(CashIssueFlow(issueAmount.POUNDS, OpaqueBytes.of(1), mockNet.defaultNotaryIdentity)) }.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])).getOrThrow() + node.startFlow(CashPaymentFlow((Integer.MAX_VALUE + 1L).POUNDS, node.info.legalIdentities[0])).getOrThrow() } @Test @@ -48,9 +47,9 @@ class CashSelectionH2Test { val notary = mockNet.defaultNotaryIdentity // Start more cash spends than we have connections. If spend leaks a connection on retry, we will run out of connections. - val flow1 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) - val flow2 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) - val flow3 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) + val flow1 = bankA.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) + val flow2 = bankA.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) + val flow3 = bankA.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) assertThatThrownBy { flow1.getOrThrow() }.isInstanceOf(CashException::class.java) assertThatThrownBy { flow2.getOrThrow() }.isInstanceOf(CashException::class.java) 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 9498154bf4..4ef010d847 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 @@ -62,7 +62,7 @@ fun ServiceHub.fillWithSomeTestCash(howMuch: Amount, ref: OpaqueBytes = OpaqueBytes(ByteArray(1, { 1 })), ownedBy: AbstractParty? = null, issuedBy: PartyAndReference = DUMMY_CASH_ISSUER): Vault { - val myKey = ownedBy?.owningKey ?: myInfo.chooseIdentity().owningKey + val myKey = ownedBy?.owningKey ?: myInfo.singleIdentity().owningKey val anonParty = AnonymousParty(myKey) // We will allocate one state to one transaction, for simplicities sake. 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 50c439c99a..3b4ed5eccd 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 @@ -10,7 +10,6 @@ import net.corda.testing.core.BOC_NAME import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork import net.corda.testing.node.StartedMockNode -import net.corda.testing.node.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -32,7 +31,7 @@ class CashExitFlowTests { bankOfCordaNode = mockNet.createPartyNode(BOC_NAME) bankOfCorda = bankOfCordaNode.info.identityFromX500Name(BOC_NAME) notary = mockNet.defaultNotaryIdentity - val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)) + val future = bankOfCordaNode.startFlow(CashIssueFlow(initialBalance, ref, notary)) mockNet.runNetwork() future.getOrThrow() } @@ -45,7 +44,7 @@ class CashExitFlowTests { @Test fun `exit some cash`() { val exitAmount = 500.DOLLARS - val future = bankOfCordaNode.services.startFlow(CashExitFlow(exitAmount, ref)) + val future = bankOfCordaNode.startFlow(CashExitFlow(exitAmount, ref)) mockNet.runNetwork() val exitTx = future.getOrThrow().stx.tx val expected = (initialBalance - exitAmount).`issued by`(bankOfCorda.ref(ref)) @@ -58,7 +57,7 @@ class CashExitFlowTests { @Test fun `exit zero cash`() { val expected = 0.DOLLARS - val future = bankOfCordaNode.services.startFlow(CashExitFlow(expected, ref)) + val future = bankOfCordaNode.startFlow(CashExitFlow(expected, ref)) mockNet.runNetwork() assertFailsWith { future.getOrThrow() 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 6d0c32e2dd..4cd16076d1 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 @@ -13,7 +13,7 @@ import net.corda.node.internal.StartedNode import net.corda.testing.core.* import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.internal.InternalMockNetwork -import net.corda.testing.node.startFlow +import net.corda.testing.node.internal.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -33,7 +33,7 @@ class CashIssueAndPaymentFlowTests { cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset", "com.r3.corda.enterprise.perftestcordapp.schemas")) bankOfCordaNode = mockNet.createPartyNode(BOC_NAME) aliceNode = mockNet.createPartyNode(ALICE_NAME) - bankOfCorda = bankOfCordaNode.info.chooseIdentity() + bankOfCorda = bankOfCordaNode.info.singleIdentity() mockNet.runNetwork() notary = mockNet.defaultNotaryIdentity } @@ -45,7 +45,7 @@ class CashIssueAndPaymentFlowTests { @Test fun `issue and pay some cash`() { - val payTo = aliceNode.info.chooseIdentity() + val payTo = aliceNode.info.singleIdentity() val expectedPayment = 500.DOLLARS bankOfCordaNode.database.transaction { @@ -54,7 +54,7 @@ class CashIssueAndPaymentFlowTests { val (_, vaultUpdatesBoc) = bankOfCordaNode.services.vaultService.trackBy(criteria) val (_, vaultUpdatesBankClient) = aliceNode.services.vaultService.trackBy(criteria) - val future = bankOfCordaNode.services.startFlow(CashIssueAndPaymentFlow(expectedPayment, OpaqueBytes.of(1), payTo, false, notary)) + val future = bankOfCordaNode.services.startFlow(CashIssueAndPaymentFlow(expectedPayment, OpaqueBytes.of(1), payTo, false, notary)).resultFuture mockNet.runNetwork() future.getOrThrow() 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 7207975eac..cd7225d0f4 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 @@ -15,7 +15,7 @@ import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStra import net.corda.testing.node.MockNetwork import net.corda.testing.node.StartedMockNode import net.corda.testing.node.internal.InternalMockNetwork -import net.corda.testing.node.startFlow +import net.corda.testing.node.internal.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -44,7 +44,7 @@ class CashIssueAndPayNoSelectionTests(private val anonymous: Boolean) { cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset", "com.r3.corda.enterprise.perftestcordapp.schemas")) bankOfCordaNode = mockNet.createPartyNode(BOC_NAME) aliceNode = mockNet.createPartyNode(ALICE_NAME) - bankOfCorda = bankOfCordaNode.info.chooseIdentity() + bankOfCorda = bankOfCordaNode.info.singleIdentity() mockNet.runNetwork() notary = mockNet.defaultNotaryIdentity } @@ -56,7 +56,7 @@ class CashIssueAndPayNoSelectionTests(private val anonymous: Boolean) { @Test fun `issue and pay some cash`() { - val payTo = aliceNode.info.chooseIdentity() + val payTo = aliceNode.info.singleIdentity() val expectedPayment = 500.DOLLARS bankOfCordaNode.database.transaction { @@ -68,7 +68,7 @@ class CashIssueAndPayNoSelectionTests(private val anonymous: Boolean) { = aliceNode.services.vaultService.trackBy(criteria) val future = bankOfCordaNode.services.startFlow(CashIssueAndPaymentNoSelection( - expectedPayment, OpaqueBytes.of(1), payTo, anonymous, notary)) + expectedPayment, OpaqueBytes.of(1), payTo, anonymous, notary)).resultFuture mockNet.runNetwork() future.getOrThrow() 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 29751c0acd..4c5a6ea0a3 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 @@ -10,7 +10,6 @@ import net.corda.testing.core.BOC_NAME import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.MockNetwork import net.corda.testing.node.StartedMockNode -import net.corda.testing.node.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -42,7 +41,7 @@ class CashIssueFlowTests { fun `issue some cash`() { val expected = 500.DOLLARS val ref = OpaqueBytes.of(0x01) - val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary)) + val future = bankOfCordaNode.startFlow(CashIssueFlow(expected, ref, notary)) mockNet.runNetwork() val issueTx = future.getOrThrow().stx val output = issueTx.tx.outputsOfType().single() @@ -53,7 +52,7 @@ class CashIssueFlowTests { fun `issue zero cash`() { val expected = 0.DOLLARS val ref = OpaqueBytes.of(0x01) - val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary)) + val future = bankOfCordaNode.startFlow(CashIssueFlow(expected, ref, notary)) mockNet.runNetwork() assertFailsWith { future.getOrThrow() 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 be49181d35..37e9235808 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 @@ -13,7 +13,7 @@ import net.corda.node.internal.StartedNode import net.corda.testing.core.* import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.internal.InternalMockNetwork -import net.corda.testing.node.startFlow +import net.corda.testing.node.internal.startFlow import org.junit.After import org.junit.Before import org.junit.Test @@ -35,9 +35,9 @@ class CashPaymentFlowTests { cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset", "com.r3.corda.enterprise.perftestcordapp.schemas")) bankOfCordaNode = mockNet.createPartyNode(BOC_NAME) aliceNode = mockNet.createPartyNode(ALICE_NAME) - bankOfCorda = bankOfCordaNode.info.chooseIdentity() + bankOfCorda = bankOfCordaNode.info.singleIdentity() mockNet.runNetwork() - val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, mockNet.defaultNotaryIdentity)) + val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, mockNet.defaultNotaryIdentity)).resultFuture future.getOrThrow() } @@ -48,7 +48,7 @@ class CashPaymentFlowTests { @Test fun `pay some cash`() { - val payTo = aliceNode.info.chooseIdentity() + val payTo = aliceNode.info.singleIdentity() val expectedPayment = 500.DOLLARS val expectedChange = 1500.DOLLARS @@ -59,7 +59,7 @@ class CashPaymentFlowTests { val (_, vaultUpdatesBankClient) = aliceNode.services.vaultService.trackBy(criteria) val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expectedPayment, - payTo)) + payTo)).resultFuture mockNet.runNetwork() future.getOrThrow() @@ -88,10 +88,10 @@ class CashPaymentFlowTests { @Test fun `pay more than we have`() { - val payTo = aliceNode.info.chooseIdentity() + val payTo = aliceNode.info.singleIdentity() val expected = 4000.DOLLARS val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected, - payTo)) + payTo)).resultFuture mockNet.runNetwork() assertFailsWith { future.getOrThrow() @@ -100,10 +100,10 @@ class CashPaymentFlowTests { @Test fun `pay zero cash`() { - val payTo = aliceNode.info.chooseIdentity() + val payTo = aliceNode.info.singleIdentity() val expected = 0.DOLLARS val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected, - payTo)) + payTo)).resultFuture mockNet.runNetwork() assertFailsWith { future.getOrThrow() 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 d8e6c2afc5..31566345a6 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 @@ -51,10 +51,13 @@ import net.corda.testing.dsl.LedgerDSL import net.corda.testing.dsl.TestLedgerDSLInterpreter import net.corda.testing.dsl.TestTransactionDSLInterpreter import net.corda.testing.internal.LogHelper +import net.corda.testing.internal.TEST_TX_TIME import net.corda.testing.internal.rigorousMock import net.corda.testing.node.* import net.corda.testing.node.internal.InternalMockNetwork +import net.corda.testing.node.internal.InternalMockNodeParameters import net.corda.testing.node.internal.pumpReceive +import net.corda.testing.node.internal.startFlow import org.assertj.core.api.Assertions.assertThat import org.junit.After import org.junit.Before @@ -292,7 +295,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { // ... bring the node back up ... the act of constructing the SMM will re-register the message handlers // that Bob was waiting on before the reboot occurred. - bobNode = mockNet.createNode(MockNodeParameters(bobAddr.id, BOB_NAME)) + bobNode = mockNet.createNode(InternalMockNodeParameters(bobAddr.id, BOB_NAME)) // Find the future representing the result of this state machine again. val bobFuture = bobNode.smm.findStateMachines(BuyerAcceptor::class.java).single().second @@ -327,7 +330,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { private fun makeNodeWithTracking( name: CordaX500Name): StartedNode { // Create a node in the mock network ... - return mockNet.createNode(MockNodeParameters(legalName = name), nodeFactory = { args -> + return mockNet.createNode(InternalMockNodeParameters(legalName = name), nodeFactory = { args -> object : InternalMockNetwork.MockNode(args) { // That constructs a recording tx storage override fun makeTransactionStorage(database: CordaPersistence, transactionCacheSizeBytes: Long): WritableTransactionStorage { @@ -552,7 +555,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) { val buyerFlows: Observable> = buyerNode.registerInitiatedFlow(BuyerAcceptor::class.java) val firstBuyerFiber = buyerFlows.toFuture().map { it.stateMachine } val seller = SellerInitiator(buyer, notary, assetToSell, 1000.DOLLARS, anonymous) - val sellerResult = sellerNode.services.startFlow(seller) + val sellerResult = sellerNode.services.startFlow(seller).resultFuture return RunResult(firstBuyerFiber, sellerResult, seller.stateMachine.id) } diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/iou/NewTransaction.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/iou/NewTransaction.kt index fde1d620b7..9c0fa8d254 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/iou/NewTransaction.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/iou/NewTransaction.kt @@ -32,7 +32,7 @@ import net.corda.explorer.model.MembershipListModel import net.corda.explorer.views.bigDecimalFormatter import net.corda.explorer.views.stringConverter import net.corda.sample.businessnetwork.iou.IOUFlow -import net.corda.testing.core.chooseIdentityAndCert +import net.corda.testing.core.singleIdentityAndCert import org.controlsfx.dialog.ExceptionDialog import tornadofx.* @@ -60,7 +60,7 @@ class NewTransaction : Fragment() { } partyBChoiceBox.apply { - items = FXCollections.observableList(parties.map { it.chooseIdentityAndCert() }).filtered { elementsFromServer.contains(it.party) }.sorted() + items = FXCollections.observableList(parties.map { it.singleIdentityAndCert() }).filtered { elementsFromServer.contains(it.party) }.sorted() } newTransactionDialog(window).showAndWait().ifPresent { request ->