Apply new test api to enterprise tests

This commit is contained in:
Anthony Keenan 2018-02-28 17:03:32 +00:00
parent c72b3ad4fa
commit 9dc5ce2161
14 changed files with 51 additions and 173 deletions

View File

@ -15,7 +15,6 @@ import java.util.concurrent.Future;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static net.corda.testing.core.TestUtils.singleIdentity; 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.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;

View File

@ -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<Unit>() {
@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<EmptyFlow>())))).get()
CordaRPCClient(a.rpcAddress).use("A", "A") { connection ->
val timings = Collections.synchronizedList(ArrayList<Long>())
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<EmptyFlow>())))).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<CashIssueFlow>(), startFlow<CashPaymentFlow>()))
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()
}
}
}
}
}

View File

@ -20,15 +20,15 @@ import net.corda.nodeapi.internal.DevIdentityGenerator
import net.corda.nodeapi.internal.network.NetworkParametersCopier import net.corda.nodeapi.internal.network.NetworkParametersCopier
import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.common.internal.testNetworkParameters
import net.corda.testing.contracts.DummyContract import net.corda.testing.contracts.DummyContract
import net.corda.testing.core.chooseIdentity
import net.corda.testing.core.dummyCommand import net.corda.testing.core.dummyCommand
import net.corda.testing.core.singleIdentity
import net.corda.testing.internal.IntegrationTest import net.corda.testing.internal.IntegrationTest
import net.corda.testing.internal.IntegrationTestSchemas 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.MockServices.Companion.makeTestDataSourceProperties
import net.corda.testing.node.inMemoryH2DataSourceConfig import net.corda.testing.node.inMemoryH2DataSourceConfig
import net.corda.testing.node.internal.InternalMockNetwork 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.After
import org.junit.Before import org.junit.Before
import org.junit.ClassRule import org.junit.ClassRule
@ -77,22 +77,22 @@ class MySQLNotaryServiceTests : IntegrationTest() {
val firstTxBuilder = TransactionBuilder(notaryParty) val firstTxBuilder = TransactionBuilder(notaryParty)
.addInputState(inputState) .addInputState(inputState)
.addCommand(dummyCommand(node.services.myInfo.chooseIdentity().owningKey)) .addCommand(dummyCommand(node.services.myInfo.singleIdentity().owningKey))
val firstSpendTx = node.services.signInitialTransaction(firstTxBuilder) 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() mockNet.runNetwork()
firstSpend.getOrThrow() firstSpend.getOrThrow()
val secondSpendBuilder = TransactionBuilder(notaryParty).withItems(inputState).run { 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) addOutputState(dummyState, DummyContract.PROGRAM_ID)
addCommand(dummyCommand(node.services.myInfo.chooseIdentity().owningKey)) addCommand(dummyCommand(node.services.myInfo.singleIdentity().owningKey))
this this
} }
val secondSpendTx = node.services.signInitialTransaction(secondSpendBuilder) 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() mockNet.runNetwork()
@ -107,14 +107,14 @@ class MySQLNotaryServiceTests : IntegrationTest() {
val txBuilder = TransactionBuilder(notaryParty) val txBuilder = TransactionBuilder(notaryParty)
.addInputState(inputState) .addInputState(inputState)
.addCommand(dummyCommand(node.services.myInfo.chooseIdentity().owningKey)) .addCommand(dummyCommand(node.services.myInfo.singleIdentity().owningKey))
val spendTx = node.services.signInitialTransaction(txBuilder) 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() mockNet.runNetwork()
val signature = notarise.get().single() val signature = notarise.get().single()
val notariseRetry = node.services.startFlow(NotaryFlow.Client(spendTx)) val notariseRetry = node.services.startFlow(NotaryFlow.Client(spendTx)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
val signatureRetry = notariseRetry.get().single() val signatureRetry = notariseRetry.get().single()
@ -132,7 +132,7 @@ class MySQLNotaryServiceTests : IntegrationTest() {
setProperty("autoCommit", "false") setProperty("autoCommit", "false")
} }
return mockNet.createUnstartedNode( return mockNet.createUnstartedNode(
MockNodeParameters( InternalMockNodeParameters(
legalName = notaryName, legalName = notaryName,
entropyRoot = BigInteger.valueOf(60L), entropyRoot = BigInteger.valueOf(60L),
configOverrides = { configOverrides = {
@ -145,7 +145,7 @@ class MySQLNotaryServiceTests : IntegrationTest() {
private fun issueState(node: StartedNode<InternalMockNetwork.MockNode>, notary: Party): StateAndRef<*> { private fun issueState(node: StartedNode<InternalMockNetwork.MockNode>, notary: Party): StateAndRef<*> {
return node.database.transaction { 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) val stx = node.services.signInitialTransaction(builder)
node.services.recordTransactions(stx) node.services.recordTransactions(stx)
StateAndRef(builder.outputStates().first(), StateRef(stx.id, 0)) StateAndRef(builder.outputStates().first(), StateRef(stx.id, 0))

View File

@ -22,18 +22,12 @@ import net.corda.node.services.Permissions.Companion.invokeRpc
import net.corda.node.services.Permissions.Companion.startFlow import net.corda.node.services.Permissions.Companion.startFlow
import net.corda.testing.core.* import net.corda.testing.core.*
import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.DriverParameters
import net.corda.testing.driver.PortAllocation
import net.corda.testing.driver.driver import net.corda.testing.driver.driver
import net.corda.testing.driver.internal.RandomFree
import net.corda.testing.internal.IntegrationTest import net.corda.testing.internal.IntegrationTest
import net.corda.testing.internal.IntegrationTestSchemas import net.corda.testing.internal.IntegrationTestSchemas
import net.corda.testing.internal.toDatabaseSchemaName import net.corda.testing.internal.toDatabaseSchemaName
import net.corda.testing.node.User 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.Assume.assumeFalse
import org.junit.ClassRule import org.junit.ClassRule
import org.junit.Test import org.junit.Test

View File

@ -20,6 +20,7 @@ import net.corda.testing.core.*
import net.corda.testing.dsl.EnforceVerifyOrFail import net.corda.testing.dsl.EnforceVerifyOrFail
import net.corda.testing.dsl.TransactionDSL import net.corda.testing.dsl.TransactionDSL
import net.corda.testing.dsl.TransactionDSLInterpreter import net.corda.testing.dsl.TransactionDSLInterpreter
import net.corda.testing.internal.TEST_TX_TIME
import net.corda.testing.internal.rigorousMock import net.corda.testing.internal.rigorousMock
import net.corda.testing.node.MockServices import net.corda.testing.node.MockServices
import net.corda.testing.node.ledger import net.corda.testing.node.ledger

View File

@ -10,7 +10,6 @@ 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.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
@ -33,10 +32,10 @@ class CashSelectionH2Test {
// spend operation below. // spend operation below.
// Issuing Integer.MAX_VALUE will not cause an exception since PersistentCashState.pennies is a long // Issuing Integer.MAX_VALUE will not cause an exception since PersistentCashState.pennies is a long
nCopies(2, Integer.MAX_VALUE).map { issueAmount -> 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() }.transpose().getOrThrow()
// The spend must be more than the size of a single cash state to force the accumulator onto the second state. // 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 @Test
@ -48,9 +47,9 @@ class CashSelectionH2Test {
val notary = mockNet.defaultNotaryIdentity 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. // 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 flow1 = bankA.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary))
val flow2 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary)) val flow2 = bankA.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notary))
val flow3 = bankA.services.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 { flow1.getOrThrow() }.isInstanceOf(CashException::class.java)
assertThatThrownBy { flow2.getOrThrow() }.isInstanceOf(CashException::class.java) assertThatThrownBy { flow2.getOrThrow() }.isInstanceOf(CashException::class.java)

View File

@ -62,7 +62,7 @@ fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>,
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> {
val myKey = ownedBy?.owningKey ?: myInfo.chooseIdentity().owningKey val myKey = ownedBy?.owningKey ?: myInfo.singleIdentity().owningKey
val anonParty = AnonymousParty(myKey) val anonParty = AnonymousParty(myKey)
// We will allocate one state to one transaction, for simplicities sake. // We will allocate one state to one transaction, for simplicities sake.

View File

@ -10,7 +10,6 @@ import net.corda.testing.core.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.StartedMockNode import net.corda.testing.node.StartedMockNode
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
@ -32,7 +31,7 @@ class CashExitFlowTests {
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
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(initialBalance, ref, notary)) val future = bankOfCordaNode.startFlow(CashIssueFlow(initialBalance, ref, notary))
mockNet.runNetwork() mockNet.runNetwork()
future.getOrThrow() future.getOrThrow()
} }
@ -45,7 +44,7 @@ class CashExitFlowTests {
@Test @Test
fun `exit some cash`() { fun `exit some cash`() {
val exitAmount = 500.DOLLARS val exitAmount = 500.DOLLARS
val future = bankOfCordaNode.services.startFlow(CashExitFlow(exitAmount, ref)) val future = bankOfCordaNode.startFlow(CashExitFlow(exitAmount, ref))
mockNet.runNetwork() mockNet.runNetwork()
val exitTx = future.getOrThrow().stx.tx val exitTx = future.getOrThrow().stx.tx
val expected = (initialBalance - exitAmount).`issued by`(bankOfCorda.ref(ref)) val expected = (initialBalance - exitAmount).`issued by`(bankOfCorda.ref(ref))
@ -58,7 +57,7 @@ class CashExitFlowTests {
@Test @Test
fun `exit zero cash`() { fun `exit zero cash`() {
val expected = 0.DOLLARS val expected = 0.DOLLARS
val future = bankOfCordaNode.services.startFlow(CashExitFlow(expected, ref)) val future = bankOfCordaNode.startFlow(CashExitFlow(expected, ref))
mockNet.runNetwork() mockNet.runNetwork()
assertFailsWith<CashException> { assertFailsWith<CashException> {
future.getOrThrow() future.getOrThrow()

View File

@ -13,7 +13,7 @@ import net.corda.node.internal.StartedNode
import net.corda.testing.core.* import net.corda.testing.core.*
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
import net.corda.testing.node.internal.InternalMockNetwork 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.After
import org.junit.Before import org.junit.Before
import org.junit.Test 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")) cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset", "com.r3.corda.enterprise.perftestcordapp.schemas"))
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.singleIdentity()
mockNet.runNetwork() mockNet.runNetwork()
notary = mockNet.defaultNotaryIdentity notary = mockNet.defaultNotaryIdentity
} }
@ -45,7 +45,7 @@ class CashIssueAndPaymentFlowTests {
@Test @Test
fun `issue and pay some cash`() { fun `issue and pay some cash`() {
val payTo = aliceNode.info.chooseIdentity() val payTo = aliceNode.info.singleIdentity()
val expectedPayment = 500.DOLLARS val expectedPayment = 500.DOLLARS
bankOfCordaNode.database.transaction { bankOfCordaNode.database.transaction {
@ -54,7 +54,7 @@ class CashIssueAndPaymentFlowTests {
val (_, vaultUpdatesBoc) = bankOfCordaNode.services.vaultService.trackBy<Cash.State>(criteria) val (_, vaultUpdatesBoc) = bankOfCordaNode.services.vaultService.trackBy<Cash.State>(criteria)
val (_, vaultUpdatesBankClient) = aliceNode.services.vaultService.trackBy<Cash.State>(criteria) val (_, vaultUpdatesBankClient) = aliceNode.services.vaultService.trackBy<Cash.State>(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() mockNet.runNetwork()
future.getOrThrow() future.getOrThrow()

View File

@ -15,7 +15,7 @@ import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStra
import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork
import net.corda.testing.node.StartedMockNode import net.corda.testing.node.StartedMockNode
import net.corda.testing.node.internal.InternalMockNetwork 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.After
import org.junit.Before import org.junit.Before
import org.junit.Test 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")) cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset", "com.r3.corda.enterprise.perftestcordapp.schemas"))
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.singleIdentity()
mockNet.runNetwork() mockNet.runNetwork()
notary = mockNet.defaultNotaryIdentity notary = mockNet.defaultNotaryIdentity
} }
@ -56,7 +56,7 @@ class CashIssueAndPayNoSelectionTests(private val anonymous: Boolean) {
@Test @Test
fun `issue and pay some cash`() { fun `issue and pay some cash`() {
val payTo = aliceNode.info.chooseIdentity() val payTo = aliceNode.info.singleIdentity()
val expectedPayment = 500.DOLLARS val expectedPayment = 500.DOLLARS
bankOfCordaNode.database.transaction { bankOfCordaNode.database.transaction {
@ -68,7 +68,7 @@ class CashIssueAndPayNoSelectionTests(private val anonymous: Boolean) {
= aliceNode.services.vaultService.trackBy<Cash.State>(criteria) = aliceNode.services.vaultService.trackBy<Cash.State>(criteria)
val future = bankOfCordaNode.services.startFlow(CashIssueAndPaymentNoSelection( val future = bankOfCordaNode.services.startFlow(CashIssueAndPaymentNoSelection(
expectedPayment, OpaqueBytes.of(1), payTo, anonymous, notary)) expectedPayment, OpaqueBytes.of(1), payTo, anonymous, notary)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
future.getOrThrow() future.getOrThrow()

View File

@ -10,7 +10,6 @@ import net.corda.testing.core.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.StartedMockNode import net.corda.testing.node.StartedMockNode
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
@ -42,7 +41,7 @@ class CashIssueFlowTests {
fun `issue some cash`() { fun `issue some cash`() {
val expected = 500.DOLLARS val expected = 500.DOLLARS
val ref = OpaqueBytes.of(0x01) val ref = OpaqueBytes.of(0x01)
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary)) val future = bankOfCordaNode.startFlow(CashIssueFlow(expected, ref, notary))
mockNet.runNetwork() mockNet.runNetwork()
val issueTx = future.getOrThrow().stx val issueTx = future.getOrThrow().stx
val output = issueTx.tx.outputsOfType<Cash.State>().single() val output = issueTx.tx.outputsOfType<Cash.State>().single()
@ -53,7 +52,7 @@ class CashIssueFlowTests {
fun `issue zero cash`() { fun `issue zero cash`() {
val expected = 0.DOLLARS val expected = 0.DOLLARS
val ref = OpaqueBytes.of(0x01) val ref = OpaqueBytes.of(0x01)
val future = bankOfCordaNode.services.startFlow(CashIssueFlow(expected, ref, notary)) val future = bankOfCordaNode.startFlow(CashIssueFlow(expected, ref, notary))
mockNet.runNetwork() mockNet.runNetwork()
assertFailsWith<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
future.getOrThrow() future.getOrThrow()

View File

@ -13,7 +13,7 @@ import net.corda.node.internal.StartedNode
import net.corda.testing.core.* import net.corda.testing.core.*
import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin import net.corda.testing.node.InMemoryMessagingNetwork.ServicePeerAllocationStrategy.RoundRobin
import net.corda.testing.node.internal.InternalMockNetwork 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.After
import org.junit.Before import org.junit.Before
import org.junit.Test 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")) cordappPackages = listOf("com.r3.corda.enterprise.perftestcordapp.contracts.asset", "com.r3.corda.enterprise.perftestcordapp.schemas"))
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.singleIdentity()
mockNet.runNetwork() 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() future.getOrThrow()
} }
@ -48,7 +48,7 @@ class CashPaymentFlowTests {
@Test @Test
fun `pay some cash`() { fun `pay some cash`() {
val payTo = aliceNode.info.chooseIdentity() val payTo = aliceNode.info.singleIdentity()
val expectedPayment = 500.DOLLARS val expectedPayment = 500.DOLLARS
val expectedChange = 1500.DOLLARS val expectedChange = 1500.DOLLARS
@ -59,7 +59,7 @@ class CashPaymentFlowTests {
val (_, vaultUpdatesBankClient) = aliceNode.services.vaultService.trackBy<Cash.State>(criteria) val (_, vaultUpdatesBankClient) = aliceNode.services.vaultService.trackBy<Cash.State>(criteria)
val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expectedPayment, val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expectedPayment,
payTo)) payTo)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
future.getOrThrow() future.getOrThrow()
@ -88,10 +88,10 @@ class CashPaymentFlowTests {
@Test @Test
fun `pay more than we have`() { fun `pay more than we have`() {
val payTo = aliceNode.info.chooseIdentity() val payTo = aliceNode.info.singleIdentity()
val expected = 4000.DOLLARS val expected = 4000.DOLLARS
val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected, val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected,
payTo)) payTo)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
assertFailsWith<CashException> { assertFailsWith<CashException> {
future.getOrThrow() future.getOrThrow()
@ -100,10 +100,10 @@ class CashPaymentFlowTests {
@Test @Test
fun `pay zero cash`() { fun `pay zero cash`() {
val payTo = aliceNode.info.chooseIdentity() val payTo = aliceNode.info.singleIdentity()
val expected = 0.DOLLARS val expected = 0.DOLLARS
val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected, val future = bankOfCordaNode.services.startFlow(CashPaymentFlow(expected,
payTo)) payTo)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
assertFailsWith<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
future.getOrThrow() future.getOrThrow()

View File

@ -51,10 +51,13 @@ import net.corda.testing.dsl.LedgerDSL
import net.corda.testing.dsl.TestLedgerDSLInterpreter import net.corda.testing.dsl.TestLedgerDSLInterpreter
import net.corda.testing.dsl.TestTransactionDSLInterpreter import net.corda.testing.dsl.TestTransactionDSLInterpreter
import net.corda.testing.internal.LogHelper import net.corda.testing.internal.LogHelper
import net.corda.testing.internal.TEST_TX_TIME
import net.corda.testing.internal.rigorousMock import net.corda.testing.internal.rigorousMock
import net.corda.testing.node.* import net.corda.testing.node.*
import net.corda.testing.node.internal.InternalMockNetwork 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.pumpReceive
import net.corda.testing.node.internal.startFlow
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.After import org.junit.After
import org.junit.Before 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 // ... 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. // 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. // Find the future representing the result of this state machine again.
val bobFuture = bobNode.smm.findStateMachines(BuyerAcceptor::class.java).single().second val bobFuture = bobNode.smm.findStateMachines(BuyerAcceptor::class.java).single().second
@ -327,7 +330,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
private fun makeNodeWithTracking( private fun makeNodeWithTracking(
name: CordaX500Name): StartedNode<InternalMockNetwork.MockNode> { name: CordaX500Name): StartedNode<InternalMockNetwork.MockNode> {
// Create a node in the mock network ... // 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) { object : InternalMockNetwork.MockNode(args) {
// That constructs a recording tx storage // That constructs a recording tx storage
override fun makeTransactionStorage(database: CordaPersistence, transactionCacheSizeBytes: Long): WritableTransactionStorage { override fun makeTransactionStorage(database: CordaPersistence, transactionCacheSizeBytes: Long): WritableTransactionStorage {
@ -552,7 +555,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
val buyerFlows: Observable<out FlowLogic<*>> = buyerNode.registerInitiatedFlow(BuyerAcceptor::class.java) val buyerFlows: Observable<out FlowLogic<*>> = buyerNode.registerInitiatedFlow(BuyerAcceptor::class.java)
val firstBuyerFiber = buyerFlows.toFuture().map { it.stateMachine } val firstBuyerFiber = buyerFlows.toFuture().map { it.stateMachine }
val seller = SellerInitiator(buyer, notary, assetToSell, 1000.DOLLARS, anonymous) 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) return RunResult(firstBuyerFiber, sellerResult, seller.stateMachine.id)
} }

View File

@ -32,7 +32,7 @@ import net.corda.explorer.model.MembershipListModel
import net.corda.explorer.views.bigDecimalFormatter import net.corda.explorer.views.bigDecimalFormatter
import net.corda.explorer.views.stringConverter import net.corda.explorer.views.stringConverter
import net.corda.sample.businessnetwork.iou.IOUFlow 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 org.controlsfx.dialog.ExceptionDialog
import tornadofx.* import tornadofx.*
@ -60,7 +60,7 @@ class NewTransaction : Fragment() {
} }
partyBChoiceBox.apply { 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 -> newTransactionDialog(window).showAndWait().ifPresent { request ->