diff --git a/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt b/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt index 34ce666450..347cb75c78 100644 --- a/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt +++ b/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt @@ -1,17 +1,16 @@ package net.corda.attachmentdemo import net.corda.core.node.services.ServiceInfo -import net.corda.core.internal.concurrent.transpose import net.corda.core.utilities.getOrThrow +import net.corda.node.services.FlowPermissions.Companion.startFlowPermission +import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import net.corda.testing.DUMMY_BANK_A import net.corda.testing.DUMMY_BANK_B import net.corda.testing.DUMMY_NOTARY import net.corda.testing.driver.driver -import net.corda.node.services.FlowPermissions.Companion.startFlowPermission -import net.corda.node.services.transactions.SimpleNotaryService -import net.corda.nodeapi.User import org.junit.Test -import java.util.concurrent.CompletableFuture +import java.util.concurrent.CompletableFuture.supplyAsync class AttachmentDemoTest { // run with a 10,000,000 bytes in-memory zip file. In practice, a slightly bigger file will be used (~10,002,000 bytes). @@ -19,19 +18,18 @@ class AttachmentDemoTest { val numOfExpectedBytes = 10_000_000 driver(dsl = { val demoUser = listOf(User("demo", "demo", setOf(startFlowPermission()))) - val (nodeA, nodeB) = listOf( - startNode(providedName = DUMMY_BANK_A.name, rpcUsers = demoUser), - startNode(providedName = DUMMY_BANK_B.name, rpcUsers = demoUser), - startNode(providedName = DUMMY_NOTARY.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))) - ).transpose().getOrThrow() + val notaryFuture = startNode(providedName = DUMMY_NOTARY.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))) + val nodeAFuture = startNode(providedName = DUMMY_BANK_A.name, rpcUsers = demoUser) + val nodeBFuture = startNode(providedName = DUMMY_BANK_B.name, rpcUsers = demoUser) + val (nodeA, nodeB) = listOf(nodeAFuture, nodeBFuture, notaryFuture).map { it.getOrThrow() } - val senderThread = CompletableFuture.supplyAsync { + val senderThread = supplyAsync { nodeA.rpcClientToNode().start(demoUser[0].username, demoUser[0].password).use { sender(it.proxy, numOfExpectedBytes) } }.exceptionally { it.printStackTrace() } - val recipientThread = CompletableFuture.supplyAsync { + val recipientThread = supplyAsync { nodeB.rpcClientToNode().start(demoUser[0].username, demoUser[0].password).use { recipient(it.proxy) } diff --git a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt index 394ed0bf7f..716587966d 100644 --- a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt +++ b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt @@ -3,11 +3,10 @@ package net.corda.bank import net.corda.bank.api.BankOfCordaClientApi import net.corda.bank.api.BankOfCordaWebApi.IssueRequestParams import net.corda.core.node.services.ServiceInfo -import net.corda.core.internal.concurrent.transpose import net.corda.core.utilities.getOrThrow -import net.corda.testing.driver.driver import net.corda.node.services.transactions.SimpleNotaryService import net.corda.testing.BOC +import net.corda.testing.driver.driver import org.junit.Test import kotlin.test.assertTrue @@ -15,10 +14,9 @@ class BankOfCordaHttpAPITest { @Test fun `issuer flow via Http`() { driver(dsl = { - val (nodeBankOfCorda) = listOf( - startNode(providedName = BOC.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))), - startNode(providedName = BIGCORP_LEGAL_NAME) - ).transpose().getOrThrow() + val bigCorpNodeFuture = startNode(providedName = BIGCORP_LEGAL_NAME) + val nodeBankOfCordaFuture = startNode(providedName = BOC.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))) + val (nodeBankOfCorda) = listOf(nodeBankOfCordaFuture, bigCorpNodeFuture).map { it.getOrThrow() } val anonymous = false val nodeBankOfCordaApiAddr = startWebserver(nodeBankOfCorda).getOrThrow().listenAddress assertTrue(BankOfCordaClientApi(nodeBankOfCordaApiAddr).requestWebIssue(IssueRequestParams(1000, "USD", BIGCORP_LEGAL_NAME, "1", BOC.name, BOC.name, anonymous))) diff --git a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt index 31481cf3d4..4a4bfadacb 100644 --- a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt +++ b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt @@ -1,6 +1,5 @@ package net.corda.bank -import net.corda.core.internal.concurrent.transpose import net.corda.core.messaging.startFlow import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.Vault @@ -23,12 +22,9 @@ class BankOfCordaRPCClientTest { val bocManager = User("bocManager", "password1", permissions = setOf( startFlowPermission())) val bigCorpCFO = User("bigCorpCFO", "password2", permissions = emptySet()) - val (nodeBankOfCorda, nodeBigCorporation) = listOf( - startNode(providedName = BOC.name, - advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type)), - rpcUsers = listOf(bocManager)), - startNode(providedName = BIGCORP_LEGAL_NAME, rpcUsers = listOf(bigCorpCFO)) - ).transpose().getOrThrow() + val nodeBankOfCordaFuture = startNode(providedName = BOC.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type)), rpcUsers = listOf(bocManager)) + val nodeBigCorporationFuture = startNode(providedName = BIGCORP_LEGAL_NAME, rpcUsers = listOf(bigCorpCFO)) + val (nodeBankOfCorda, nodeBigCorporation) = listOf(nodeBankOfCordaFuture, nodeBigCorporationFuture).map { it.getOrThrow() } // Bank of Corda RPC Client val bocClient = nodeBankOfCorda.rpcClientToNode() diff --git a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt index fbea2e1a83..a523e5f273 100644 --- a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt +++ b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt @@ -1,7 +1,6 @@ package net.corda.irs import net.corda.client.rpc.CordaRPCClient -import net.corda.core.internal.concurrent.transpose import net.corda.core.messaging.vaultTrackBy import net.corda.core.node.services.ServiceInfo import net.corda.core.toFuture @@ -44,19 +43,20 @@ class IRSDemoTest : IntegrationTestCategory { @Test fun `runs IRS demo`() { driver(useTestClock = true, isDebug = true) { - val (controller, nodeA, nodeB) = listOf( - startNode(providedName = DUMMY_NOTARY.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type), ServiceInfo(NodeInterestRates.Oracle.type))), - startNode(providedName = DUMMY_BANK_A.name, rpcUsers = listOf(rpcUser)), - startNode(providedName = DUMMY_BANK_B.name) - ).transpose().getOrThrow() + val controllerFuture = startNode( + providedName = DUMMY_NOTARY.name, + advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type), ServiceInfo(NodeInterestRates.Oracle.type))) + val nodeAFuture = startNode(providedName = DUMMY_BANK_A.name, rpcUsers = listOf(rpcUser)) + val nodeBFuture = startNode(providedName = DUMMY_BANK_B.name) + val (controller, nodeA, nodeB) = listOf(controllerFuture, nodeAFuture, nodeBFuture).map { it.getOrThrow() } log.info("All nodes started") - val (controllerAddr, nodeAAddr, nodeBAddr) = listOf( - startWebserver(controller), - startWebserver(nodeA), - startWebserver(nodeB) - ).transpose().getOrThrow().map { it.listenAddress } + val controllerAddrFuture = startWebserver(controller) + val nodeAAddrFuture = startWebserver(nodeA) + val nodeBAddrFuture = startWebserver(nodeB) + val (controllerAddr, nodeAAddr, nodeBAddr) = + listOf(controllerAddrFuture, nodeAAddrFuture, nodeBAddrFuture).map { it.getOrThrow().listenAddress } log.info("All webservers started") diff --git a/samples/irs-demo/src/test/kotlin/net/corda/irs/Main.kt b/samples/irs-demo/src/test/kotlin/net/corda/irs/Main.kt index 4f9117ed44..4604da6b3e 100644 --- a/samples/irs-demo/src/test/kotlin/net/corda/irs/Main.kt +++ b/samples/irs-demo/src/test/kotlin/net/corda/irs/Main.kt @@ -1,6 +1,5 @@ package net.corda.irs -import net.corda.core.internal.concurrent.transpose import net.corda.core.node.services.ServiceInfo import net.corda.core.utilities.getOrThrow import net.corda.testing.DUMMY_BANK_A @@ -16,11 +15,12 @@ import net.corda.testing.driver.driver */ fun main(args: Array) { driver(dsl = { - val (controller, nodeA, nodeB) = listOf( - startNode(providedName = DUMMY_NOTARY.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type), ServiceInfo(NodeInterestRates.Oracle.type))), - startNode(providedName = DUMMY_BANK_A.name), - startNode(providedName = DUMMY_BANK_B.name) - ).transpose().getOrThrow() + val controllerFuture = startNode( + providedName = DUMMY_NOTARY.name, + advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type), ServiceInfo(NodeInterestRates.Oracle.type))) + val nodeAFuture = startNode(providedName = DUMMY_BANK_A.name) + val nodeBFuture = startNode(providedName = DUMMY_BANK_B.name) + val (controller, nodeA, nodeB) = listOf(controllerFuture, nodeAFuture, nodeBFuture).map { it.getOrThrow() } startWebserver(controller) startWebserver(nodeA) diff --git a/samples/network-visualiser/src/main/kotlin/net/corda/netmap/NetworkMapVisualiser.kt b/samples/network-visualiser/src/main/kotlin/net/corda/netmap/NetworkMapVisualiser.kt index 9836dd1a09..12f783851c 100644 --- a/samples/network-visualiser/src/main/kotlin/net/corda/netmap/NetworkMapVisualiser.kt +++ b/samples/network-visualiser/src/main/kotlin/net/corda/netmap/NetworkMapVisualiser.kt @@ -171,7 +171,7 @@ class NetworkMapVisualiser : Application() { onNextInvoked() } } - viewModel.simulation.networkInitialisationFinished.then { + viewModel.simulation.networkInitialisationFinished.thenAccept { view.simulateInitialisationCheckbox.isVisible = false } view.runPauseButton.setOnAction { diff --git a/samples/network-visualiser/src/main/kotlin/net/corda/netmap/simulation/IRSSimulation.kt b/samples/network-visualiser/src/main/kotlin/net/corda/netmap/simulation/IRSSimulation.kt index 1e2a624d02..a09fa66682 100644 --- a/samples/network-visualiser/src/main/kotlin/net/corda/netmap/simulation/IRSSimulation.kt +++ b/samples/network-visualiser/src/main/kotlin/net/corda/netmap/simulation/IRSSimulation.kt @@ -3,14 +3,12 @@ package net.corda.netmap.simulation import co.paralleluniverse.fibers.Suspendable import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.readValue -import net.corda.core.concurrent.CordaFuture import net.corda.core.contracts.StateAndRef import net.corda.core.flows.FlowLogic import net.corda.core.flows.InitiatedBy import net.corda.core.flows.InitiatingFlow import net.corda.core.identity.Party import net.corda.core.internal.FlowStateMachine -import net.corda.core.internal.concurrent.* import net.corda.core.node.services.queryBy import net.corda.core.toFuture import net.corda.core.transactions.SignedTransaction @@ -28,6 +26,8 @@ import rx.Observable import java.security.PublicKey import java.time.LocalDate import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.CompletableFuture.allOf /** @@ -42,46 +42,58 @@ class IRSSimulation(networkSendManuallyPumped: Boolean, runAsync: Boolean, laten private val executeOnNextIteration = Collections.synchronizedList(LinkedList<() -> Unit>()) - override fun startMainSimulation(): CordaFuture { + override fun startMainSimulation(): CompletableFuture { // TODO: Determine why this isn't happening via the network map mockNet.nodes.map { it.services.identityService }.forEach { service -> - mockNet.nodes.forEach { node -> service.registerIdentity(node.info.legalIdentityAndCert) } + mockNet.nodes.forEach { node -> service.verifyAndRegisterIdentity(node.info.legalIdentityAndCert) } } - val future = openFuture() om = JacksonSupport.createInMemoryMapper(InMemoryIdentityService((banks + regulators + networkMap).map { it.info.legalIdentityAndCert }, trustRoot = DUMMY_CA.certificate)) registerFinanceJSONMappers(om) - startIRSDealBetween(0, 1).thenMatch({ + return startIRSDealBetween(0, 1).thenCompose { + val future = CompletableFuture() // Next iteration is a pause. executeOnNextIteration.add {} executeOnNextIteration.add { // Keep fixing until there's no more left to do. val initialFixFuture = doNextFixing(0, 1) fun onFailure(t: Throwable) { - future.setException(t) // Propagate the error. + future.completeExceptionally(t) } - fun onSuccess(result: Unit?) { + fun onSuccess() { // Pause for an iteration. executeOnNextIteration.add {} executeOnNextIteration.add { val f = doNextFixing(0, 1) if (f != null) { - f.thenMatch(::onSuccess, ::onFailure) + f.handle { _, throwable -> + if (throwable == null) { + onSuccess() + } else { + onFailure(throwable) + } + } } else { // All done! - future.set(Unit) + future.complete(Unit) } } } - initialFixFuture!!.thenMatch(::onSuccess, ::onFailure) + initialFixFuture!!.handle { _, throwable -> + if (throwable == null) { + onSuccess() + } else { + onFailure(throwable) + } + } } - }, {}) - return future + future + } } - private fun doNextFixing(i: Int, j: Int): CordaFuture? { + private fun doNextFixing(i: Int, j: Int): CompletableFuture? { println("Doing a fixing between $i and $j") val node1: SimulatedNode = banks[i] val node2: SimulatedNode = banks[j] @@ -107,10 +119,10 @@ class IRSSimulation(networkSendManuallyPumped: Boolean, runAsync: Boolean, laten if (nextFixingDate > currentDateAndTime.toLocalDate()) currentDateAndTime = nextFixingDate.atTime(15, 0) - return listOf(futA, futB).transpose().map { Unit } + return allOf(futA.toCompletableFuture(), futB.toCompletableFuture()) } - private fun startIRSDealBetween(i: Int, j: Int): CordaFuture { + private fun startIRSDealBetween(i: Int, j: Int): CompletableFuture { val node1: SimulatedNode = banks[i] val node2: SimulatedNode = banks[j] @@ -141,8 +153,8 @@ class IRSSimulation(networkSendManuallyPumped: Boolean, runAsync: Boolean, laten val acceptDealFlows: Observable = node2.registerInitiatedFlow(AcceptDealFlow::class.java) @Suppress("UNCHECKED_CAST") - val acceptorTxFuture = acceptDealFlows.toFuture().flatMap { - (it.stateMachine as FlowStateMachine).resultFuture + val acceptorTxFuture = acceptDealFlows.toFuture().toCompletableFuture().thenCompose { + (it.stateMachine as FlowStateMachine).resultFuture.toCompletableFuture() } showProgressFor(listOf(node1, node2)) @@ -154,7 +166,7 @@ class IRSSimulation(networkSendManuallyPumped: Boolean, runAsync: Boolean, laten node1.services.legalIdentityKey) val instigatorTxFuture = node1.services.startFlow(instigator).resultFuture - return listOf(instigatorTxFuture, acceptorTxFuture).transpose().flatMap { instigatorTxFuture } + return allOf(instigatorTxFuture.toCompletableFuture(), acceptorTxFuture).thenCompose { instigatorTxFuture.toCompletableFuture() } } override fun iterate(): InMemoryMessagingNetwork.MessageTransfer? { diff --git a/samples/network-visualiser/src/main/kotlin/net/corda/netmap/simulation/Simulation.kt b/samples/network-visualiser/src/main/kotlin/net/corda/netmap/simulation/Simulation.kt index e5e635dc93..9a8bae5d4d 100644 --- a/samples/network-visualiser/src/main/kotlin/net/corda/netmap/simulation/Simulation.kt +++ b/samples/network-visualiser/src/main/kotlin/net/corda/netmap/simulation/Simulation.kt @@ -1,6 +1,5 @@ package net.corda.netmap.simulation -import net.corda.core.concurrent.CordaFuture import net.corda.core.utilities.locationOrNull import net.corda.core.flows.FlowLogic import net.corda.core.messaging.SingleMessageRecipient @@ -8,9 +7,6 @@ import net.corda.core.node.CityDatabase import net.corda.core.node.WorldMapLocation import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.containsType -import net.corda.core.internal.concurrent.doneFuture -import net.corda.core.internal.concurrent.flatMap -import net.corda.core.internal.concurrent.transpose import net.corda.testing.DUMMY_MAP import net.corda.testing.DUMMY_NOTARY import net.corda.testing.DUMMY_REGULATOR @@ -34,6 +30,9 @@ import java.time.LocalDate import java.time.LocalDateTime import java.time.ZoneOffset import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.CompletableFuture.allOf +import java.util.concurrent.Future /** * Base class for network simulations that are based on the unit test / mock environment. @@ -261,21 +260,19 @@ abstract class Simulation(val networkSendManuallyPumped: Boolean, } } - val networkInitialisationFinished = mockNet.nodes.map { it.nodeReadyFuture }.transpose() + val networkInitialisationFinished = allOf(*mockNet.nodes.map { it.nodeReadyFuture.toCompletableFuture() }.toTypedArray()) - fun start(): CordaFuture { + fun start(): Future { mockNet.startNodes() // Wait for all the nodes to have finished registering with the network map service. - return networkInitialisationFinished.flatMap { startMainSimulation() } + return networkInitialisationFinished.thenCompose { startMainSimulation() } } /** * Sub-classes should override this to trigger whatever they want to simulate. This method will be invoked once the * network bringup has been simulated. */ - protected open fun startMainSimulation(): CordaFuture { - return doneFuture(Unit) - } + protected abstract fun startMainSimulation(): CompletableFuture fun stop() { mockNet.stopNodes() diff --git a/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/Notarise.kt b/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/Notarise.kt index d648ce6d71..cd8485ce57 100644 --- a/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/Notarise.kt +++ b/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/Notarise.kt @@ -1,19 +1,16 @@ package net.corda.notarydemo import net.corda.client.rpc.CordaRPCClient -import net.corda.client.rpc.notUsed -import net.corda.core.concurrent.CordaFuture import net.corda.core.crypto.toStringShort import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.startFlow import net.corda.core.transactions.SignedTransaction -import net.corda.core.internal.concurrent.map -import net.corda.core.internal.concurrent.transpose import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.getOrThrow import net.corda.notarydemo.flows.DummyIssueAndMove import net.corda.notarydemo.flows.RPCStartableNotaryFlowClient import net.corda.testing.BOB +import java.util.concurrent.Future import kotlin.streams.asSequence fun main(args: Array) { @@ -53,9 +50,10 @@ private class NotaryDemoClientApi(val rpc: CordaRPCOps) { * as it consumes the original asset and creates a copy with the new owner as its output. */ private fun buildTransactions(count: Int): List { - return (1..count).map { + val flowFutures = (1..count).map { rpc.startFlow(::DummyIssueAndMove, notary, counterpartyNode.legalIdentity, it).returnValue - }.transpose().getOrThrow() + } + return flowFutures.map { it.getOrThrow() } } /** @@ -64,9 +62,9 @@ private class NotaryDemoClientApi(val rpc: CordaRPCOps) { * * @return a list of encoded signer public keys - one for every transaction */ - private fun notariseTransactions(transactions: List): List>> { + private fun notariseTransactions(transactions: List): List>> { return transactions.map { - rpc.startFlow(::RPCStartableNotaryFlowClient, it).returnValue.map { it.map { it.by.toStringShort() } } + rpc.startFlow(::RPCStartableNotaryFlowClient, it).returnValue.toCompletableFuture().thenApply { it.map { it.by.toStringShort() } } } } } diff --git a/samples/simm-valuation-demo/src/integration-test/kotlin/net/corda/vega/SimmValuationTest.kt b/samples/simm-valuation-demo/src/integration-test/kotlin/net/corda/vega/SimmValuationTest.kt index ed78ffd6aa..444e1aa7a8 100644 --- a/samples/simm-valuation-demo/src/integration-test/kotlin/net/corda/vega/SimmValuationTest.kt +++ b/samples/simm-valuation-demo/src/integration-test/kotlin/net/corda/vega/SimmValuationTest.kt @@ -2,7 +2,6 @@ package net.corda.vega import com.opengamma.strata.product.common.BuySell import net.corda.core.node.services.ServiceInfo -import net.corda.core.internal.concurrent.transpose import net.corda.core.utilities.getOrThrow import net.corda.testing.DUMMY_BANK_A import net.corda.testing.DUMMY_BANK_B @@ -34,10 +33,13 @@ class SimmValuationTest : IntegrationTestCategory { fun `runs SIMM valuation demo`() { driver(isDebug = true) { startNode(providedName = DUMMY_NOTARY.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))).getOrThrow() - val (nodeA, nodeB) = listOf(startNode(providedName = nodeALegalName), startNode(providedName = nodeBLegalName)).transpose().getOrThrow() - val (nodeAApi, nodeBApi) = listOf(startWebserver(nodeA), startWebserver(nodeB)).transpose() - .getOrThrow() - .map { HttpApi.fromHostAndPort(it.listenAddress, "api/simmvaluationdemo") } + val nodeAFuture = startNode(providedName = nodeALegalName) + val nodeBFuture = startNode(providedName = nodeBLegalName) + val (nodeA, nodeB) = listOf(nodeAFuture, nodeBFuture).map { it.getOrThrow() } + val nodeAWebServerFuture = startWebserver(nodeA) + val nodeBWebServerFuture = startWebserver(nodeB) + val nodeAApi = HttpApi.fromHostAndPort(nodeAWebServerFuture.getOrThrow().listenAddress, "api/simmvaluationdemo") + val nodeBApi = HttpApi.fromHostAndPort(nodeBWebServerFuture.getOrThrow().listenAddress, "api/simmvaluationdemo") val nodeBParty = getPartyWithName(nodeAApi, nodeBLegalName) val nodeAParty = getPartyWithName(nodeBApi, nodeALegalName) @@ -55,7 +57,7 @@ class SimmValuationTest : IntegrationTestCategory { } private fun getAvailablePartiesFor(partyApi: HttpApi): PortfolioApi.AvailableParties { - return partyApi.getJson("whoami") + return partyApi.getJson("whoami") } private fun createTradeBetween(partyApi: HttpApi, counterparty: PortfolioApi.ApiParty, tradeId: String): Boolean { diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/analytics/OGUtils.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/analytics/OGUtils.kt index ff48322f55..65c28f48d5 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/analytics/OGUtils.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/analytics/OGUtils.kt @@ -1,13 +1,7 @@ package net.corda.vega.analytics fun compareIMTriples(a: InitialMarginTriple, b: InitialMarginTriple): Boolean { - if (a.first is Double && a.second is Double && a.third is Double && - b.first is Double && b.second is Double && b.third is Double) { - if (withinTolerance(a.first, b.first) && withinTolerance(a.second, b.second) && withinTolerance(a.third, b.third)) { - return true - } - } - return false + return withinTolerance(a.first, b.first) && withinTolerance(a.second, b.second) && withinTolerance(a.third, b.third) } // TODO: Do this correctly diff --git a/samples/simm-valuation-demo/src/test/kotlin/net/corda/vega/Main.kt b/samples/simm-valuation-demo/src/test/kotlin/net/corda/vega/Main.kt index 81b13ae98c..c31048985d 100644 --- a/samples/simm-valuation-demo/src/test/kotlin/net/corda/vega/Main.kt +++ b/samples/simm-valuation-demo/src/test/kotlin/net/corda/vega/Main.kt @@ -1,6 +1,5 @@ package net.corda.vega -import net.corda.core.internal.concurrent.transpose import net.corda.core.node.services.ServiceInfo import net.corda.core.utilities.getOrThrow import net.corda.testing.DUMMY_BANK_A @@ -17,12 +16,11 @@ import net.corda.testing.driver.driver */ fun main(args: Array) { driver(dsl = { - startNode(providedName = DUMMY_NOTARY.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))) - val (nodeA, nodeB, nodeC) = listOf( - startNode(providedName = DUMMY_BANK_A.name), - startNode(providedName = DUMMY_BANK_B.name), - startNode(providedName = DUMMY_BANK_C.name) - ).transpose().getOrThrow() + val notaryFuture = startNode(providedName = DUMMY_NOTARY.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))) + val nodeAFuture = startNode(providedName = DUMMY_BANK_A.name) + val nodeBFuture = startNode(providedName = DUMMY_BANK_B.name) + val nodeCFuture = startNode(providedName = DUMMY_BANK_C.name) + val (nodeA, nodeB, nodeC) = listOf(nodeAFuture, nodeBFuture, nodeCFuture, notaryFuture).map { it.getOrThrow() } startWebserver(nodeA) startWebserver(nodeB) diff --git a/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt b/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt index 7db63b4f77..778554688b 100644 --- a/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt +++ b/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt @@ -1,7 +1,6 @@ package net.corda.traderdemo import net.corda.client.rpc.CordaRPCClient -import net.corda.core.internal.concurrent.transpose import net.corda.core.node.services.ServiceInfo import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.millis @@ -32,12 +31,11 @@ class TraderDemoTest : NodeBasedTest() { startFlowPermission(), startFlowPermission(), startFlowPermission())) - val (nodeA, nodeB, bankNode) = listOf( - startNode(DUMMY_BANK_A.name, rpcUsers = listOf(demoUser)), - startNode(DUMMY_BANK_B.name, rpcUsers = listOf(demoUser)), - startNode(BOC.name, rpcUsers = listOf(bankUser)), - startNode(DUMMY_NOTARY.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))) - ).transpose().getOrThrow() + val notaryFuture = startNode(DUMMY_NOTARY.name, advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))) + val nodeAFuture = startNode(DUMMY_BANK_A.name, rpcUsers = listOf(demoUser)) + val nodeBFuture = startNode(DUMMY_BANK_B.name, rpcUsers = listOf(demoUser)) + val bankNodeFuture = startNode(BOC.name, rpcUsers = listOf(bankUser)) + val (nodeA, nodeB, bankNode) = listOf(nodeAFuture, nodeBFuture, bankNodeFuture, notaryFuture).map { it.getOrThrow() } nodeA.registerInitiatedFlow(BuyerFlow::class.java)