diff --git a/acceptance-tests/dsl/build.gradle b/acceptance-tests/dsl/build.gradle index aa5db9ce1e7..0b664c52556 100644 --- a/acceptance-tests/dsl/build.gradle +++ b/acceptance-tests/dsl/build.gradle @@ -45,6 +45,5 @@ dependencies { implementation 'org.web3j:crypto' implementation 'org.wiremock:wiremock' - implementation 'org.testcontainers:testcontainers' implementation 'org.junit.jupiter:junit-jupiter' } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/account/TransferTransactionBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/account/TransferTransactionBuilder.java index 1d859694440..bb5fd5c4ed3 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/account/TransferTransactionBuilder.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/account/TransferTransactionBuilder.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.tests.acceptance.dsl.transaction.account; -import static org.testcontainers.shaded.com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkNotNull; import org.hyperledger.besu.crypto.SECP256K1; import org.hyperledger.besu.crypto.SignatureAlgorithm; diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle index e9724151abd..fdc77354522 100644 --- a/acceptance-tests/tests/build.gradle +++ b/acceptance-tests/tests/build.gradle @@ -74,7 +74,6 @@ dependencies { testImplementation 'org.assertj:assertj-core' testImplementation 'org.awaitility:awaitility' testImplementation 'org.junit.jupiter:junit-jupiter' - testImplementation 'org.testcontainers:testcontainers' testImplementation 'org.web3j:abi' testImplementation 'org.web3j:besu' testImplementation 'org.web3j:core' diff --git a/besu/build.gradle b/besu/build.gradle index fb9aeef9e67..41a4b11494b 100644 --- a/besu/build.gradle +++ b/besu/build.gradle @@ -104,7 +104,6 @@ dependencies { testImplementation 'org.awaitility:awaitility' testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.mockito:mockito-core' - testImplementation 'org.testcontainers:testcontainers' testImplementation 'tech.pegasys.discovery:discovery' testImplementation 'com.google.dagger:dagger' diff --git a/enclave/build.gradle b/enclave/build.gradle index 25aeb466d77..24aa1b2e64d 100644 --- a/enclave/build.gradle +++ b/enclave/build.gradle @@ -24,5 +24,4 @@ dependencies { integrationTestImplementation 'org.awaitility:awaitility' integrationTestImplementation 'org.junit.jupiter:junit-jupiter-api' integrationTestImplementation 'org.mockito:mockito-core' - integrationTestImplementation 'org.testcontainers:testcontainers' } diff --git a/ethereum/api/build.gradle b/ethereum/api/build.gradle index 7f5e3d40a9c..6bbfa531a99 100644 --- a/ethereum/api/build.gradle +++ b/ethereum/api/build.gradle @@ -121,7 +121,6 @@ dependencies { integrationTestImplementation 'org.junit.jupiter:junit-jupiter' integrationTestImplementation 'org.mockito:mockito-core' integrationTestImplementation 'org.mockito:mockito-junit-jupiter' - integrationTestImplementation 'org.testcontainers:testcontainers' integrationTestRuntimeOnly 'org.junit.jupiter:junit-jupiter' } diff --git a/ethereum/core/build.gradle b/ethereum/core/build.gradle index 24c794e298e..912d8673a58 100644 --- a/ethereum/core/build.gradle +++ b/ethereum/core/build.gradle @@ -96,7 +96,6 @@ dependencies { integrationTestImplementation 'org.assertj:assertj-core' integrationTestImplementation 'org.junit.jupiter:junit-jupiter-api' integrationTestImplementation 'org.mockito:mockito-core' - integrationTestImplementation 'org.testcontainers:testcontainers' integrationTestImplementation 'io.tmio:tuweni-bytes' integrationTestRuntimeOnly 'org.junit.jupiter:junit-jupiter' diff --git a/gradle/versions.gradle b/gradle/versions.gradle new file mode 100644 index 00000000000..e69de29bb2d diff --git a/platform/build.gradle b/platform/build.gradle index 307c54dc1a8..5b02eb0beeb 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -158,8 +158,6 @@ dependencies { api 'org.springframework.security:spring-security-crypto:6.3.3' - api 'org.testcontainers:testcontainers:1.20.2' - api 'org.wiremock:wiremock:3.9.1' api 'org.web3j:abi:4.12.2' diff --git a/testutil/build.gradle b/testutil/build.gradle index e77a763bdae..1663c366507 100644 --- a/testutil/build.gradle +++ b/testutil/build.gradle @@ -49,6 +49,4 @@ dependencies { implementation 'org.assertj:assertj-core' implementation 'org.mockito:mockito-core' implementation 'org.web3j:core' - - implementation 'org.testcontainers:testcontainers' } diff --git a/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarness.java b/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarness.java deleted file mode 100644 index f27224fa1d5..00000000000 --- a/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarness.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.enclave.testutil; - -import static com.google.common.io.Files.readLines; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import com.google.common.base.Charsets; -import io.vertx.core.json.JsonArray; -import org.assertj.core.util.Files; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.utility.MountableFile; - -/** The Tessera test harness. */ -public class TesseraTestHarness implements EnclaveTestHarness { - private static final Logger LOG = LoggerFactory.getLogger(TesseraTestHarness.class); - - private final EnclaveConfiguration enclaveConfiguration; - - private boolean isRunning; - private URI nodeURI; - private URI q2TUri; - private URI thirdPartyUri; - - /** The constant TESSERA_VERSION. */ - public static final String TESSERA_VERSION = "22.10.0"; - - private final int thirdPartyPort = 9081; - private final int q2TPort = 9082; - - /** The constant p2pPort. */ - public static final int p2pPort = 9001; - - private final String containerKeyDir = "/tmp/keys/"; - - @SuppressWarnings("rawtypes") - private GenericContainer tesseraContainer; - - private final Optional containerNetwork; - private final String containerName; - - /** - * Instantiates a new Tessera test harness. - * - * @param enclaveConfiguration the enclave configuration - * @param containerNetwork the container network - */ - protected TesseraTestHarness( - final EnclaveConfiguration enclaveConfiguration, final Optional containerNetwork) { - this.enclaveConfiguration = enclaveConfiguration; - this.containerNetwork = containerNetwork; - this.containerName = enclaveConfiguration.getName(); - Runtime.getRuntime().addShutdownHook(new Thread(this::stop)); - } - - @Override - public void start() { - if (!isRunning) { - final File tempFolder = Files.newTemporaryFolder(); - LOG.info("Temporary directory: " + tempFolder.getAbsolutePath()); - final String configFile = createConfigFile(enclaveConfiguration.getName()); - - tesseraContainer = buildTesseraContainer(configFile); - containerNetwork.ifPresent(network -> addNetwork(tesseraContainer, containerName, network)); - tesseraContainer.start(); - isRunning = true; - - try { - final String host = "http://" + tesseraContainer.getHost(); - nodeURI = new URI(host + ":" + tesseraContainer.getMappedPort(p2pPort)); - LOG.info("Tessera node URI: {}", nodeURI); - q2TUri = new URI(host + ':' + tesseraContainer.getMappedPort(q2TPort)); - LOG.info("Tessera client URI: {}", q2TUri); - thirdPartyUri = new URI(host + ':' + tesseraContainer.getMappedPort(thirdPartyPort)); - LOG.info("Tessera thirdParty URI: {}", thirdPartyUri); - } catch (final URISyntaxException e) { - throw new RuntimeException(e); - } - } - } - - @Override - public void stop() { - if (isRunning) { - tesseraContainer.stop(); - isRunning = false; - } - } - - @Override - public void close() { - stop(); - } - - @Override - public List getPublicKeyPaths() { - return Arrays.asList(enclaveConfiguration.getPublicKeys()); - } - - @Override - public String getDefaultPublicKey() { - return readFile(enclaveConfiguration.getPublicKeys()[0]); - } - - @Override - public List getPublicKeys() { - return Arrays.stream(enclaveConfiguration.getPublicKeys()) - .map(TesseraTestHarness::readFile) - .collect(Collectors.toList()); - } - - private static String readFile(final Path path) { - try { - return readLines(path.toFile(), Charsets.UTF_8).get(0); - } catch (final IOException e) { - e.printStackTrace(); - return ""; - } - } - - @Override - public URI clientUrl() { - return q2TUri; - } - - @Override - public URI nodeUrl() { - return nodeURI; - } - - @Override - public void addOtherNode(final URI otherNode) { - enclaveConfiguration.addOtherNode(otherNode.toString()); - } - - @Override - public EnclaveType getEnclaveType() { - return EnclaveType.TESSERA; - } - - private String createConfigFile(final String nodeName) { - // create a config file - - // @formatter:off - String confString = - "{\n" - + " \"mode\" : \"orion\",\n" - + enclaveConfiguration.getEnclaveEncryptorType().toTesseraEncryptorConfigJSON() - + " \"useWhiteList\": false,\n" - + " \"jdbc\": {\n" - + " \"username\": \"sa\",\n" - + " \"password\": \"\",\n" - + " \"url\": \"jdbc:h2:/tmp/db;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=0\",\n" - + " \"autoCreateTables\": true\n" - + " },\n" - + " \"serverConfigs\":[\n" - + " {\n" - + " \"app\":\"ThirdParty\",\n" - + " \"enabled\": true,\n" - + " \"serverAddress\": \"http://" - + nodeName - + ":" - + thirdPartyPort - + "\",\n" - + " \"cors\" : {\n" - + " \"allowedMethods\" : [\"GET\", \"OPTIONS\"],\n" - + " \"allowedOrigins\" : [\"*\"]\n" - + " },\n" - + " \"communicationType\" : \"REST\"\n" - + " },\n" - + " {\n" - + " \"app\":\"Q2T\",\n" - + " \"enabled\": true,\n" - + " \"serverAddress\":\"http://" - + nodeName - + ":" - + q2TPort - + "\",\n" - + " \"communicationType\" : \"REST\"\n" - + " },\n" - + " {\n" - + " \"app\":\"P2P\",\n" - + " \"enabled\": true,\n" - + " \"serverAddress\":\"http://" - + nodeName - + ":" - + p2pPort - + "\",\n" - + " \"communicationType\" : \"REST\"\n" - + " }\n" - + " ],\n" - + " \"keys\": {\n" - + " \"passwords\": [],\n" - + " \"keyData\": " - + buildKeyConfig() - + "\n" - + " },\n" - + " \"alwaysSendTo\": []"; - - if (enclaveConfiguration.getOtherNodes().size() != 0) { - confString += - ",\n" - + " \"peer\": [\n" - + " {\n" - + " \"url\": \"" - + enclaveConfiguration.getOtherNodes().get(0) - + "\"\n" - + " }\n" - + " ]"; - } else { - confString += ",\n" + " \"peer\": []"; - } - - confString += "\n}"; - - final File configFile = Files.newTemporaryFile(); - try { - final FileWriter fw = new FileWriter(configFile, StandardCharsets.UTF_8); - fw.write(confString); - fw.close(); - } catch (final IOException e) { - throw new RuntimeException(e); - } - - return configFile.getAbsolutePath(); - } - - private String buildKeyConfig() { - final JsonArray keyArray = new JsonArray(); - final List pubKeysPaths = Arrays.asList(enclaveConfiguration.getPublicKeys()); - final List privKeyPaths = Arrays.asList(enclaveConfiguration.getPrivateKeys()); - - for (int count = 0; count < pubKeysPaths.size(); count++) { - final HashMap stringStringHashMap = new HashMap<>(); - stringStringHashMap.put( - "publicKeyPath", containerKeyDir + pubKeysPaths.get(count).getFileName()); - stringStringHashMap.put( - "privateKeyPath", containerKeyDir + privKeyPaths.get(count).getFileName()); - keyArray.add(stringStringHashMap); - } - - return keyArray.toString(); - } - - @SuppressWarnings("rawtypes") - private GenericContainer buildTesseraContainer(final String configFilePath) { - final String containerConfigFilePath = "/tmp/config.json"; - final String keyDir = enclaveConfiguration.getTempDir().toString(); - return new GenericContainer<>("quorumengineering/tessera:" + TESSERA_VERSION) - .withCopyFileToContainer(MountableFile.forHostPath(configFilePath), containerConfigFilePath) - .withFileSystemBind(keyDir, containerKeyDir) - .withCommand("--configfile " + containerConfigFilePath) - .withExposedPorts(p2pPort, q2TPort, thirdPartyPort) - .waitingFor(Wait.forHttp("/upcheck").withMethod("GET").forStatusCode(200)); - } - - @SuppressWarnings("rawtypes") - private void addNetwork( - final GenericContainer container, final String containerName, final Network network) { - container.withNetwork(network).withNetworkAliases(containerName); - } -} diff --git a/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarnessFactory.java b/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarnessFactory.java deleted file mode 100644 index 0cfe8b76c9b..00000000000 --- a/testutil/src/main/java/org/hyperledger/enclave/testutil/TesseraTestHarnessFactory.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.enclave.testutil; - -import static org.apache.tuweni.io.file.Files.copyResource; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import javax.annotation.Nonnull; - -import org.testcontainers.containers.Network; - -/** The Tessera test harness factory. */ -public class TesseraTestHarnessFactory { - private static final String storage = "memory"; - - /** Default constructor */ - private TesseraTestHarnessFactory() {} - - /** - * Create tessera test harness. - * - * @param name the name - * @param tempDir the temp dir - * @param enclaveConfig the enclave config - * @param containerNetwork the container network - * @return the tessera test harness - */ - public static TesseraTestHarness create( - final String name, - final Path tempDir, - final EnclaveKeyConfiguration enclaveConfig, - final Optional containerNetwork) { - return create( - name, - tempDir, - enclaveConfig.getPubKeyPaths(), - enclaveConfig.getPrivKeyPaths(), - enclaveConfig.getEnclaveEncryptorType(), - Collections.emptyList(), - containerNetwork); - } - - /** - * Create tessera test harness. - * - * @param name the name - * @param tempDir the temp dir - * @param pubKeyPaths the pub key paths - * @param privKeyPaths the priv key paths - * @param enclaveEncryptorType the enclave encryptor type - * @param othernodes the othernodes - * @param containerNetwork the container network - * @return the tessera test harness - */ - public static TesseraTestHarness create( - final String name, - final Path tempDir, - final String[] pubKeyPaths, - final String[] privKeyPaths, - final EnclaveEncryptorType enclaveEncryptorType, - final List othernodes, - final Optional containerNetwork) { - final Path[] pubKeys = stringArrayToPathArray(tempDir, pubKeyPaths); - final Path[] privKeys = stringArrayToPathArray(tempDir, privKeyPaths); - - return create( - name, tempDir, pubKeys, privKeys, enclaveEncryptorType, othernodes, containerNetwork); - } - - /** - * Create tessera test harness. - * - * @param name the name - * @param tempDir the temp dir - * @param key1pubs the key 1 pubs - * @param key1keys the key 1 keys - * @param enclaveEncryptorType the enclave encryptor type - * @param othernodes the othernodes - * @param containerNetwork the container network - * @return the tessera test harness - */ - public static TesseraTestHarness create( - final String name, - final Path tempDir, - final Path[] key1pubs, - final Path[] key1keys, - final EnclaveEncryptorType enclaveEncryptorType, - final List othernodes, - final Optional containerNetwork) { - return new TesseraTestHarness( - new EnclaveConfiguration( - name, key1pubs, key1keys, enclaveEncryptorType, tempDir, othernodes, false, storage), - containerNetwork); - } - - @Nonnull - private static Path[] stringArrayToPathArray(final Path tempDir, final String[] privKeyPaths) { - return Arrays.stream(privKeyPaths) - .map( - (pk) -> { - try { - return copyResource(pk, tempDir.resolve(pk)); - } catch (final IOException e) { - throw new RuntimeException(e); - } - }) - .toArray(Path[]::new); - } -}