From aa01ef638b3a3788def6fcad185a913d25d21a6c Mon Sep 17 00:00:00 2001 From: Rick Parker Date: Thu, 7 Jun 2018 09:12:25 +0100 Subject: [PATCH] =?UTF-8?q?CORDA-1589=20Flow=20hospital=20reports=20incorr?= =?UTF-8?q?ect=20number=20of=20patients=20and=20fix=E2=80=A6=20(#3315)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * CORDA-1589 Flow hospital reports incorrect number of patients and fix flakey associated test. * Compare before and after count, not against zero. There's a leak in killFlow that will be easier to address in or after Shams PR. --- .../corda/node/services/statemachine/StaffedFlowHospital.kt | 2 +- .../corda/node/services/statemachine/RetryFlowMockTest.kt | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/StaffedFlowHospital.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/StaffedFlowHospital.kt index 3f66c15c4b..eb7806e9b8 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/StaffedFlowHospital.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/StaffedFlowHospital.kt @@ -17,7 +17,7 @@ object StaffedFlowHospital : FlowHospital { private val patients = ConcurrentHashMap() - val numberOfPatients = patients.size + val numberOfPatients get() = patients.size class MedicalHistory { val records: MutableList = mutableListOf() diff --git a/node/src/test/kotlin/net/corda/node/services/statemachine/RetryFlowMockTest.kt b/node/src/test/kotlin/net/corda/node/services/statemachine/RetryFlowMockTest.kt index 710e545540..dbcd28796a 100644 --- a/node/src/test/kotlin/net/corda/node/services/statemachine/RetryFlowMockTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/statemachine/RetryFlowMockTest.kt @@ -89,8 +89,11 @@ class RetryFlowMockTest { @Test fun `Patient records do not leak in hospital`() { + val patientCountBefore = StaffedFlowHospital.numberOfPatients assertEquals(Unit, internalNodeA.startFlow(RetryFlow(1)).get()) - assertEquals(0, StaffedFlowHospital.numberOfPatients) + // Need to make sure the state machine has finished. Otherwise this test is flakey. + mockNet.waitQuiescent() + assertEquals(patientCountBefore, StaffedFlowHospital.numberOfPatients) assertEquals(2, RetryFlow.count) } }