diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/loader/ExternalUrlKeyReader.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/loader/ExternalUrlKeyReader.java index ecaec67994b..08f1ad010d9 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/loader/ExternalUrlKeyReader.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/loader/ExternalUrlKeyReader.java @@ -16,6 +16,7 @@ import static tech.pegasys.teku.infrastructure.logging.StatusLogger.STATUS_LOG; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.annotations.VisibleForTesting; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -58,7 +59,7 @@ public Stream readKeys() { return Arrays.stream(keys).map(key -> BLSPublicKey.fromSSZBytes(Bytes.fromHexString(key))); } - public SafeFuture readUrl() { + private SafeFuture readUrl() { try { return SafeFuture.completedFuture(mapper.readValue(new URL(url), String[].class)); } catch (IOException e) { @@ -66,7 +67,8 @@ public SafeFuture readUrl() { } } - public SafeFuture retry() { + @VisibleForTesting + SafeFuture retry() { return asyncRunner .runWithRetry( () -> { diff --git a/validator/client/src/test/java/tech/pegasys/teku/validator/client/loader/ExternalUrlKeyReaderTest.java b/validator/client/src/test/java/tech/pegasys/teku/validator/client/loader/ExternalUrlKeyReaderTest.java index 36204032716..01f931f8b05 100644 --- a/validator/client/src/test/java/tech/pegasys/teku/validator/client/loader/ExternalUrlKeyReaderTest.java +++ b/validator/client/src/test/java/tech/pegasys/teku/validator/client/loader/ExternalUrlKeyReaderTest.java @@ -44,17 +44,18 @@ class ExternalUrlKeyReaderTest { private static final Duration DELAY = Duration.ofSeconds(5); private static final String VALID_URL = "http://test:0000/api/v1/eth2/publicKeys"; - private final ObjectMapper mapper = mock(ObjectMapper.class); + private final ObjectMapper mapper = mock(ObjectMapper.class); private final StubTimeProvider timeProvider = StubTimeProvider.withTimeInMillis(0); private final StubAsyncRunner asyncRunner = new StubAsyncRunner(timeProvider); private final DataStructureUtil dataStructureUtil = new DataStructureUtil(TestSpecFactory.createDefault()); - final BLSPublicKey publicKey1 = dataStructureUtil.randomPublicKey(); - final BLSPublicKey publicKey2 = dataStructureUtil.randomPublicKey(); - final String[] expectedKeys = new String[] {publicKey1.toHexString(), publicKey2.toHexString()}; + private final BLSPublicKey publicKey1 = dataStructureUtil.randomPublicKey(); + private final BLSPublicKey publicKey2 = dataStructureUtil.randomPublicKey(); + private final String[] expectedKeys = + new String[] {publicKey1.toHexString(), publicKey2.toHexString()}; @Test void readKeys_validUrlReturnsValidKeys() throws IOException {