diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/MirrorNodeClient.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/MirrorNodeClient.java index 7236acb587..1e536a5960 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/MirrorNodeClient.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/MirrorNodeClient.java @@ -125,6 +125,7 @@ public SubscriptionResponse subscribeToTopic(SDKClient sdkClient, TopicMessageQu // allow time for connection to be made and error to be caught await("responseEncountered") .atMost(Durations.ONE_MINUTE) + .pollInterval(Durations.ONE_SECOND) .pollDelay(Durations.ONE_HUNDRED_MILLISECONDS) .until(() -> subscriptionResponse.hasResponse()); diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/SDKClient.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/SDKClient.java index 1bcdda3cdd..b8db14277c 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/SDKClient.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/client/SDKClient.java @@ -17,6 +17,7 @@ package com.hedera.mirror.test.e2e.acceptance.client; import static com.hedera.mirror.test.e2e.acceptance.config.AcceptanceTestProperties.HederaNetwork.OTHER; +import static org.awaitility.Awaitility.await; import com.google.common.base.Stopwatch; import com.hedera.hashgraph.sdk.AccountBalanceQuery; @@ -49,6 +50,8 @@ import lombok.CustomLog; import lombok.Getter; import lombok.Value; +import org.apache.commons.lang3.StringUtils; +import org.awaitility.Durations; import org.springframework.util.CollectionUtils; @CustomLog @@ -56,6 +59,7 @@ @Value public class SDKClient implements Cleanable { + private static final String RESET_IP = "1.0.0.0"; private static final SecureRandom RANDOM = new SecureRandom(); private final Client client; @@ -152,7 +156,13 @@ private Client createClient() throws InterruptedException { if (acceptanceTestProperties.isRetrieveAddressBook()) { try { - return toClient(getAddressBook()); + log.info("Waiting for a valid address book"); + var addressBook = await("retrieveAddressBook") + .atMost(acceptanceTestProperties.getStartupTimeout()) + .pollDelay(Duration.ofMillis(100)) + .pollInterval(Durations.FIVE_SECONDS) + .until(this::getAddressBook, ab -> !ab.isEmpty()); + return toClient(addressBook); } catch (Exception e) { log.warn("Error retrieving address book", e); } @@ -283,7 +293,7 @@ private Map getAddressBook() { for (var serviceEndpoint : node.getServiceEndpoints()) { var ip = serviceEndpoint.getIpAddressV4(); var port = serviceEndpoint.getPort(); - if (port == 50211) { + if (port == 50211 && StringUtils.isNotBlank(ip) && !RESET_IP.equals(ip)) { networkMap.putIfAbsent(ip + ":" + port, accountId); } }