From fcd365bdecfa9ef4c4957c6bd9454ec3f2810e57 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Mon, 31 Aug 2020 10:22:20 +1000 Subject: [PATCH] made findPrivacyGroup calls async (#1346) Signed-off-by: Sally MacFarlane --- enclave/build.gradle | 1 + .../hyperledger/besu/enclave/EnclaveTest.java | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/enclave/build.gradle b/enclave/build.gradle index dc35c3033..35e5df097 100644 --- a/enclave/build.gradle +++ b/enclave/build.gradle @@ -19,6 +19,7 @@ dependencies { // integration test dependencies. integrationTestImplementation project(':testutil') integrationTestImplementation 'org.bouncycastle:bcpkix-jdk15on' + integrationTestImplementation 'org.awaitility:awaitility' diff --git a/enclave/src/integration-test/java/org/hyperledger/besu/enclave/EnclaveTest.java b/enclave/src/integration-test/java/org/hyperledger/besu/enclave/EnclaveTest.java index 4023d8cbb..26c61c55e 100644 --- a/enclave/src/integration-test/java/org/hyperledger/besu/enclave/EnclaveTest.java +++ b/enclave/src/integration-test/java/org/hyperledger/besu/enclave/EnclaveTest.java @@ -28,9 +28,11 @@ import org.hyperledger.orion.testutil.OrionTestHarnessFactory; import java.net.URI; import java.net.URISyntaxException; import java.util.List; +import java.util.concurrent.TimeUnit; import com.google.common.collect.Lists; import io.vertx.core.Vertx; +import org.awaitility.Awaitility; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; @@ -148,20 +150,30 @@ public class EnclaveTest { assertThat(privacyGroupResponse.getDescription()).isEqualTo(description); assertThat(privacyGroupResponse.getType()).isEqualTo(PrivacyGroup.Type.PANTHEON); - PrivacyGroup[] findPrivacyGroupResponse = enclave.findPrivacyGroup(publicKeys); + Awaitility.await() + .atMost(5, TimeUnit.SECONDS) + .untilAsserted( + () -> { + final PrivacyGroup[] findPrivacyGroupResponse = enclave.findPrivacyGroup(publicKeys); - assertThat(findPrivacyGroupResponse.length).isEqualTo(1); - assertThat(findPrivacyGroupResponse[0].getPrivacyGroupId()) - .isEqualTo(privacyGroupResponse.getPrivacyGroupId()); + assertThat(findPrivacyGroupResponse.length).isEqualTo(1); + assertThat(findPrivacyGroupResponse[0].getPrivacyGroupId()) + .isEqualTo(privacyGroupResponse.getPrivacyGroupId()); + }); final String response = enclave.deletePrivacyGroup(privacyGroupResponse.getPrivacyGroupId(), publicKeys.get(0)); assertThat(privacyGroupResponse.getPrivacyGroupId()).isEqualTo(response); - findPrivacyGroupResponse = enclave.findPrivacyGroup(publicKeys); + Awaitility.await() + .atMost(5, TimeUnit.SECONDS) + .untilAsserted( + () -> { + final PrivacyGroup[] findPrivacyGroupResponse = enclave.findPrivacyGroup(publicKeys); - assertThat(findPrivacyGroupResponse.length).isEqualTo(0); + assertThat(findPrivacyGroupResponse.length).isEqualTo(0); + }); } @Test