From e6e3c29d748382bf8dcd8246ef806eea8b285d6f Mon Sep 17 00:00:00 2001 From: Clinton Date: Tue, 3 Oct 2017 14:31:36 +0100 Subject: [PATCH] Fixed a few instances of waitUntilNetworkReady() to fix flaky tests. (#1785) --- .../net/corda/node/services/AttachmentLoadingTests.kt | 2 +- .../kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt | 4 ++-- .../main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt | 2 +- .../main/kotlin/net/corda/explorer/ExplorerSimulation.kt | 7 +++---- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt index ecbe731158..27c9a3d08a 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/AttachmentLoadingTests.kt @@ -129,7 +129,7 @@ class AttachmentLoadingTests : TestDependencyInjectionBase() { startNode(providedName = bankBName, rpcUsers = listOf(adminUser)), startNode(providedName = notaryName, rpcUsers = listOf(adminUser), advertisedServices = setOf(ServiceInfo(SimpleNotaryService.type))) ).transpose().getOrThrow() // Wait for all nodes to start up. - nodes.forEach { it.rpc.waitUntilNetworkReady() } + nodes.forEach { it.rpc.waitUntilNetworkReady().getOrThrow() } return nodes } } 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 33a36ec75f..157b2c0fd6 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 @@ -33,8 +33,8 @@ class BankOfCordaRPCClientTest { // Big Corporation RPC Client val bigCorpClient = nodeBigCorporation.rpcClientToNode() val bigCorpProxy = bigCorpClient.start("bigCorpCFO", "password2").proxy - bocProxy.waitUntilNetworkReady() - bigCorpProxy.waitUntilNetworkReady() + bocProxy.waitUntilNetworkReady().getOrThrow() + bigCorpProxy.waitUntilNetworkReady().getOrThrow() // Register for Bank of Corda Vault updates val criteria = QueryCriteria.VaultQueryCriteria(status = Vault.StateStatus.ALL) diff --git a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt index 455c090973..a50e99b727 100644 --- a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt +++ b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt @@ -36,7 +36,7 @@ class BankOfCordaClientApi(val hostAndPort: NetworkHostAndPort) { // TODO: privileged security controls required client.start("bankUser", "test").use { connection -> val rpc = connection.proxy - rpc.waitUntilNetworkReady() + rpc.waitUntilNetworkReady().getOrThrow() // Resolve parties via RPC val issueToParty = rpc.wellKnownPartyFromX500Name(params.issueToPartyName) diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt index 11026a819c..706d5e3649 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/ExplorerSimulation.kt @@ -132,10 +132,9 @@ class ExplorerSimulation(val options: OptionSet) { issuerNodeGBP.nodeInfo.legalIdentities.first() to issuerRPCGBP, issuerNodeUSD.nodeInfo.legalIdentities.first() to issuerRPCUSD)) - aliceRPC.waitUntilNetworkReady() - bobRPC.waitUntilNetworkReady() - issuerRPCGBP.waitUntilNetworkReady() - issuerRPCUSD.waitUntilNetworkReady() + listOf(aliceRPC, bobRPC, issuerRPCGBP, issuerRPCUSD).map { + it.waitUntilNetworkReady().getOrThrow() + } } private fun startSimulation(eventGenerator: EventGenerator, maxIterations: Int) {