diff --git a/.circleci/config.yml b/.circleci/config.yml index bcd81e45cbe..1b8a774ce01 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,7 +28,7 @@ executors: resource_class: xlarge working_directory: ~/project environment: - GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=4 + GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=4 -XX:+HeapDumpOnOutOfMemoryError xl_machine_executor: machine: #https://circleci.com/developer/machine/image/ubuntu-2204 @@ -227,7 +227,8 @@ jobs: | sed 's/.\{5\}$//' \ | circleci tests split --split-by=timings --timings-type=classname) # Format the arguments to "./gradlew test" - GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}') + GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}') \ + echo "calling gradle w args $GRADLE_ARGS"\ ./gradlew --no-daemon acceptanceTestMainnet $GRADLE_ARGS - capture_test_results - capture_test_logs @@ -239,7 +240,7 @@ jobs: - attach_workspace: at: ~/project - run: - name: AcceptanceTests (Non-Mainnet) + name: AcceptanceTests (Clique + BFT) no_output_timeout: 20m command: | ./gradlew --no-daemon acceptanceTestCliqueBft @@ -254,7 +255,7 @@ jobs: - attach_workspace: at: ~/project - run: - name: AcceptanceTests (Non-Mainnet) + name: AcceptanceTests (Privacy) no_output_timeout: 20m command: | CLASSNAMES=$(circleci tests glob "acceptance-tests/tests/src/test/java/**/*.java" \ @@ -263,7 +264,8 @@ jobs: | sed 's/.\{5\}$//' \ | circleci tests split --split-by=timings --timings-type=classname) # Format the arguments to "./gradlew test" - GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}') + GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}') \ + echo "calling gradle acceptanceTestPrivacy w args $GRADLE_ARGS"\ ./gradlew --no-daemon acceptanceTestPrivacy $GRADLE_ARGS - capture_test_results - capture_test_logs @@ -275,7 +277,7 @@ jobs: - attach_workspace: at: ~/project - run: - name: AcceptanceTests (Non-Mainnet) + name: AcceptanceTests (Permissioning) no_output_timeout: 20m command: | ./gradlew --no-daemon acceptanceTestPermissioning @@ -409,12 +411,14 @@ workflows: - unitTests: requires: - assemble + - acceptanceTests - testWindows: requires: - assemble - referenceTests: requires: - assemble + - acceptanceTests - integrationTests: requires: - assemble @@ -424,11 +428,11 @@ workflows: - acceptanceTestsCliqueBft: requires: - assemble - - acceptanceTests + - acceptanceTestsPermissioning - acceptanceTestsPermissioning: requires: + - acceptanceTests - assemble - - acceptanceTestsCliqueBft - buildDocker: requires: - assemble diff --git a/acceptance-tests/dsl/build.gradle b/acceptance-tests/dsl/build.gradle index 7aff9aaffb5..8854457c4f8 100644 --- a/acceptance-tests/dsl/build.gradle +++ b/acceptance-tests/dsl/build.gradle @@ -34,7 +34,6 @@ dependencies { implementation 'info.picocli:picocli' implementation 'io.reactivex.rxjava2:rxjava' implementation 'io.vertx:vertx-core' - implementation 'junit:junit' implementation 'io.opentelemetry:opentelemetry-api' implementation 'io.tmio:tuweni-bytes' implementation 'io.tmio:tuweni-io' @@ -47,4 +46,5 @@ dependencies { implementation 'org.web3j:crypto' 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/AcceptanceTestBase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java index 617e0e534cb..7dff3ede726 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBase.java @@ -49,7 +49,6 @@ import org.hyperledger.besu.tests.acceptance.dsl.transaction.web3.Web3Transactions; import java.io.BufferedReader; -import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.lang.ProcessBuilder.Redirect; @@ -57,15 +56,12 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.junit.After; -import org.junit.Rule; -import org.junit.rules.TestName; -import org.junit.rules.TestWatcher; -import org.junit.runner.Description; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.MDC; +@ExtendWith(AcceptanceTestBaseTestWatcher.class) public class AcceptanceTestBase { private static final Logger LOG = LoggerFactory.getLogger(AcceptanceTestBase.class); @@ -131,9 +127,7 @@ protected AcceptanceTestBase() { exitedSuccessfully = new ExitedWithCode(0); } - @Rule public final TestName name = new TestName(); - - @After + @AfterEach public void tearDownAcceptanceTestBase() { reportMemory(); cluster.close(); @@ -178,49 +172,6 @@ private void printOutput(final Process process) { } } - @Rule - public TestWatcher logEraser = - new TestWatcher() { - - @Override - protected void starting(final Description description) { - MDC.put("test", description.getMethodName()); - MDC.put("class", description.getClassName()); - - final String errorMessage = "Uncaught exception in thread \"{}\""; - Thread.currentThread() - .setUncaughtExceptionHandler( - (thread, error) -> LOG.error(errorMessage, thread.getName(), error)); - Thread.setDefaultUncaughtExceptionHandler( - (thread, error) -> LOG.error(errorMessage, thread.getName(), error)); - } - - @Override - protected void failed(final Throwable e, final Description description) { - // add the result at the end of the log so it is self-sufficient - LOG.error( - "=========================================================================================="); - LOG.error("Test failed. Reported Throwable at the point of failure:", e); - LOG.error(e.getMessage()); - } - - @Override - protected void succeeded(final Description description) { - // if so configured, delete logs of successful tests - if (!Boolean.getBoolean("acctests.keepLogsOfPassingTests")) { - String pathname = - "build/acceptanceTestLogs/" - + description.getClassName() - + "." - + description.getMethodName() - + ".log"; - LOG.info("Test successful, deleting log at {}", pathname); - File file = new File(pathname); - file.delete(); - } - } - }; - protected void waitForBlockHeight(final Node node, final long blockchainHeight) { WaitUtils.waitFor( 120, diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseTestWatcher.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseTestWatcher.java new file mode 100644 index 00000000000..6afc34c2e04 --- /dev/null +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/AcceptanceTestBaseTestWatcher.java @@ -0,0 +1,61 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.besu.tests.acceptance.dsl; + +import java.io.File; +import java.util.Optional; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestWatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AcceptanceTestBaseTestWatcher implements TestWatcher { + private static final Logger LOG = LoggerFactory.getLogger(AcceptanceTestBaseTestWatcher.class); + + @Override + public void testAborted(final ExtensionContext extensionContext, final Throwable throwable) { + LOG.info("test aborted:" + extensionContext.getDisplayName()); + } + + @Override + public void testDisabled( + final ExtensionContext extensionContext, final Optional optional) { + LOG.info("test disabled:" + extensionContext.getDisplayName()); + } + + @Override + public void testFailed(final ExtensionContext extensionContext, final Throwable e) { + // add the result at the end of the log, so it is self-sufficient + LOG.error( + "=========================================================================================="); + LOG.error("Test failed. Reported Throwable at the point of failure:", e); + LOG.error(e.getMessage()); + } + + @Override + public void testSuccessful(final ExtensionContext extensionContext) { + // TODO where is the other side of this - what creates these log files? + + // if so configured, delete logs of successful tests + if (!Boolean.getBoolean("acctests.keepLogsOfPassingTests")) { + String pathname = "build/acceptanceTestLogs/" + extensionContext.getDisplayName() + ".log"; + LOG.info("Test successful, deleting log at {}", pathname); + File file = new File(pathname); + file.delete(); + } + } +} diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/ParameterizedEnclaveTestBase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/ParameterizedEnclaveTestBase.java index 581fd71722d..3755353a317 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/ParameterizedEnclaveTestBase.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/ParameterizedEnclaveTestBase.java @@ -25,43 +25,26 @@ import org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction.RestrictedCreatePrivacyGroupTransaction; import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; import org.hyperledger.enclave.testutil.EnclaveEncryptorType; -import org.hyperledger.enclave.testutil.EnclaveType; -import java.util.Arrays; -import java.util.Collection; +import java.util.stream.Stream; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; import org.web3j.utils.Restriction; -@RunWith(Parameterized.class) public abstract class ParameterizedEnclaveTestBase extends PrivacyAcceptanceTestBase { - protected final Restriction restriction; - protected final EnclaveType enclaveType; - protected final EnclaveEncryptorType enclaveEncryptorType; - protected ParameterizedEnclaveTestBase( - final Restriction restriction, - final EnclaveType enclaveType, - final EnclaveEncryptorType enclaveEncryptorType) { - this.restriction = restriction; - this.enclaveType = enclaveType; - this.enclaveEncryptorType = enclaveEncryptorType; - } - - @Parameters(name = "{0} tx with {1} enclave and {2} encryptor type") - public static Collection params() { - return Arrays.asList( - new Object[][] { - {RESTRICTED, TESSERA, NACL}, - {RESTRICTED, TESSERA, EC}, - {UNRESTRICTED, NOOP, EnclaveEncryptorType.NOOP} - }); + public static Stream params() { + return Stream.of( + Arguments.of(RESTRICTED, TESSERA, NACL), + Arguments.of(RESTRICTED, TESSERA, EC), + Arguments.of(UNRESTRICTED, NOOP, EnclaveEncryptorType.NOOP)); } public Transaction createPrivacyGroup( - final String name, final String description, final PrivacyNode... nodes) { + final Restriction restriction, + final String name, + final String description, + final PrivacyNode... nodes) { if (restriction == RESTRICTED) { return new RestrictedCreatePrivacyGroupTransaction(name, description, nodes); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyAcceptanceTestBase.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyAcceptanceTestBase.java index 8e12cbc7a80..d861ba6f98b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyAcceptanceTestBase.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyAcceptanceTestBase.java @@ -32,12 +32,9 @@ import java.math.BigInteger; import io.vertx.core.Vertx; -import org.junit.After; -import org.junit.ClassRule; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterEach; public class PrivacyAcceptanceTestBase { - @ClassRule public static final TemporaryFolder privacy = new TemporaryFolder(); protected final PrivacyTransactions privacyTransactions; protected final PrivateContractVerifier privateContractVerifier; @@ -77,7 +74,7 @@ protected void waitForBlockHeight(final PrivacyNode node, final long blockchainH .isGreaterThanOrEqualTo(BigInteger.valueOf(blockchainHeight))); } - @After + @AfterEach public void tearDownAcceptanceTestBase() { privacyCluster.close(); vertx.close(); diff --git a/acceptance-tests/test-plugins/build.gradle b/acceptance-tests/test-plugins/build.gradle index c31175cee8f..f605252d030 100644 --- a/acceptance-tests/test-plugins/build.gradle +++ b/acceptance-tests/test-plugins/build.gradle @@ -13,8 +13,6 @@ dependencies { testImplementation 'org.assertj:assertj-core' testImplementation 'org.junit.jupiter:junit-jupiter' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } task testPluginsJar(type: Jar) { diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle index 464805779c8..e36bb13c912 100644 --- a/acceptance-tests/tests/build.gradle +++ b/acceptance-tests/tests/build.gradle @@ -73,7 +73,6 @@ dependencies { testImplementation 'io.opentracing:opentracing-api' testImplementation 'io.opentracing:opentracing-util' testImplementation 'io.vertx:vertx-core' - testImplementation 'junit:junit' testImplementation 'org.apache.commons:commons-compress' testImplementation 'org.apache.logging.log4j:log4j-core' testImplementation 'io.tmio:tuweni-crypto' @@ -84,8 +83,6 @@ dependencies { testImplementation 'org.web3j:abi' testImplementation 'org.web3j:besu' testImplementation 'org.web3j:core' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } test.enabled = false @@ -103,8 +100,6 @@ processTestResources.dependsOn(':acceptance-tests:test-plugins:testPluginsJar',' task acceptanceTest(type: Test) { inputs.property "integration.date", LocalTime.now() // so it runs at every invocation - useJUnitPlatform {} - dependsOn(rootProject.installDist) setSystemProperties(test.getSystemProperties()) systemProperty 'acctests.runBesuAsProcess', 'true' @@ -132,8 +127,6 @@ task acceptanceTestMainnet(type: Test) { exclude '**/permissioning/**' exclude '**/privacy/**' - useJUnitPlatform {} - dependsOn(rootProject.installDist) setSystemProperties(test.getSystemProperties()) systemProperty 'acctests.runBesuAsProcess', 'true' @@ -160,13 +153,10 @@ task acceptanceTestCliqueBft(type: Test) { include '**/bft/**' include '**/clique/**' - useJUnitPlatform {} - dependsOn(rootProject.installDist) setSystemProperties(test.getSystemProperties()) systemProperty 'acctests.runBesuAsProcess', 'true' systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security" - mustRunAfter rootProject.subprojects*.test description = 'Runs Clique and BFT Besu acceptance tests.' group = 'verification' @@ -187,8 +177,6 @@ task acceptanceTestPrivacy(type: Test) { inputs.property "integration.date", LocalTime.now() // so it runs at every invocation include '**/privacy/**' - useJUnitPlatform {} - dependsOn(rootProject.installDist) setSystemProperties(test.getSystemProperties()) systemProperty 'acctests.runBesuAsProcess', 'true' @@ -214,13 +202,10 @@ task acceptanceTestPermissioning(type: Test) { inputs.property "integration.date", LocalTime.now() // so it runs at every invocation include '**/permissioning/**' - useJUnitPlatform {} - dependsOn(rootProject.installDist) setSystemProperties(test.getSystemProperties()) systemProperty 'acctests.runBesuAsProcess', 'true' systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security" - mustRunAfter rootProject.subprojects*.test description = 'Runs Permissioning Besu acceptance tests.' group = 'verification' diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java index b7464190abe..c03df68eac5 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java @@ -17,26 +17,23 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeFactory; -import java.util.ArrayList; -import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.params.provider.Arguments; public class BftAcceptanceTestParameterization { - public static List getFactories() { - final List ret = new ArrayList<>(); - ret.addAll( - List.of( - new Object[] { - "ibft2", - new BftAcceptanceTestParameterization( - BesuNodeFactory::createIbft2Node, BesuNodeFactory::createIbft2NodeWithValidators) - }, - new Object[] { - "qbft", - new BftAcceptanceTestParameterization( - BesuNodeFactory::createQbftNode, BesuNodeFactory::createQbftNodeWithValidators) - })); - return ret; + public static Stream getFactories() { + return Stream.of( + Arguments.of( + "ibft2", + new BftAcceptanceTestParameterization( + BesuNodeFactory::createIbft2Node, BesuNodeFactory::createIbft2NodeWithValidators), + Arguments.of( + "qbft", + new BftAcceptanceTestParameterization( + BesuNodeFactory::createQbftNode, + BesuNodeFactory::createQbftNodeWithValidators)))); } @FunctionalInterface diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftBlockRewardPaymentAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftBlockRewardPaymentAcceptanceTest.java index 4225035b7ff..86978ae0b0e 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftBlockRewardPaymentAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftBlockRewardPaymentAcceptanceTest.java @@ -32,19 +32,18 @@ import java.util.Optional; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class BftBlockRewardPaymentAcceptanceTest extends ParameterizedBftTestBase { private static final Amount BLOCK_REWARD = Amount.wei(new BigInteger("5000000000000000000", 10)); - public BftBlockRewardPaymentAcceptanceTest( - final String testName, final BftAcceptanceTestParameterization nodeFactory) { - super(testName, nodeFactory); - } - - @Test - public void validatorsArePaidBlockReward() throws Exception { + @ParameterizedTest(name = "{0} bft node factory type") + @MethodSource("factoryFunctions") + public void validatorsArePaidBlockReward( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final String[] validators = {"validator"}; final BesuNode validator = nodeFactory.createNodeWithValidators(besu, "validator", validators); final BesuNode nonValidator = @@ -61,8 +60,11 @@ public void validatorsArePaidBlockReward() throws Exception { Amount.ether(blockRewardEth * blockToCheck), BigInteger.valueOf(blockToCheck))); } - @Test - public void payBlockRewardToConfiguredNode() throws Exception { + @ParameterizedTest(name = "{0} bft node factory type") + @MethodSource("factoryFunctions") + public void payBlockRewardToConfiguredNode( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final String[] validators = {"validator1"}; final BesuNode validator1 = nodeFactory.createNodeWithValidators(besu, "validator1", validators); @@ -90,9 +92,11 @@ public void payBlockRewardToConfiguredNode() throws Exception { Amount.ether(blockRewardEth * blockToCheck), BigInteger.valueOf(blockToCheck))); } - @Test - public void payBlockRewardAccordingToTransitions_defaultInitialMiningBeneficiary() - throws Exception { + @ParameterizedTest(name = "{0} bft node factory type") + @MethodSource("factoryFunctions") + public void payBlockRewardAccordingToTransitions_defaultInitialMiningBeneficiary( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final List
addresses = generateAddresses(2); final Map> transitions = Map.of( @@ -103,9 +107,11 @@ public void payBlockRewardAccordingToTransitions_defaultInitialMiningBeneficiary testMiningBeneficiaryTransitions(Optional.empty(), transitions); } - @Test - public void payBlockRewardAccordingToTransitions_customInitialMiningBeneficiary() - throws Exception { + @ParameterizedTest(name = "{0} bft node factory type") + @MethodSource("factoryFunctions") + public void payBlockRewardAccordingToTransitions_customInitialMiningBeneficiary( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final List
addresses = generateAddresses(4); final Map> transitions = Map.of( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftDiscardRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftDiscardRpcAcceptanceTest.java index 40d0e881459..0e7484529fe 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftDiscardRpcAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftDiscardRpcAcceptanceTest.java @@ -16,17 +16,16 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class BftDiscardRpcAcceptanceTest extends ParameterizedBftTestBase { - public BftDiscardRpcAcceptanceTest( - final String testName, final BftAcceptanceTestParameterization nodeFactory) { - super(testName, nodeFactory); - } - - @Test - public void shouldDiscardVotes() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldDiscardVotes( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final String[] validators = {"validator1", "validator3"}; final BesuNode validator1 = nodeFactory.createNodeWithValidators(besu, "validator1", validators); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java index a109a3b8567..71eb3908a7c 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java @@ -28,17 +28,16 @@ import java.util.Optional; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class BftMiningAcceptanceTest extends ParameterizedBftTestBase { - public BftMiningAcceptanceTest( - final String testName, final BftAcceptanceTestParameterization nodeFactory) { - super(testName, nodeFactory); - } - - @Test - public void shouldMineOnSingleNodeWithPaidGas_Berlin() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldMineOnSingleNodeWithPaidGas_Berlin( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final BesuNode minerNode = nodeFactory.createNode(besu, "miner1"); cluster.start(minerNode); @@ -57,8 +56,11 @@ public void shouldMineOnSingleNodeWithPaidGas_Berlin() throws Exception { cluster.verify(receiver.balanceEquals(3)); } - @Test - public void shouldMineOnSingleNodeWithFreeGas_Berlin() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldMineOnSingleNodeWithFreeGas_Berlin( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final BesuNode minerNode = nodeFactory.createNode(besu, "miner1"); final MiningParameters zeroGasMiningParams = ImmutableMiningParameters.builder() @@ -90,8 +92,11 @@ public void shouldMineOnSingleNodeWithFreeGas_Berlin() throws Exception { cluster.verify(receiver.balanceEquals(3)); } - @Test - public void shouldMineOnSingleNodeWithPaidGas_London() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldMineOnSingleNodeWithPaidGas_London( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final BesuNode minerNode = nodeFactory.createNode(besu, "miner1"); updateGenesisConfigToLondon(minerNode, false); @@ -115,8 +120,11 @@ public void shouldMineOnSingleNodeWithPaidGas_London() throws Exception { cluster.verify(receiver.balanceEquals(3)); } - @Test - public void shouldMineOnSingleNodeWithFreeGas_London() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldMineOnSingleNodeWithFreeGas_London( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final BesuNode minerNode = nodeFactory.createNode(besu, "miner1"); updateGenesisConfigToLondon(minerNode, true); @@ -142,8 +150,11 @@ public void shouldMineOnSingleNodeWithFreeGas_London() throws Exception { cluster.verify(receiver.balanceEquals(3)); } - @Test - public void shouldMineOnMultipleNodes() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldMineOnMultipleNodes( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final BesuNode minerNode1 = nodeFactory.createNode(besu, "miner1"); final BesuNode minerNode2 = nodeFactory.createNode(besu, "miner2"); final BesuNode minerNode3 = nodeFactory.createNode(besu, "miner3"); @@ -168,8 +179,11 @@ public void shouldMineOnMultipleNodes() throws Exception { cluster.verify(receiver.balanceEquals(6)); } - @Test - public void shouldMineOnMultipleNodesEvenWhenClusterContainsNonValidator() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldMineOnMultipleNodesEvenWhenClusterContainsNonValidator( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final String[] validators = {"validator1", "validator2", "validator3"}; final BesuNode validator1 = nodeFactory.createNodeWithValidators(besu, "validator1", validators); @@ -196,9 +210,11 @@ public void shouldMineOnMultipleNodesEvenWhenClusterContainsNonValidator() throw cluster.verify(receiver.balanceEquals(3)); } - @Test - public void shouldStillMineWhenANonProposerNodeFailsAndHasSufficientValidators() - throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldStillMineWhenANonProposerNodeFailsAndHasSufficientValidators( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final BesuNode minerNode1 = nodeFactory.createNode(besu, "miner1"); final BesuNode minerNode2 = nodeFactory.createNode(besu, "miner2"); final BesuNode minerNode3 = nodeFactory.createNode(besu, "miner3"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftProposalRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftProposalRpcAcceptanceTest.java index 7fccf33fa27..eecd383003f 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftProposalRpcAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftProposalRpcAcceptanceTest.java @@ -16,17 +16,16 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class BftProposalRpcAcceptanceTest extends ParameterizedBftTestBase { - public BftProposalRpcAcceptanceTest( - final String testName, final BftAcceptanceTestParameterization nodeFactory) { - super(testName, nodeFactory); - } - - @Test - public void shouldReturnProposals() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldReturnProposals( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final String[] validators = {"validator1", "validator2", "validator3"}; final BesuNode validator1 = nodeFactory.createNodeWithValidators(besu, "validator1", validators); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftProposeRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftProposeRpcAcceptanceTest.java index 7db3d6a5b9f..191884f41a2 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftProposeRpcAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftProposeRpcAcceptanceTest.java @@ -17,19 +17,18 @@ import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; // These tests prove the ibft_proposeValidatorVote and ibft_getValidatorsByBlockNumber (implicitly) // JSON RPC calls. public class BftProposeRpcAcceptanceTest extends ParameterizedBftTestBase { - public BftProposeRpcAcceptanceTest( - final String testName, final BftAcceptanceTestParameterization nodeFactory) { - super(testName, nodeFactory); - } - - @Test - public void validatorsCanBeAddedAndThenRemoved() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void validatorsCanBeAddedAndThenRemoved( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final String[] validators = {"validator1", "validator2", "validator3"}; final BesuNode validator1 = nodeFactory.createNodeWithValidators(besu, "validator1", validators); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftZeroValidators.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftZeroValidators.java index 898ad47b3f8..a77909d24e8 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftZeroValidators.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftZeroValidators.java @@ -16,17 +16,16 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class BftZeroValidators extends ParameterizedBftTestBase { - public BftZeroValidators( - final String testName, final BftAcceptanceTestParameterization nodeFactory) { - super(testName, nodeFactory); - } - - @Test - public void zeroValidatorsFormValidCluster() throws Exception { + @ParameterizedTest(name = "{0} bft node factory type") + @MethodSource("factoryFunctions") + public void zeroValidatorsFormValidCluster( + final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { + setUp(testName, nodeFactory); final String[] validators = {}; final BesuNode node1 = nodeFactory.createNodeWithValidators(besu, "node1", validators); final BesuNode node2 = nodeFactory.createNodeWithValidators(besu, "node2", validators); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/ParameterizedBftTestBase.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/ParameterizedBftTestBase.java index e08d4a5c206..29a4df4a9a7 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/ParameterizedBftTestBase.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/ParameterizedBftTestBase.java @@ -16,27 +16,21 @@ import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; -import java.util.Collection; +import java.util.stream.Stream; import org.junit.Ignore; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(Parameterized.class) @Ignore("This is not a test class, it offers BFT parameterization only.") public abstract class ParameterizedBftTestBase extends AcceptanceTestBase { + protected String bftType; + protected BftAcceptanceTestParameterization nodeFactory; - protected final String bftType; - protected final BftAcceptanceTestParameterization nodeFactory; - - @Parameters(name = "{0}") - public static Collection factoryFunctions() { + public static Stream factoryFunctions() { return BftAcceptanceTestParameterization.getFactories(); } - protected ParameterizedBftTestBase( - final String bftType, final BftAcceptanceTestParameterization input) { + protected void setUp(final String bftType, final BftAcceptanceTestParameterization input) { this.bftType = bftType; this.nodeFactory = input; } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/ParameterizedPkiQbftTestBase.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/ParameterizedPkiQbftTestBase.java index 29c00b65d96..5614b0dec18 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/ParameterizedPkiQbftTestBase.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/ParameterizedPkiQbftTestBase.java @@ -16,26 +16,14 @@ import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; -import java.util.Collection; +import java.util.stream.Stream; import org.junit.Ignore; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(Parameterized.class) @Ignore("This is not a test class, it offers PKI QBFT parameterization only.") public abstract class ParameterizedPkiQbftTestBase extends AcceptanceTestBase { - - protected final PkiQbftAcceptanceTestParameterization nodeFactory; - - @Parameters(name = "{0}") - public static Collection factoryFunctions() { + public static Stream factoryFunctions() { return PkiQbftAcceptanceTestParameterization.getFactories(); } - - protected ParameterizedPkiQbftTestBase( - final String testName, final PkiQbftAcceptanceTestParameterization input) { - this.nodeFactory = input; - } } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTest.java index 8fecb5f6779..12ae887a510 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTest.java @@ -20,17 +20,16 @@ import org.hyperledger.besu.tests.acceptance.dsl.account.Account; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class PkiQbftAcceptanceTest extends ParameterizedPkiQbftTestBase { - public PkiQbftAcceptanceTest( - final String testName, final PkiQbftAcceptanceTestParameterization input) { - super(testName, input); - } - - @Test - public void shouldMineOnSingleNode() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldMineOnSingleNode( + final String testName, final PkiQbftAcceptanceTestParameterization nodeFactory) + throws Exception { final BesuNode minerNode = nodeFactory.createNode(besu, "miner1"); cluster.start(minerNode); @@ -49,8 +48,11 @@ public void shouldMineOnSingleNode() throws Exception { cluster.verify(receiver.balanceEquals(3)); } - @Test - public void shouldMineOnMultipleNodes() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldMineOnMultipleNodes( + final String testName, final PkiQbftAcceptanceTestParameterization nodeFactory) + throws Exception { final BesuNode minerNode1 = nodeFactory.createNode(besu, "miner1"); final BesuNode minerNode2 = nodeFactory.createNode(besu, "miner2"); final BesuNode minerNode3 = nodeFactory.createNode(besu, "miner3"); @@ -75,8 +77,11 @@ public void shouldMineOnMultipleNodes() throws Exception { cluster.verify(receiver.balanceEquals(6)); } - @Test - public void shouldMineWithIgnoringANodeInCRL() throws Exception { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("factoryFunctions") + public void shouldMineWithIgnoringANodeInCRL( + final String testName, final PkiQbftAcceptanceTestParameterization nodeFactory) + throws Exception { final BesuNode minerNode1 = nodeFactory.createNode(besu, "miner1"); final BesuNode minerNode2 = nodeFactory.createNode(besu, "miner2"); final BesuNode minerNode3 = nodeFactory.createNode(besu, "miner3"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTestParameterization.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTestParameterization.java index 10d4866fef7..7bcf09afd38 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTestParameterization.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/pki/PkiQbftAcceptanceTestParameterization.java @@ -22,73 +22,70 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.params.provider.Arguments; public class PkiQbftAcceptanceTestParameterization { - public static List getFactories() { - final List ret = new ArrayList<>(); + public static Stream getFactories() { + List args = new ArrayList<>(); /* BLOCK CREATION */ - ret.add( - new Object[] { - "qbft-pki-jks", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createPkiQbftJKSNode, - BesuNodeFactory::createPkiQbftJKSNodeWithValidators) - }); - - ret.add( - new Object[] { - "qbft-pki-pkcs12", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createPkiQbftPKCS12Node, - BesuNodeFactory::createPkiQbftPKCS12NodeWithValidators) - }); + args.add( + Arguments.of( + "qbft-pki-jks", + new PkiQbftAcceptanceTestParameterization( + BesuNodeFactory::createPkiQbftJKSNode, + BesuNodeFactory::createPkiQbftJKSNodeWithValidators))); - if (Boolean.getBoolean("acctests.runBesuAsProcess")) { - ret.add( - new Object[] { - "qbft-pki-pkcs11", + args.add( + Arguments.of( + "qbft-pki-pkcs12", new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createPkiQbftPKCS11Node, - BesuNodeFactory::createPkiQbftPKCS11NodeWithValidators) - }); + BesuNodeFactory::createPkiQbftPKCS12Node, + BesuNodeFactory::createPkiQbftPKCS12NodeWithValidators))); + + if (Boolean.getBoolean("acctests.runBesuAsProcess")) { + args.add( + Arguments.of( + "qbft-pki-pkcs11", + new PkiQbftAcceptanceTestParameterization( + BesuNodeFactory::createPkiQbftPKCS11Node, + BesuNodeFactory::createPkiQbftPKCS11NodeWithValidators))); } /* TLS */ - ret.add( - new Object[] { - "qbft-tls-jks", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createQbftNodeWithTLSJKS, - BesuNodeFactory::createQbftTLSJKSNodeWithValidators) - }); - - ret.add( - new Object[] { - "qbft-tls-pkcs12", - new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createQbftNodeWithTLSPKCS12, - BesuNodeFactory::createQbftTLSPKCS12NodeWithValidators) - }); + args.add( + Arguments.of( + "qbft-tls-jks", + new PkiQbftAcceptanceTestParameterization( + BesuNodeFactory::createQbftNodeWithTLSJKS, + BesuNodeFactory::createQbftTLSJKSNodeWithValidators))); - if (Boolean.getBoolean("acctests.runBesuAsProcess")) { - ret.add( - new Object[] { - "qbft-tls-pkcs11", + args.add( + Arguments.of( + "qbft-tls-pkcs12", new PkiQbftAcceptanceTestParameterization( - BesuNodeFactory::createQbftNodeWithTLSPKCS11, - BesuNodeFactory::createQbftTLSPKCS11NodeWithValidators) - }); + BesuNodeFactory::createQbftNodeWithTLSPKCS12, + BesuNodeFactory::createQbftTLSPKCS12NodeWithValidators))); + + if (Boolean.getBoolean("acctests.runBesuAsProcess")) { + args.add( + Arguments.of( + "qbft-tls-pkcs11", + new PkiQbftAcceptanceTestParameterization( + BesuNodeFactory::createQbftNodeWithTLSPKCS11, + BesuNodeFactory::createQbftTLSPKCS11NodeWithValidators))); } - return ret; + return args.stream(); } @FunctionalInterface diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java index e3b2878b052..a788da4c453 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/qbft/QbftContractAcceptanceTest.java @@ -18,7 +18,7 @@ import org.hyperledger.besu.tests.acceptance.dsl.account.Account; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class QbftContractAcceptanceTest extends AcceptanceTestBase { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java index 9dbf376aac5..3ac42cb056c 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueDiscardRpcAcceptanceTest.java @@ -19,7 +19,7 @@ import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CliqueDiscardRpcAcceptanceTest extends AcceptanceTestBase { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcAcceptanceTest.java similarity index 89% rename from acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcTest.java rename to acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcAcceptanceTest.java index 92987595dfd..25a1d335105 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueGetSignersRpcAcceptanceTest.java @@ -19,16 +19,16 @@ import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -@Ignore -public class CliqueGetSignersRpcTest extends AcceptanceTestBase { +@Disabled("flaky test due to hardcoded block numbers") +public class CliqueGetSignersRpcAcceptanceTest extends AcceptanceTestBase { private BesuNode minerNode1; private BesuNode minerNode2; - @Before + @BeforeEach public void setUp() throws Exception { final String[] validators = {"miner1"}; minerNode1 = besu.createCliqueNodeWithValidators("miner1", validators); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java index 4ac728dec73..5afc5b195b1 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueMiningAcceptanceTest.java @@ -21,7 +21,7 @@ import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CliqueMiningAcceptanceTest extends AcceptanceTestBase { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposalRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposalRpcAcceptanceTest.java index 65340c57d27..6cbfbbda0f0 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposalRpcAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposalRpcAcceptanceTest.java @@ -19,7 +19,7 @@ import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CliqueProposalRpcAcceptanceTest extends AcceptanceTestBase { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java index 4767f6267b8..1674c551a4b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueProposeRpcAcceptanceTest.java @@ -21,7 +21,7 @@ import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CliqueProposeRpcAcceptanceTest extends AcceptanceTestBase { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidators.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidatorsAcceptanceTest.java similarity index 91% rename from acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidators.java rename to acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidatorsAcceptanceTest.java index 3f8ed7b5e9c..e124e669d92 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidators.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/clique/CliqueZeroValidatorsAcceptanceTest.java @@ -19,9 +19,9 @@ import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class CliqueZeroValidators extends AcceptanceTestBase { +public class CliqueZeroValidatorsAcceptanceTest extends AcceptanceTestBase { @Test public void zeroValidatorsFormValidCluster() throws IOException { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/MiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/MiningAcceptanceTest.java index 69d6d19d18e..c64ef559212 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/MiningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/mining/MiningAcceptanceTest.java @@ -18,14 +18,14 @@ import org.hyperledger.besu.tests.acceptance.dsl.account.Account; import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MiningAcceptanceTest extends AcceptanceTestBase { private Node minerNode; - @Before + @BeforeEach public void setUp() throws Exception { minerNode = besu.createMinerNode("miner1"); cluster.start(minerNode); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalAndOnchainPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalAndOnchainPermissioningAcceptanceTest.java index 4b6401303be..1d38f7e6c7c 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalAndOnchainPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalAndOnchainPermissioningAcceptanceTest.java @@ -21,15 +21,15 @@ import java.math.BigInteger; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AccountLocalAndOnchainPermissioningAcceptanceTest extends AccountSmartContractPermissioningAcceptanceTestBase { private Account senderC; - @Before + @BeforeEach public void setUp() { senderC = accounts.createAccount("Account-C"); } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningAcceptanceTest.java index 78a9fee0413..4b163a4efc9 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningAcceptanceTest.java @@ -22,8 +22,8 @@ import java.math.BigInteger; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AccountLocalConfigPermissioningAcceptanceTest extends AcceptanceTestBase { @@ -31,7 +31,7 @@ public class AccountLocalConfigPermissioningAcceptanceTest extends AcceptanceTes private Account senderA; private Account senderB; - @Before + @BeforeEach public void setUp() throws Exception { senderA = accounts.getPrimaryBenefactor(); senderB = accounts.getSecondaryBenefactor(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningImportAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningImportAcceptanceTest.java index 4415a03f807..93443c61d3b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningImportAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountLocalConfigPermissioningImportAcceptanceTest.java @@ -23,18 +23,18 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class AccountLocalConfigPermissioningImportAcceptanceTest extends AcceptanceTestBase { - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @TempDir public Path folder; private static final String GENESIS_FILE = "/ibft/ibft.json"; @@ -45,12 +45,12 @@ public class AccountLocalConfigPermissioningImportAcceptanceTest extends Accepta private BesuNode nodeB; private Cluster permissionedCluster; - @Before + @BeforeEach public void setUp() throws IOException { sender = accounts.getPrimaryBenefactor(); beneficiary = accounts.createAccount("beneficiary"); final List allowList = List.of(sender.getAddress(), beneficiary.getAddress()); - final File sharedFile = folder.newFile(); + final File sharedFile = Files.createFile(folder.resolve("shared.txt")).toFile(); persistAllowList(allowList, sharedFile.toPath()); bootnode = besu.createIbft2NonValidatorBootnode("bootnode", GENESIS_FILE); nodeA = @@ -67,7 +67,7 @@ public void setUp() throws IOException { @Test public void transactionFromDeniedAccountShouldNotBreakBlockImport() throws IOException { - final File newPermissionsFile = folder.newFile(); + final File newPermissionsFile = Files.createFile(folder.resolve("new.txt")).toFile(); final List allowList = List.of(beneficiary.getAddress()); persistAllowList(allowList, newPermissionsFile.toPath()); final BesuNode nodeC = @@ -91,7 +91,7 @@ private void persistAllowList(final List allowList, final Path path) thr AllowlistPersistor.ALLOWLIST_TYPE.ACCOUNTS, allowList, path); } - @After + @AfterEach public void tearDown() { permissionedCluster.stop(); } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountSmartContractPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountSmartContractPermissioningAcceptanceTest.java index 6d9e74e04a6..9009721d94d 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountSmartContractPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AccountSmartContractPermissioningAcceptanceTest.java @@ -21,8 +21,8 @@ import java.math.BigInteger; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AccountSmartContractPermissioningAcceptanceTest extends AccountSmartContractPermissioningAcceptanceTestBase { @@ -31,7 +31,7 @@ public class AccountSmartContractPermissioningAcceptanceTest private Account allowedSender; private Account otherAccount; - @Before + @BeforeEach public void setUp() { node = permissionedNode("node1", Collections.emptyList()); permissionedCluster.start(node); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java index 5a563cc5264..71258222d78 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java @@ -26,8 +26,8 @@ import java.util.Collections; import org.assertj.core.api.Assertions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AllowlistPersistorAcceptanceTest extends AcceptanceTestBase { @@ -45,7 +45,7 @@ public class AllowlistPersistorAcceptanceTest extends AcceptanceTestBase { private Account senderB; private Path tempFile; - @Before + @BeforeEach public void setUp() throws Exception { senderA = accounts.getPrimaryBenefactor(); senderB = accounts.getSecondaryBenefactor(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistWithDnsPersistorAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistWithDnsPersistorAcceptanceTest.java index 88c7e783777..a70de1ac0c5 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistWithDnsPersistorAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistWithDnsPersistorAcceptanceTest.java @@ -25,14 +25,16 @@ import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition; import org.hyperledger.besu.tests.acceptance.dsl.node.Node; +import java.io.IOException; import java.net.InetAddress; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class AllowlistWithDnsPersistorAcceptanceTest extends AcceptanceTestBase { @@ -46,9 +48,12 @@ public class AllowlistWithDnsPersistorAcceptanceTest extends AcceptanceTestBase private Node node; private Account senderA; - private Path tempFile; + @TempDir private Path tempDir; - @Before + @TempDir private Path nodesConfigFile; + @TempDir private Path accountsConfigFile; + + @BeforeEach public void setUp() throws Exception { ENODE_LOCALHOST_DNS = ENODE_PREFIX + InetAddress.getLocalHost().getHostName() + PORT_SUFFIX; ENODE_LOCALHOST_IP = ENODE_PREFIX + "127.0.0.1" + PORT_SUFFIX; @@ -56,14 +61,16 @@ public void setUp() throws Exception { "enode://5f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.10:1234"; senderA = accounts.getPrimaryBenefactor(); - tempFile = Files.createTempFile("test", "perm-dns-test"); + + nodesConfigFile = Files.createFile(tempDir.resolve("nodesConfigFile.txt")); + accountsConfigFile = Files.createFile(tempDir.resolve("accountsConfigFile.txt")); this.node = permissionedNodeBuilder .name("node") - .nodesConfigFile(tempFile) + .nodesConfigFile(nodesConfigFile) .nodesPermittedInConfig(new ArrayList<>()) - .accountsConfigFile(tempFile) + .accountsConfigFile(accountsConfigFile) .accountsPermittedInConfig(Collections.singletonList(senderA.getAddress())) .dnsEnabled(true) .build(); @@ -72,12 +79,13 @@ public void setUp() throws Exception { } @Test - public void addingEnodeWithIp_andThenAddingSameEnodeWithHostname_shouldThrow() { + public void addingEnodeWithIp_andThenAddingSameEnodeWithHostname_shouldThrow() + throws IOException { node.verify(perm.addNodesToAllowlist(ENODE_LOCALHOST_IP)); node.verify( perm.expectPermissioningAllowlistFileKeyValue( - ALLOWLIST_TYPE.NODES, tempFile, ENODE_LOCALHOST_DNS)); + ALLOWLIST_TYPE.NODES, nodesConfigFile, ENODE_LOCALHOST_DNS)); // expect an exception when adding using hostname, since this node is already added with IP final Condition condition = perm.addNodesToAllowlist(ENODE_LOCALHOST_DNS); @@ -90,7 +98,7 @@ public void addingEnodeWithHostname_andThenAddingSameEnodeWithIp_shouldThrow() { node.verify(perm.addNodesToAllowlist(ENODE_LOCALHOST_DNS)); node.verify( perm.expectPermissioningAllowlistFileKeyValue( - ALLOWLIST_TYPE.NODES, tempFile, ENODE_LOCALHOST_DNS)); + ALLOWLIST_TYPE.NODES, nodesConfigFile, ENODE_LOCALHOST_DNS)); // expect an exception when adding using IP, since this node is already added with hostname final Condition condition = perm.addNodesToAllowlist(ENODE_LOCALHOST_IP); @@ -106,7 +114,7 @@ public void addingEnodeWithHostNameShouldWorkWhenDnsEnabled() { // With DNS enabled, the ENODE with the DNS hostname in it should remain as is. node.verify( perm.expectPermissioningAllowlistFileKeyValue( - ALLOWLIST_TYPE.NODES, tempFile, ENODE_LOCALHOST_DNS)); + ALLOWLIST_TYPE.NODES, nodesConfigFile, ENODE_LOCALHOST_DNS)); } @Test @@ -121,11 +129,11 @@ public void manipulatedNodesAllowlistWithHostnameShouldWorkWhenDnsEnabled() { final String enode2ResolvedToDns = enodeURL0.toString(); node.verify( perm.expectPermissioningAllowlistFileKeyValue( - ALLOWLIST_TYPE.NODES, tempFile, ENODE_LOCALHOST_DNS, enode2ResolvedToDns)); + ALLOWLIST_TYPE.NODES, nodesConfigFile, ENODE_LOCALHOST_DNS, enode2ResolvedToDns)); node.verify(perm.removeNodesFromAllowlist(ENODE_LOCALHOST_DNS)); node.verify( perm.expectPermissioningAllowlistFileKeyValue( - ALLOWLIST_TYPE.NODES, tempFile, enode2ResolvedToDns)); + ALLOWLIST_TYPE.NODES, nodesConfigFile, enode2ResolvedToDns)); } } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnchainPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnchainPermissioningAcceptanceTest.java index 6a7b8e9b35f..3dfdae528a8 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnchainPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnchainPermissioningAcceptanceTest.java @@ -16,8 +16,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeLocalAndOnchainPermissioningAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { @@ -27,7 +27,7 @@ public class NodeLocalAndOnchainPermissioningAcceptanceTest private Node allowedNode; private Node forbiddenNode; - @Before + @BeforeEach public void setUp() { bootnode = bootnode("bootnode"); forbiddenNode = node("forbidden-node"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalConfigPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalConfigPermissioningAcceptanceTest.java index 7d8128d66c7..d889abb9fbb 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalConfigPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalConfigPermissioningAcceptanceTest.java @@ -20,8 +20,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration; import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeLocalConfigPermissioningAcceptanceTest extends AcceptanceTestBase { @@ -31,7 +31,7 @@ public class NodeLocalConfigPermissioningAcceptanceTest extends AcceptanceTestBa private Node allowedNode; private Node permissionedNode; - @Before + @BeforeEach public void setUp() throws Exception { final ClusterConfiguration clusterConfiguration = new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java index c5fbb693043..95bece1eecb 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTest.java @@ -16,8 +16,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { @@ -27,7 +27,7 @@ public class NodeSmartContractPermissioningAcceptanceTest private Node allowedNode; private Node forbiddenNode; - @Before + @BeforeEach public void setUp() { bootnode = bootnode("bootnode"); forbiddenNode = node("forbidden-node"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningIbft2StallAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningIbft2StallAcceptanceTest.java index e9da331a9e3..ed48ad9db97 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningIbft2StallAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningIbft2StallAcceptanceTest.java @@ -22,7 +22,7 @@ import java.io.IOException; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningIbft2StallAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningOutOfSyncAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningOutOfSyncAcceptanceTest.java index 2f8adf43867..4315151473b 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningOutOfSyncAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningOutOfSyncAcceptanceTest.java @@ -16,8 +16,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningOutOfSyncAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { @@ -25,7 +25,7 @@ public class NodeSmartContractPermissioningOutOfSyncAcceptanceTest private Node permissionedNodeA; private Node permissionedNodeB; - @Before + @BeforeEach public void setUp() throws InterruptedException { bootnode = bootnode("bootnode"); permissionedNodeA = permissionedNode("permissioned-node-A"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java index 72aab9cb7e4..792d45fe98e 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2AcceptanceTest.java @@ -16,8 +16,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningV2AcceptanceTest extends NodeSmartContractPermissioningV2AcceptanceTestBase { @@ -27,7 +27,7 @@ public class NodeSmartContractPermissioningV2AcceptanceTest private Node allowedNode; private Node forbiddenNode; - @Before + @BeforeEach public void setUp() { bootnode = bootnode("bootnode"); forbiddenNode = node("forbidden-node"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2DNSAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2DNSAcceptanceTest.java index b2ed27d7c5d..7a55283e4f4 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2DNSAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningV2DNSAcceptanceTest.java @@ -24,8 +24,8 @@ import java.net.UnknownHostException; import org.assertj.core.api.Assertions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeSmartContractPermissioningV2DNSAcceptanceTest extends NodeSmartContractPermissioningV2AcceptanceTestBase { @@ -38,7 +38,7 @@ public class NodeSmartContractPermissioningV2DNSAcceptanceTest final ImmutableEnodeDnsConfiguration enodeDnsConfiguration = ImmutableEnodeDnsConfiguration.builder().dnsEnabled(true).updateEnabled(true).build(); - @Before + @BeforeEach public void setUp() { bootnode = bootnode("bootnode"); forbiddenNode = node("forbidden-node"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodesSmartContractPermissioningStaticNodesAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodesSmartContractPermissioningStaticNodesAcceptanceTest.java index 57253d474c2..4f516d1cda5 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodesSmartContractPermissioningStaticNodesAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodesSmartContractPermissioningStaticNodesAcceptanceTest.java @@ -24,8 +24,8 @@ import java.util.List; import javax.annotation.Nonnull; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodesSmartContractPermissioningStaticNodesAcceptanceTest extends NodeSmartContractPermissioningAcceptanceTestBase { @@ -33,7 +33,7 @@ public class NodesSmartContractPermissioningStaticNodesAcceptanceTest private Node miner; private Node permissionedNode; - @Before + @BeforeEach public void setUp() { miner = miner("miner"); permissionedCluster.start(miner); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/BftPrivacyClusterAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/BftPrivacyClusterAcceptanceTest.java index 2baf1d1f5ce..81aba5f8b26 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/BftPrivacyClusterAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/BftPrivacyClusterAcceptanceTest.java @@ -25,21 +25,18 @@ import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Optional; +import java.util.stream.Stream; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.containers.Network; import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; import org.web3j.utils.Restriction; -@RunWith(Parameterized.class) public class BftPrivacyClusterAcceptanceTest extends PrivacyAcceptanceTestBase { - private final BftPrivacyType bftPrivacyType; public static class BftPrivacyType { private final EnclaveType enclaveType; @@ -69,12 +66,7 @@ public String toString() { } } - public BftPrivacyClusterAcceptanceTest(final BftPrivacyType bftPrivacyType) { - this.bftPrivacyType = bftPrivacyType; - } - - @Parameterized.Parameters(name = "{0}") - public static Collection bftPrivacyTypes() { + public static Stream bftPrivacyTypes() { final List bftPrivacyTypes = new ArrayList<>(); for (EnclaveType x : EnclaveType.valuesForTests()) { for (ConsensusType consensusType : ConsensusType.values()) { @@ -95,26 +87,28 @@ public static Collection bftPrivacyTypes() { Restriction.UNRESTRICTED)); } - return bftPrivacyTypes; + return Stream.of(Arguments.of(bftPrivacyTypes)); } private PrivacyNode alice; private PrivacyNode bob; private PrivacyNode charlie; - @Before - public void setUp() throws Exception { + public void setUp(final BftPrivacyType bftPrivacyType) throws Exception { final Network containerNetwork = Network.newNetwork(); - alice = createNode(containerNetwork, "node1", 0); - bob = createNode(containerNetwork, "node2", 1); - charlie = createNode(containerNetwork, "node3", 2); + alice = createNode(bftPrivacyType, containerNetwork, "node1", 0); + bob = createNode(bftPrivacyType, containerNetwork, "node2", 1); + charlie = createNode(bftPrivacyType, containerNetwork, "node3", 2); privacyCluster.start(alice, bob, charlie); } private PrivacyNode createNode( - final Network containerNetwork, final String nodeName, final int privacyAccount) + final BftPrivacyType bftPrivacyType, + final Network containerNetwork, + final String nodeName, + final int privacyAccount) throws IOException { if (bftPrivacyType.consensusType == ConsensusType.IBFT2) { return privacyBesu.createIbft2NodePrivacyEnabled( @@ -144,8 +138,11 @@ private PrivacyNode createNode( } } - @Test - public void onlyAliceAndBobCanExecuteContract() { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("bftPrivacyTypes") + public void onlyAliceAndBobCanExecuteContract(final BftPrivacyType bftPrivacyType) + throws Exception { + setUp(bftPrivacyType); // Contract address is generated from sender address and transaction nonce final String contractAddress = EnclaveEncryptorType.EC.equals(bftPrivacyType.enclaveEncryptorType) @@ -186,8 +183,11 @@ public void onlyAliceAndBobCanExecuteContract() { } } - @Test - public void aliceCanDeployMultipleTimesInSingleGroup() { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("bftPrivacyTypes") + public void aliceCanDeployMultipleTimesInSingleGroup(final BftPrivacyType bftPrivacyType) + throws Exception { + setUp(bftPrivacyType); final String firstDeployedAddress = EnclaveEncryptorType.EC.equals(bftPrivacyType.enclaveEncryptorType) ? "0x3e5d325a03ad3ce5640502219833d30b89ce3ce1" @@ -225,8 +225,11 @@ public void aliceCanDeployMultipleTimesInSingleGroup() { .verify(secondEventEmitter); } - @Test - public void canInteractWithMultiplePrivacyGroups() { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("bftPrivacyTypes") + public void canInteractWithMultiplePrivacyGroups(final BftPrivacyType bftPrivacyType) + throws Exception { + setUp(bftPrivacyType); // alice deploys contract final String firstDeployedAddress = EnclaveEncryptorType.EC.equals(bftPrivacyType.enclaveEncryptorType) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/DeployPrivateSmartContractAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/DeployPrivateSmartContractAcceptanceTest.java index 71aa618cdd8..80ccbd97bef 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/DeployPrivateSmartContractAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/DeployPrivateSmartContractAcceptanceTest.java @@ -26,19 +26,19 @@ import java.io.IOException; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.web3j.utils.Restriction; public class DeployPrivateSmartContractAcceptanceTest extends ParameterizedEnclaveTestBase { - private final PrivacyNode minerNode; + private PrivacyNode minerNode; - public DeployPrivateSmartContractAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); minerNode = privacyBesu.createPrivateTransactionEnabledMinerNode( @@ -53,8 +53,14 @@ public DeployPrivateSmartContractAcceptanceTest( privacyCluster.start(minerNode); } - @Test - public void deployingMustGiveValidReceiptAndCode() throws Exception { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void deployingMustGiveValidReceiptAndCode( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final String contractAddress = EnclaveEncryptorType.EC.equals(enclaveEncryptorType) ? "0xfeeb2367e77e28f75fc3bcc55b70a535752db058" diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/EnclaveErrorAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/EnclaveErrorAcceptanceTest.java index 266284a498e..906cebf954c 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/EnclaveErrorAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/EnclaveErrorAcceptanceTest.java @@ -32,40 +32,31 @@ import java.math.BigInteger; import java.security.KeyPairGenerator; import java.security.spec.ECGenParameterSpec; -import java.util.Arrays; import java.util.Base64; -import java.util.Collection; import java.util.Optional; +import java.util.stream.Stream; import org.apache.tuweni.crypto.sodium.Box; import org.assertj.core.api.Condition; import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.containers.Network; import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; import org.web3j.utils.Restriction; -@RunWith(Parameterized.class) public class EnclaveErrorAcceptanceTest extends PrivacyAcceptanceTestBase { - private final PrivacyNode alice; - private final PrivacyNode bob; - private final String wrongPublicKey; - - @Parameters(name = "{0} enclave type with {1} encryptor") - public static Collection enclaveParameters() { - return Arrays.asList( - new Object[][] { - {TESSERA, NACL}, - {TESSERA, EC} - }); + private PrivacyNode alice; + private PrivacyNode bob; + private String wrongPublicKey; + + public static Stream enclaveParameters() { + return Stream.of(Arguments.of(TESSERA, NACL), Arguments.of(TESSERA, EC)); } - public EnclaveErrorAcceptanceTest( - final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + public void setUp(final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { final Network containerNetwork = Network.newNetwork(); @@ -102,8 +93,12 @@ public EnclaveErrorAcceptanceTest( wrongPublicKey = Base64.getEncoder().encodeToString(wrongPublicKeyBytes); } - @Test - public void aliceCannotSendTransactionFromBobNode() { + @ParameterizedTest(name = "{0} enclave type with {1} encryptor") + @MethodSource("enclaveParameters") + public void aliceCannotSendTransactionFromBobNode( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final Throwable throwable = catchThrowable( () -> @@ -119,8 +114,12 @@ public void aliceCannotSendTransactionFromBobNode() { RpcErrorType.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY.getMessage()); } - @Test - public void enclaveNoPeerUrlError() { + @ParameterizedTest(name = "{0} enclave type with {1} encryptor") + @MethodSource("enclaveParameters") + public void enclaveNoPeerUrlError( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final Throwable throwable = catchThrowable( () -> @@ -136,8 +135,12 @@ public void enclaveNoPeerUrlError() { assertThat(throwable.getMessage()).has(matchTesseraEnclaveMessage(tesseraMessage)); } - @Test - public void whenEnclaveIsDisconnectedGetReceiptReturnsInternalError() { + @ParameterizedTest(name = "{0} enclave type with {1} encryptor") + @MethodSource("enclaveParameters") + public void whenEnclaveIsDisconnectedGetReceiptReturnsInternalError( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final EventEmitter eventEmitter = alice.execute( privateContractTransactions.createSmartContract( @@ -174,9 +177,13 @@ public void whenEnclaveIsDisconnectedGetReceiptReturnsInternalError() { privateTransactionVerifier.internalErrorPrivateTransactionReceipt(transactionHash)); } - @Test + @ParameterizedTest(name = "{0} enclave type with {1} encryptor") + @MethodSource("enclaveParameters") @Ignore("Web3J is broken by PR #1426") - public void transactionFailsIfPartyIsOffline() { + public void transactionFailsIfPartyIsOffline( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); // Contract address is generated from sender address and transaction nonce final String contractAddress = "0xebf56429e6500e84442467292183d4d621359838"; @@ -209,8 +216,12 @@ public void transactionFailsIfPartyIsOffline() { assertThat(throwable).hasMessageContaining("NodePropagatingToAllPeers"); } - @Test - public void createPrivacyGroupReturnsCorrectError() { + @ParameterizedTest(name = "{0} enclave type with {1} encryptor") + @MethodSource("enclaveParameters") + public void createPrivacyGroupReturnsCorrectError( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final Throwable throwable = catchThrowable(() -> alice.execute(privacyTransactions.createPrivacyGroup(null, null))); final String tesseraMessage = RpcErrorType.TESSERA_CREATE_GROUP_INCLUDE_SELF.getMessage(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTest.java index 3f32904ba76..e93b1f1d55e 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTest.java @@ -20,7 +20,6 @@ import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.EC; import static org.hyperledger.enclave.testutil.EnclaveEncryptorType.NACL; import static org.hyperledger.enclave.testutil.EnclaveType.TESSERA; -import static org.junit.runners.Parameterized.Parameters; import org.hyperledger.besu.tests.acceptance.dsl.condition.eth.EthConditions; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; @@ -32,18 +31,17 @@ import java.math.BigInteger; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Supplier; +import java.util.stream.Stream; import com.google.common.collect.Lists; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.containers.Network; import org.web3j.crypto.Credentials; import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; @@ -52,25 +50,10 @@ import org.web3j.protocol.core.methods.response.TransactionReceipt; import org.web3j.tx.Contract; -@RunWith(Parameterized.class) public class FlexiblePrivacyAcceptanceTest extends FlexiblePrivacyAcceptanceTestBase { - private final EnclaveType enclaveType; - private final EnclaveEncryptorType enclaveEncryptorType; - - public FlexiblePrivacyAcceptanceTest( - final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) { - this.enclaveType = enclaveType; - this.enclaveEncryptorType = enclaveEncryptorType; - } - - @Parameters(name = "{0} enclave type with {1} encryptor") - public static Collection enclaveParameters() { - return Arrays.asList( - new Object[][] { - {TESSERA, NACL}, - {TESSERA, EC} - }); + public static Stream enclaveParameters() { + return Stream.of(Arguments.of(TESSERA, NACL), Arguments.of(TESSERA, EC)); } private PrivacyNode alice; @@ -85,8 +68,8 @@ public static Collection enclaveParameters() { private static final String EXPECTED_STORE_EVENT_TOPIC = "0xc9db20adedc6cf2b5d25252b101ab03e124902a73fcb12b753f3d1aaa2d8f9f5"; - @Before - public void setUp() throws Exception { + public void setUp(final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { final Network containerNetwork = Network.newNetwork(); alice = @@ -113,14 +96,22 @@ public void setUp() throws Exception { privacyCluster.start(alice, bob, charlie); } - @Test - public void nodeCanCreatePrivacyGroup() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void nodeCanCreatePrivacyGroup( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = createFlexiblePrivacyGroup(alice); checkFlexiblePrivacyGroupExists(privacyGroupId, alice); } - @Test - public void deployingMustGiveValidReceipt() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void deployingMustGiveValidReceipt( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob); final Contract eventEmitter = deployPrivateContract(EventEmitter.class, privacyGroupId, alice); final String commitmentHash = getContractDeploymentCommitmentHash(eventEmitter); @@ -129,8 +120,12 @@ public void deployingMustGiveValidReceipt() { bob.verify(privateTransactionVerifier.existingPrivateTransactionReceipt(commitmentHash)); } - @Test - public void canAddParticipantToGroup() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void canAddParticipantToGroup( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob); final Contract eventEmitter = deployPrivateContract(EventEmitter.class, privacyGroupId, alice); final String commitmentHash = getContractDeploymentCommitmentHash(eventEmitter); @@ -145,8 +140,12 @@ public void canAddParticipantToGroup() { charlie.verify(privateTransactionVerifier.existingPrivateTransactionReceipt(commitmentHash)); } - @Test - public void removedMemberCannotSendTransactionToGroup() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void removedMemberCannotSendTransactionToGroup( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob); final String removeHash = @@ -160,8 +159,12 @@ public void removedMemberCannotSendTransactionToGroup() { .hasMessageContaining("Flexible Privacy group does not exist."); } - @Test - public void canInteractWithPrivateGenesisPreCompile() throws Exception { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void canInteractWithPrivateGenesisPreCompile( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = createFlexiblePrivacyGroup(alice, bob); final EventEmitter eventEmitter = @@ -205,8 +208,12 @@ public void canInteractWithPrivateGenesisPreCompile() throws Exception { assertThat(charlieResponse).isEqualTo("0x"); } - @Test - public void memberCanBeAddedAfterBeingRemoved() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void memberCanBeAddedAfterBeingRemoved( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = createFlexiblePrivacyGroup(alice); checkFlexiblePrivacyGroupExists(privacyGroupId, alice); @@ -321,8 +328,12 @@ private void checkEmitterValue( } } - @Test - public void bobCanAddCharlieAfterBeingAddedByAlice() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void bobCanAddCharlieAfterBeingAddedByAlice( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = createFlexiblePrivacyGroup(alice); checkFlexiblePrivacyGroupExists(privacyGroupId, alice); final EventEmitter eventEmitter = @@ -487,8 +498,12 @@ public void bobCanAddCharlieAfterBeingAddedByAlice() { checkFlexiblePrivacyGroupExists(privacyGroupId, alice, bob); } - @Test - public void canOnlyCallProxyContractWhenGroupLocked() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void canOnlyCallProxyContractWhenGroupLocked( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = createFlexiblePrivacyGroup(alice); checkFlexiblePrivacyGroupExists(privacyGroupId, alice); @@ -552,8 +567,12 @@ public void canOnlyCallProxyContractWhenGroupLocked() { assertThatTransactionReceiptIs.accept(callAfterUnlockedHash, "0x1"); } - @Test - public void addMembersToTwoGroupsInTheSameBlock() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void addMembersToTwoGroupsInTheSameBlock( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId1 = createFlexiblePrivacyGroup(alice); final String privacyGroupId2 = createFlexiblePrivacyGroup(bob); checkFlexiblePrivacyGroupExists(privacyGroupId1, alice); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTestBase.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTestBase.java index 9e4f1638dad..8308e31c4b7 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTestBase.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/FlexiblePrivacyAcceptanceTestBase.java @@ -49,7 +49,7 @@ protected String createFlexiblePrivacyGroup(final PrivacyNode... members) { } /** - * Create an flexible privacy group. The privacy group id will be randomly generated. + * Create a flexible privacy group. The privacy group id will be randomly generated. * *

This method also checks that each node member has successfully processed the transaction and * has the expected list of member for the group. diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PluginPrivacySigningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PluginPrivacySigningAcceptanceTest.java index 68d5117fd6b..fd34bd8d4d1 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PluginPrivacySigningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PluginPrivacySigningAcceptanceTest.java @@ -29,40 +29,28 @@ import java.io.IOException; import java.math.BigInteger; -import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; +import java.util.stream.Stream; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.web3j.protocol.core.DefaultBlockParameter; import org.web3j.protocol.core.methods.response.EthBlock.Block; import org.web3j.protocol.core.methods.response.TransactionReceipt; -@RunWith(Parameterized.class) public class PluginPrivacySigningAcceptanceTest extends PrivacyAcceptanceTestBase { private PrivacyNode minerNode; - private final EnclaveEncryptorType enclaveEncryptorType; - - public PluginPrivacySigningAcceptanceTest(final EnclaveEncryptorType enclaveEncryptorType) { - this.enclaveEncryptorType = enclaveEncryptorType; - } - - @Parameterized.Parameters(name = "{0}") - public static Collection enclaveEncryptorTypes() { - return Arrays.stream(EnclaveEncryptorType.values()) + public static Stream enclaveEncryptorTypes() { + return Stream.of(EnclaveEncryptorType.values()) .filter(encryptorType -> !EnclaveEncryptorType.NOOP.equals(encryptorType)) - .collect(Collectors.toList()); + .map(Arguments::of); } - @Before - public void setup() throws IOException { + public void setup(final EnclaveEncryptorType enclaveEncryptorType) throws IOException { final PrivacyAccount BOB = PrivacyAccountResolver.BOB.resolve(enclaveEncryptorType); minerNode = @@ -95,8 +83,11 @@ public void setup() throws IOException { privacyCluster.start(minerNode); } - @Test - public void canDeployContractSignedByPlugin() throws Exception { + @ParameterizedTest(name = "{0} encryptor type") + @MethodSource("enclaveEncryptorTypes") + public void canDeployContractSignedByPlugin(final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setup(enclaveEncryptorType); final String contractAddress = EnclaveEncryptorType.EC.equals(enclaveEncryptorType) ? "0xf01ec73d91fdeb8bb9388ec74e6a3981da86e021" diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java index bb5e829dc5a..c4de9ba1cad 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivCallAcceptanceTest.java @@ -36,7 +36,8 @@ import javax.annotation.Nonnull; import org.bouncycastle.util.encoders.Hex; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.web3j.abi.FunctionEncoder; import org.web3j.abi.TypeReference; import org.web3j.abi.datatypes.Bool; @@ -55,16 +56,14 @@ public class PrivCallAcceptanceTest extends ParameterizedEnclaveTestBase { private static final int VALUE = 1024; - private final PrivacyNode minerNode; + private PrivacyNode minerNode; - public PrivCallAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); - minerNode = privacyBesu.createPrivateTransactionEnabledMinerNode( restriction + "-node", @@ -78,11 +77,18 @@ public PrivCallAcceptanceTest( privacyCluster.start(minerNode); } - @Test - public void mustReturnCorrectValue() throws Exception { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void mustReturnCorrectValue( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final String privacyGroupId = - minerNode.execute(createPrivacyGroup("myGroupName", "my group description", minerNode)); + minerNode.execute( + createPrivacyGroup(restriction, "myGroupName", "my group description", minerNode)); final EventEmitter eventEmitter = minerNode.execute( @@ -115,11 +121,18 @@ public void mustReturnCorrectValue() throws Exception { .isEqualByComparingTo(BigInteger.valueOf(VALUE)); } - @Test - public void mustRevertWithRevertReason() throws Exception { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("enclaveParameters") + public void mustRevertWithRevertReason( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final String privacyGroupId = - minerNode.execute(createPrivacyGroup("myGroupName", "my group description", minerNode)); + minerNode.execute( + createPrivacyGroup(restriction, "myGroupName", "my group description", minerNode)); final RevertReason revertReasonContract = minerNode.execute( @@ -147,11 +160,18 @@ public void mustRevertWithRevertReason() throws Exception { assertThat(revertMessage).isEqualTo("RevertReason"); } - @Test - public void shouldReturnEmptyResultWithNonExistingPrivacyGroup() throws IOException { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("enclaveParameters") + public void shouldReturnEmptyResultWithNonExistingPrivacyGroup( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final String privacyGroupId = - minerNode.execute(createPrivacyGroup("myGroupName", "my group description", minerNode)); + minerNode.execute( + createPrivacyGroup(restriction, "myGroupName", "my group description", minerNode)); final EventEmitter eventEmitter = minerNode.execute( @@ -176,11 +196,18 @@ public void shouldReturnEmptyResultWithNonExistingPrivacyGroup() throws IOExcept assertThat(result.getResult()).isEqualTo("0x"); } - @Test - public void mustNotSucceedWithWronglyEncodedFunction() throws IOException { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("enclaveParameters") + public void mustNotSucceedWithWronglyEncodedFunction( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final String privacyGroupId = - minerNode.execute(createPrivacyGroup("myGroupName", "my group description", minerNode)); + minerNode.execute( + createPrivacyGroup(restriction, "myGroupName", "my group description", minerNode)); final EventEmitter eventEmitter = minerNode.execute( @@ -203,11 +230,18 @@ public void mustNotSucceedWithWronglyEncodedFunction() throws IOException { assertThat(errorMessage).isEqualTo("Private transaction failed"); } - @Test - public void mustReturn0xUsingInvalidContractAddress() throws IOException { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("enclaveParameters") + public void mustReturn0xUsingInvalidContractAddress( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final String privacyGroupId = - minerNode.execute(createPrivacyGroup("myGroupName", "my group description", minerNode)); + minerNode.execute( + createPrivacyGroup(restriction, "myGroupName", "my group description", minerNode)); final EventEmitter eventEmitter = minerNode.execute( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootFlexibleGroupAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootFlexibleGroupAcceptanceTest.java index 59973fd00be..d178e0ec658 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootFlexibleGroupAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootFlexibleGroupAcceptanceTest.java @@ -31,14 +31,10 @@ import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.testcontainers.containers.Network; -@RunWith(Parameterized.class) public class PrivDebugGetStateRootFlexibleGroupAcceptanceTest extends FlexiblePrivacyAcceptanceTestBase { @@ -48,7 +44,6 @@ public PrivDebugGetStateRootFlexibleGroupAcceptanceTest(final EnclaveType enclav this.enclaveType = enclaveType; } - @Parameters(name = "{0}") public static Collection enclaveTypes() { return EnclaveType.valuesForTests(); } @@ -56,7 +51,7 @@ public static Collection enclaveTypes() { private PrivacyNode aliceNode; private PrivacyNode bobNode; - @Before + @BeforeEach public void setUp() throws IOException, URISyntaxException { final Network containerNetwork = Network.newNetwork(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootOffchainGroupAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootOffchainGroupAcceptanceTest.java index 92643446ddb..e14eec5befa 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootOffchainGroupAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivDebugGetStateRootOffchainGroupAcceptanceTest.java @@ -29,23 +29,23 @@ import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.containers.Network; import org.web3j.utils.Restriction; public class PrivDebugGetStateRootOffchainGroupAcceptanceTest extends ParameterizedEnclaveTestBase { - private final PrivacyNode aliceNode; - private final PrivacyNode bobNode; + private PrivacyNode aliceNode; + private PrivacyNode bobNode; - public PrivDebugGetStateRootOffchainGroupAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); - final Network containerNetwork = Network.newNetwork(); aliceNode = @@ -74,11 +74,18 @@ public PrivDebugGetStateRootOffchainGroupAcceptanceTest( privacyCluster.start(aliceNode, bobNode); } - @Test - public void nodesInGroupShouldHaveSameStateRoot() { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void nodesInGroupShouldHaveSameStateRoot( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final String privacyGroupId = aliceNode.execute( - createPrivacyGroup("testGroup", "A group for everyone", aliceNode, bobNode)); + createPrivacyGroup( + restriction, "testGroup", "A group for everyone", aliceNode, bobNode)); final Hash aliceStateRootId = aliceNode @@ -94,7 +101,12 @@ public void nodesInGroupShouldHaveSameStateRoot() { } @Test - public void unknownGroupShouldReturnError() { + public void unknownGroupShouldReturnError( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); if (restriction != UNRESTRICTED) { final PrivacyRequestFactory.DebugGetStateRoot aliceResult = aliceNode.execute( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetCodeAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetCodeAcceptanceTest.java index c08006f694b..1ba482b46ad 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetCodeAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetCodeAcceptanceTest.java @@ -29,21 +29,20 @@ import java.util.Optional; import org.apache.tuweni.bytes.Bytes; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.web3j.utils.Restriction; public class PrivGetCodeAcceptanceTest extends ParameterizedEnclaveTestBase { - private final PrivacyNode alice; + private PrivacyNode alice; - public PrivGetCodeAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); - alice = privacyBesu.createPrivateTransactionEnabledMinerNode( restriction + "-node", @@ -57,10 +56,16 @@ public PrivGetCodeAcceptanceTest( privacyCluster.start(alice); } - @Test - public void privGetCodeReturnsDeployedContractBytecode() { - final String privacyGroupId = createPrivacyGroup(); - final EventEmitter eventEmitterContract = deployPrivateContract(privacyGroupId); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void privGetCodeReturnsDeployedContractBytecode( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final String privacyGroupId = createPrivacyGroup(restriction); + final EventEmitter eventEmitterContract = deployPrivateContract(restriction, privacyGroupId); final Bytes deployedContractCode = alice.execute( @@ -73,7 +78,8 @@ public void privGetCodeReturnsDeployedContractBytecode() { .contains(deployedContractCode.toUnprefixedHexString()); } - private EventEmitter deployPrivateContract(final String privacyGroupId) { + private EventEmitter deployPrivateContract( + final Restriction restriction, final String privacyGroupId) { final EventEmitter eventEmitter = alice.execute( privateContractTransactions.createSmartContractWithPrivacyGroupId( @@ -90,9 +96,10 @@ private EventEmitter deployPrivateContract(final String privacyGroupId) { return eventEmitter; } - private String createPrivacyGroup() { + private String createPrivacyGroup(final Restriction restriction) { final String privacyGroupId = - alice.execute(createPrivacyGroup("myGroupName", "my group description", alice)); + alice.execute( + createPrivacyGroup(restriction, "myGroupName", "my group description", alice)); assertThat(privacyGroupId).isNotNull(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetLogsAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetLogsAcceptanceTest.java index 62519385a2e..dfd885ce53a 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetLogsAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetLogsAcceptanceTest.java @@ -30,7 +30,8 @@ import java.util.List; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; import org.web3j.protocol.core.methods.response.EthLog.LogResult; import org.web3j.utils.Restriction; @@ -44,16 +45,14 @@ public class PrivGetLogsAcceptanceTest extends ParameterizedEnclaveTestBase { private static final String EVENT_EMITTER_EVENT_TOPIC = "0xc9db20adedc6cf2b5d25252b101ab03e124902a73fcb12b753f3d1aaa2d8f9f5"; - private final PrivacyNode node; + private PrivacyNode node; - public PrivGetLogsAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); - node = privacyBesu.createPrivateTransactionEnabledMinerNode( restriction + "-node", @@ -67,16 +66,23 @@ public PrivGetLogsAcceptanceTest( privacyCluster.start(node); } - @Test - public void getLogsUsingBlockRangeFilter() { - final String privacyGroupId = createPrivacyGroup(); - final EventEmitter eventEmitterContract = deployEventEmitterContract(privacyGroupId); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void getLogsUsingBlockRangeFilter( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final String privacyGroupId = createPrivacyGroup(restriction); + final EventEmitter eventEmitterContract = + deployEventEmitterContract(restriction, privacyGroupId); /* Updating the contract value 2 times */ - updateContractValue(privacyGroupId, eventEmitterContract, 1); - updateContractValue(privacyGroupId, eventEmitterContract, 2); + updateContractValue(restriction, privacyGroupId, eventEmitterContract, 1); + updateContractValue(restriction, privacyGroupId, eventEmitterContract, 2); final LogFilterJsonParameter filter = blockRangeLogFilter("earliest", "latest", eventEmitterContract.getContractAddress()); @@ -90,16 +96,23 @@ public void getLogsUsingBlockRangeFilter() { assertThat(logs).hasSize(2); } - @Test - public void getLogsUsingBlockHashFilter() { - final String privacyGroupId = createPrivacyGroup(); - final EventEmitter eventEmitterContract = deployEventEmitterContract(privacyGroupId); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void getLogsUsingBlockHashFilter( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final String privacyGroupId = createPrivacyGroup(restriction); + final EventEmitter eventEmitterContract = + deployEventEmitterContract(restriction, privacyGroupId); /* Updating the contract value 1 times */ final PrivateTransactionReceipt updateValueReceipt = - updateContractValue(privacyGroupId, eventEmitterContract, 1); + updateContractValue(restriction, privacyGroupId, eventEmitterContract, 1); final String blockHash = updateValueReceipt.getBlockHash(); final LogFilterJsonParameter filter = @@ -131,11 +144,13 @@ private LogFilterJsonParameter blockHashLogFilter( blockHash); } - private String createPrivacyGroup() { - return node.execute(createPrivacyGroup("myGroupName", "my group description", node)); + private String createPrivacyGroup(final Restriction restriction) { + return node.execute( + createPrivacyGroup(restriction, "myGroupName", "my group description", node)); } - private EventEmitter deployEventEmitterContract(final String privacyGroupId) { + private EventEmitter deployEventEmitterContract( + final Restriction restriction, final String privacyGroupId) { final EventEmitter eventEmitter = node.execute( privateContractTransactions.createSmartContractWithPrivacyGroupId( @@ -154,7 +169,10 @@ private EventEmitter deployEventEmitterContract(final String privacyGroupId) { } private PrivateTransactionReceipt updateContractValue( - final String privacyGroupId, final EventEmitter eventEmitterContract, final int value) { + final Restriction restriction, + final String privacyGroupId, + final EventEmitter eventEmitterContract, + final int value) { final String transactionHash = node.execute( privateContractTransactions.callSmartContractWithPrivacyGroupId( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetPrivateTransactionAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetPrivateTransactionAcceptanceTest.java index 91896761d09..a24a46a2aeb 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetPrivateTransactionAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivGetPrivateTransactionAcceptanceTest.java @@ -32,23 +32,22 @@ import java.util.Optional; import org.apache.tuweni.bytes.Bytes; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.containers.Network; import org.web3j.utils.Restriction; public class PrivGetPrivateTransactionAcceptanceTest extends ParameterizedEnclaveTestBase { - private final PrivacyNode alice; - private final PrivacyNode bob; + private PrivacyNode alice; + private PrivacyNode bob; - public PrivGetPrivateTransactionAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); - final Network containerNetwork = Network.newNetwork(); alice = @@ -77,14 +76,20 @@ public PrivGetPrivateTransactionAcceptanceTest( privacyCluster.start(alice, bob); } - @Test - public void returnsTransaction() { - final Transaction onlyAlice = createPrivacyGroup("Only Alice", "", alice); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void returnsTransaction( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final Transaction onlyAlice = createPrivacyGroup(restriction, "Only Alice", "", alice); final String privacyGroupId = alice.execute(onlyAlice); final PrivateTransaction validSignedPrivateTransaction = - getValidSignedPrivateTransaction(alice, privacyGroupId); + getValidSignedPrivateTransaction(restriction, alice, privacyGroupId); final BytesValueRLPOutput rlpOutput = getRLPOutput(validSignedPrivateTransaction); final Hash transactionHash = @@ -97,19 +102,31 @@ public void returnsTransaction() { .verify(priv.getPrivateTransaction(transactionHash, validSignedPrivateTransaction)); } - @Test - public void nonExistentHashReturnsNull() { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void nonExistentHashReturnsNull( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); alice.getBesu().verify(priv.getPrivateTransactionReturnsNull(Hash.ZERO)); } - @Test - public void returnsNullTransactionNotInNodesPrivacyGroup() { - final Transaction onlyAlice = createPrivacyGroup("Only Alice", "", alice); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void returnsNullTransactionNotInNodesPrivacyGroup( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final Transaction onlyAlice = createPrivacyGroup(restriction, "Only Alice", "", alice); final String privacyGroupId = alice.execute(onlyAlice); final PrivateTransaction validSignedPrivateTransaction = - getValidSignedPrivateTransaction(alice, privacyGroupId); + getValidSignedPrivateTransaction(restriction, alice, privacyGroupId); final BytesValueRLPOutput rlpOutput = getRLPOutput(validSignedPrivateTransaction); final Hash transactionHash = @@ -127,7 +144,7 @@ private BytesValueRLPOutput getRLPOutput(final PrivateTransaction privateTransac } private PrivateTransaction getValidSignedPrivateTransaction( - final PrivacyNode node, final String privacyGoupId) { + final Restriction restriction, final PrivacyNode node, final String privacyGoupId) { org.hyperledger.besu.plugin.data.Restriction besuRestriction = restriction == RESTRICTED diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyClusterAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyClusterAcceptanceTest.java index 1284daf917e..c372c02ad96 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyClusterAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyClusterAcceptanceTest.java @@ -34,18 +34,16 @@ import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.Optional; +import java.util.stream.Stream; import io.vertx.core.Vertx; import org.apache.tuweni.bytes.Bytes; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.containers.Network; import org.web3j.crypto.Credentials; import org.web3j.crypto.RawTransaction; @@ -56,29 +54,20 @@ import org.web3j.utils.Base64String; import org.web3j.utils.Numeric; -@RunWith(Parameterized.class) public class PrivacyClusterAcceptanceTest extends PrivacyAcceptanceTestBase { - private final PrivacyNode alice; - private final PrivacyNode bob; - private final PrivacyNode charlie; - private final EnclaveEncryptorType enclaveEncryptorType; + private PrivacyNode alice; + private PrivacyNode bob; + private PrivacyNode charlie; private final Vertx vertx = Vertx.vertx(); private final EnclaveFactory enclaveFactory = new EnclaveFactory(vertx); - @Parameters(name = "{0} enclave type with {1} encryptor") - public static Collection enclaveParameters() { - return Arrays.asList( - new Object[][] { - {TESSERA, NACL}, - {TESSERA, EC} - }); + public static Stream enclaveParameters() { + return Stream.of(Arguments.of(TESSERA, NACL), Arguments.of(TESSERA, EC)); } - public PrivacyClusterAcceptanceTest( - final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + public void setUp(final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - this.enclaveEncryptorType = enclaveEncryptorType; final Network containerNetwork = Network.newNetwork(); alice = privacyBesu.createPrivateTransactionEnabledMinerNode( @@ -110,13 +99,17 @@ public PrivacyClusterAcceptanceTest( privacyCluster.start(alice, bob, charlie); } - @After + @AfterEach public void cleanUp() { vertx.close(); } - @Test - public void onlyAliceAndBobCanExecuteContract() { + @ParameterizedTest(name = "{0} enclave type with {1} encryptor") + @MethodSource("enclaveParameters") + public void onlyAliceAndBobCanExecuteContract( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); // Contract address is generated from sender address and transaction nonce final String contractAddress = EnclaveEncryptorType.EC.equals(enclaveEncryptorType) @@ -176,8 +169,12 @@ public void onlyAliceAndBobCanExecuteContract() { transactionHash2, expectedReceipt2)); } - @Test - public void aliceCanUsePrivDistributeTransaction() { + @ParameterizedTest(name = "{0} enclave type with {1} encryptor") + @MethodSource("enclaveParameters") + public void aliceCanUsePrivDistributeTransaction( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); // Contract address is generated from sender address and transaction nonce final String contractAddress = EnclaveEncryptorType.EC.equals(enclaveEncryptorType) @@ -277,8 +274,12 @@ public void aliceCanUsePrivDistributeTransaction() { assertThat(EventEmitter.BINARY).contains(bobPrivateTransactionReceipt.getOutput().substring(2)); } - @Test - public void aliceCanDeployMultipleTimesInSingleGroup() { + @ParameterizedTest(name = "{0} enclave type with {1} encryptor") + @MethodSource("enclaveParameters") + public void aliceCanDeployMultipleTimesInSingleGroup( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String firstDeployedAddress = EnclaveEncryptorType.EC.equals(enclaveEncryptorType) ? "0x3e5d325a03ad3ce5640502219833d30b89ce3ce1" @@ -314,8 +315,12 @@ public void aliceCanDeployMultipleTimesInSingleGroup() { .verify(secondEventEmitter); } - @Test - public void canInteractWithMultiplePrivacyGroups() { + @ParameterizedTest(name = "{0} enclave type with {1} encryptor") + @MethodSource("enclaveParameters") + public void canInteractWithMultiplePrivacyGroups( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); // alice deploys contract final String firstDeployedAddress = EnclaveEncryptorType.EC.equals(enclaveEncryptorType) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyGroupAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyGroupAcceptanceTest.java index a1739b1fc8d..2b32fd4ad68 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyGroupAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyGroupAcceptanceTest.java @@ -30,37 +30,30 @@ import java.io.IOException; import java.math.BigInteger; -import java.util.Arrays; -import java.util.Collection; import java.util.Optional; +import java.util.stream.Stream; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.junit.runners.Parameterized.Parameters; import org.testcontainers.containers.Network; import org.web3j.protocol.besu.response.privacy.PrivacyGroup; import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; import org.web3j.utils.Base64String; -@RunWith(Parameterized.class) public class PrivacyGroupAcceptanceTest extends PrivacyAcceptanceTestBase { - private final PrivacyNode alice; - private final PrivacyNode bob; - private final PrivacyNode charlie; + private PrivacyNode alice; + private PrivacyNode bob; + private PrivacyNode charlie; @Parameters(name = "{0} enclave type with {1} encryptor") - public static Collection enclaveParameters() { - return Arrays.asList( - new Object[][] { - {TESSERA, NACL}, - {TESSERA, EC} - }); + public static Stream enclaveParameters() { + return Stream.of(Arguments.of(TESSERA, NACL), Arguments.of(TESSERA, EC)); } - public PrivacyGroupAcceptanceTest( - final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + public void setUp(final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { final Network containerNetwork = Network.newNetwork(); @@ -96,8 +89,12 @@ public PrivacyGroupAcceptanceTest( privacyCluster.start(alice, bob, charlie); } - @Test - public void nodeCanCreatePrivacyGroup() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void nodeCanCreatePrivacyGroup( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); LogConfigurator.setLevel("", "DEBUG"); final String privacyGroupId = alice.execute( @@ -119,8 +116,12 @@ public void nodeCanCreatePrivacyGroup() { bob.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected)); } - @Test - public void nodeCanCreatePrivacyGroupWithoutName() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void nodeCanCreatePrivacyGroupWithoutName( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = alice.execute( privacyTransactions.createPrivacyGroup(null, "my group description", alice, bob)); @@ -140,8 +141,12 @@ public void nodeCanCreatePrivacyGroupWithoutName() { bob.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected)); } - @Test - public void nodeCanCreatePrivacyGroupWithoutDescription() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void nodeCanCreatePrivacyGroupWithoutDescription( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = alice.execute(privacyTransactions.createPrivacyGroup("myGroupName", null, alice, bob)); @@ -160,8 +165,12 @@ public void nodeCanCreatePrivacyGroupWithoutDescription() { bob.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected)); } - @Test - public void nodeCanCreatePrivacyGroupWithoutOptionalParams() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void nodeCanCreatePrivacyGroupWithoutOptionalParams( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupId = alice.execute(privacyTransactions.createPrivacyGroup(null, null, alice)); @@ -178,8 +187,12 @@ public void nodeCanCreatePrivacyGroupWithoutOptionalParams() { alice.verify(privateTransactionVerifier.validPrivacyGroupCreated(expected)); } - @Test - public void canInteractWithMultiplePrivacyGroups() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void canInteractWithMultiplePrivacyGroups( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final String privacyGroupIdABC = alice.execute(privacyTransactions.createPrivacyGroup(null, null, alice, bob, charlie)); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyReceiptAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyReceiptAcceptanceTest.java index 0b45d29732a..73f71066596 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyReceiptAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivacyReceiptAcceptanceTest.java @@ -34,20 +34,20 @@ import java.util.Optional; import org.apache.tuweni.bytes.Bytes; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.web3j.utils.Restriction; public class PrivacyReceiptAcceptanceTest extends ParameterizedEnclaveTestBase { final MinerTransactions minerTransactions = new MinerTransactions(); - private final PrivacyNode alice; + private PrivacyNode alice; - public PrivacyReceiptAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); alice = privacyBesu.createIbft2NodePrivacyEnabled( @@ -63,14 +63,20 @@ public PrivacyReceiptAcceptanceTest( privacyCluster.start(alice); } - @Test - public void createPrivateTransactionReceiptSuccessfulTransaction() { - final Transaction onlyAlice = createPrivacyGroup("Only Alice", "", alice); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void createPrivateTransactionReceiptSuccessfulTransaction( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final Transaction onlyAlice = createPrivacyGroup(restriction, "Only Alice", "", alice); final String privacyGroupId = alice.execute(onlyAlice); final PrivateTransaction validTransaction = - createSignedTransaction(alice, privacyGroupId, empty()); + createSignedTransaction(restriction, alice, privacyGroupId, empty()); final BytesValueRLPOutput rlpOutput = getRLPOutput(validTransaction); final Hash transactionHash = @@ -82,15 +88,24 @@ public void createPrivateTransactionReceiptSuccessfulTransaction() { alice.getBesu().verify(priv.getSuccessfulTransactionReceipt(transactionHash)); } - @Test - public void createPrivateTransactionReceiptFailedTransaction() { - final Transaction onlyAlice = createPrivacyGroup("Only Alice", "", alice); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void createPrivateTransactionReceiptFailedTransaction( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final Transaction onlyAlice = createPrivacyGroup(restriction, "Only Alice", "", alice); final String privacyGroupId = alice.execute(onlyAlice); final PrivateTransaction invalidPayloadTransaction = createSignedTransaction( - alice, privacyGroupId, Optional.of(Bytes.fromBase64String("invalidPayload"))); + restriction, + alice, + privacyGroupId, + Optional.of(Bytes.fromBase64String("invalidPayload"))); final BytesValueRLPOutput rlpOutput = getRLPOutput(invalidPayloadTransaction); final Hash transactionHash = @@ -102,14 +117,20 @@ public void createPrivateTransactionReceiptFailedTransaction() { alice.getBesu().verify(priv.getFailedTransactionReceipt(transactionHash)); } - @Test - public void createPrivateTransactionReceiptInvalidTransaction() { - final Transaction onlyAlice = createPrivacyGroup("Only Alice", "", alice); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void createPrivateTransactionReceiptInvalidTransaction( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final Transaction onlyAlice = createPrivacyGroup(restriction, "Only Alice", "", alice); final String privacyGroupId = alice.execute(onlyAlice); final PrivateTransaction validTransaction = - createSignedTransaction(alice, privacyGroupId, empty()); + createSignedTransaction(restriction, alice, privacyGroupId, empty()); final BytesValueRLPOutput rlpOutput = getRLPOutput(validTransaction); // Stop mining, to allow adding duplicate nonce block @@ -139,7 +160,10 @@ private BytesValueRLPOutput getRLPOutput(final PrivateTransaction privateTransac } private PrivateTransaction createSignedTransaction( - final PrivacyNode node, final String privacyGoupId, final Optional payload) { + final Restriction restriction, + final PrivacyNode node, + final String privacyGoupId, + final Optional payload) { org.hyperledger.besu.plugin.data.Restriction besuRestriction = restriction == RESTRICTED diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateContractPublicStateAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateContractPublicStateAcceptanceTest.java index 83a7ce66d8b..e0b4f2555ba 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateContractPublicStateAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateContractPublicStateAcceptanceTest.java @@ -33,7 +33,8 @@ import java.math.BigInteger; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.testcontainers.containers.Network; import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; import org.web3j.protocol.core.RemoteFunctionCall; @@ -44,14 +45,13 @@ public class PrivateContractPublicStateAcceptanceTest extends ParameterizedEnclaveTestBase { - private final PrivacyNode transactionNode; + private PrivacyNode transactionNode; - public PrivateContractPublicStateAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); final Network containerNetwork = Network.newNetwork(); final PrivacyNode minerNode = @@ -77,8 +77,14 @@ public PrivateContractPublicStateAcceptanceTest( privacyCluster.start(minerNode, transactionNode); } - @Test - public void mustAllowAccessToPublicStateFromPrivateTx() throws Exception { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void mustAllowAccessToPublicStateFromPrivateTx( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final EventEmitter publicEventEmitter = transactionNode.execute(contractTransactions.createSmartContract(EventEmitter.class)); @@ -99,8 +105,14 @@ public void mustAllowAccessToPublicStateFromPrivateTx() throws Exception { assertThat(result).isEqualTo(BigInteger.valueOf(12)); } - @Test - public void mustNotAllowAccessToPrivateStateFromPublicTx() throws Exception { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void mustNotAllowAccessToPrivateStateFromPublicTx( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final EventEmitter privateEventEmitter = transactionNode.execute( (privateContractTransactions.createSmartContract( @@ -119,8 +131,14 @@ public void mustNotAllowAccessToPrivateStateFromPublicTx() throws Exception { assertThatThrownBy(functionCall::send).isInstanceOf(ContractCallException.class); } - @Test - public void privateContractMustNotBeAbleToCallPublicContractWhichChangesState() throws Exception { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void privateContractMustNotBeAbleToCallPublicContractWhichChangesState( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final CrossContractReader privateReader = transactionNode.execute( privateContractTransactions.createSmartContract( @@ -138,9 +156,14 @@ public void privateContractMustNotBeAbleToCallPublicContractWhichChangesState() "0x", e -> ((PrivateTransactionReceipt) e.getTransactionReceipt().get()).getOutput()); } - @Test - public void privateContractMustNotBeAbleToCallPublicContractWhichInstantiatesContract() + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void privateContractMustNotBeAbleToCallPublicContractWhichInstantiatesContract( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final CrossContractReader privateReader = transactionNode.execute( privateContractTransactions.createSmartContract( @@ -157,8 +180,14 @@ public void privateContractMustNotBeAbleToCallPublicContractWhichInstantiatesCon .returns(0, e -> e.getTransactionReceipt().get().getLogs().size()); } - @Test - public void privateContractMustNotBeAbleToCallSelfDestructOnPublicContract() throws Exception { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void privateContractMustNotBeAbleToCallSelfDestructOnPublicContract( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final CrossContractReader privateReader = transactionNode.execute( privateContractTransactions.createSmartContract( @@ -179,8 +208,14 @@ public void privateContractMustNotBeAbleToCallSelfDestructOnPublicContract() thr "0x", e -> ((PrivateTransactionReceipt) e.getTransactionReceipt().get()).getOutput()); } - @Test - public void privateContractCanCallPublicContractThatCallsPublicContract() throws Exception { + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void privateContractCanCallPublicContractThatCallsPublicContract( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); final SimpleStorage simpleStorage = transactionNode .getBesu() diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateGenesisAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateGenesisAcceptanceTest.java index 29d5b655e3c..8b048fdc546 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateGenesisAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateGenesisAcceptanceTest.java @@ -29,24 +29,20 @@ import java.math.BigInteger; import java.util.Optional; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.web3j.protocol.core.methods.response.EthCall; import org.web3j.utils.Restriction; -@RunWith(Parameterized.class) public class PrivateGenesisAcceptanceTest extends ParameterizedEnclaveTestBase { - private final PrivacyNode alice; + private PrivacyNode alice; - public PrivateGenesisAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); - alice = privacyBesu.createIbft2NodePrivacyEnabledWithGenesis( "node1", @@ -62,9 +58,15 @@ public PrivateGenesisAcceptanceTest( privacyCluster.start(alice); } - @Test - public void canInteractWithPrivateGenesisPreCompile() throws Exception { - final String privacyGroupId = createPrivacyGroup(); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void canInteractWithPrivateGenesisPreCompile( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final String privacyGroupId = createPrivacyGroup(restriction); final EventEmitter eventEmitter = alice.execute( @@ -87,7 +89,7 @@ public void canInteractWithPrivateGenesisPreCompile() throws Exception { assertThat(new BigInteger(value.substring(2), 16)).isEqualByComparingTo(BigInteger.valueOf(42)); } - private String createPrivacyGroup() { + private String createPrivacyGroup(final Restriction restriction) { if (restriction == RESTRICTED) { return alice.execute(privacyTransactions.createPrivacyGroup("name", "description", alice)); } else if (restriction == UNRESTRICTED) { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateLogFilterAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateLogFilterAcceptanceTest.java index a6837f95465..b0b579b03dd 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateLogFilterAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/PrivateLogFilterAcceptanceTest.java @@ -31,7 +31,8 @@ import java.util.List; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; import org.web3j.protocol.core.methods.response.EthLog.LogResult; import org.web3j.utils.Restriction; @@ -39,16 +40,14 @@ @SuppressWarnings("rawtypes") public class PrivateLogFilterAcceptanceTest extends ParameterizedEnclaveTestBase { - private final PrivacyNode node; + private PrivacyNode node; - public PrivateLogFilterAcceptanceTest( + public void setUp( final Restriction restriction, final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) throws IOException { - super(restriction, enclaveType, enclaveEncryptorType); - node = privacyBesu.createPrivateTransactionEnabledMinerNode( restriction + "-node", @@ -62,10 +61,17 @@ public PrivateLogFilterAcceptanceTest( privacyCluster.start(node); } - @Test - public void installAndUninstallFilter() { - final String privacyGroupId = createPrivacyGroup(); - final EventEmitter eventEmitterContract = deployEventEmitterContract(privacyGroupId); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void installAndUninstallFilter( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final String privacyGroupId = createPrivacyGroup(restriction); + final EventEmitter eventEmitterContract = + deployEventEmitterContract(restriction, privacyGroupId); final LogFilterJsonParameter filter = blockRangeLogFilter("earliest", "latest", eventEmitterContract.getContractAddress()); @@ -78,16 +84,23 @@ public void installAndUninstallFilter() { assertThat(filterUninstalled).isTrue(); } - @Test - public void getFilterLogs() { - final String privacyGroupId = createPrivacyGroup(); - final EventEmitter eventEmitterContract = deployEventEmitterContract(privacyGroupId); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void getFilterLogs( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final String privacyGroupId = createPrivacyGroup(restriction); + final EventEmitter eventEmitterContract = + deployEventEmitterContract(restriction, privacyGroupId); final LogFilterJsonParameter filter = blockRangeLogFilter("earliest", "latest", eventEmitterContract.getContractAddress()); final String filterId = node.execute(privacyTransactions.newFilter(privacyGroupId, filter)); - updateContractValue(privacyGroupId, eventEmitterContract, 1); + updateContractValue(restriction, privacyGroupId, eventEmitterContract, 1); final List logs = node.execute(privacyTransactions.getFilterLogs(privacyGroupId, filterId)); @@ -95,22 +108,29 @@ public void getFilterLogs() { assertThat(logs).hasSize(1); } - @Test - public void getFilterChanges() { - final String privacyGroupId = createPrivacyGroup(); - final EventEmitter eventEmitterContract = deployEventEmitterContract(privacyGroupId); + @ParameterizedTest(name = "{0} tx with {1} enclave and {2} encryptor type") + @MethodSource("params") + public void getFilterChanges( + final Restriction restriction, + final EnclaveType enclaveType, + final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(restriction, enclaveType, enclaveEncryptorType); + final String privacyGroupId = createPrivacyGroup(restriction); + final EventEmitter eventEmitterContract = + deployEventEmitterContract(restriction, privacyGroupId); final LogFilterJsonParameter filter = blockRangeLogFilter("earliest", "latest", eventEmitterContract.getContractAddress()); final String filterId = node.execute(privacyTransactions.newFilter(privacyGroupId, filter)); - updateContractValue(privacyGroupId, eventEmitterContract, 1); - updateContractValue(privacyGroupId, eventEmitterContract, 2); + updateContractValue(restriction, privacyGroupId, eventEmitterContract, 1); + updateContractValue(restriction, privacyGroupId, eventEmitterContract, 2); assertThat(node.execute(privacyTransactions.getFilterChanges(privacyGroupId, filterId))) .hasSize(2); - updateContractValue(privacyGroupId, eventEmitterContract, 3); + updateContractValue(restriction, privacyGroupId, eventEmitterContract, 3); assertThat(node.execute(privacyTransactions.getFilterChanges(privacyGroupId, filterId))) .hasSize(1); @@ -122,11 +142,13 @@ private LogFilterJsonParameter blockRangeLogFilter( fromBlock, toBlock, List.of(contractAddress), Collections.emptyList(), null); } - private String createPrivacyGroup() { - return node.execute(createPrivacyGroup("myGroupName", "my group description", node)); + private String createPrivacyGroup(final Restriction restriction) { + return node.execute( + createPrivacyGroup(restriction, "myGroupName", "my group description", node)); } - private EventEmitter deployEventEmitterContract(final String privacyGroupId) { + private EventEmitter deployEventEmitterContract( + final Restriction restriction, final String privacyGroupId) { final EventEmitter eventEmitter = node.execute( privateContractTransactions.createSmartContractWithPrivacyGroupId( @@ -145,7 +167,10 @@ private EventEmitter deployEventEmitterContract(final String privacyGroupId) { } private PrivateTransactionReceipt updateContractValue( - final String privacyGroupId, final EventEmitter eventEmitterContract, final int value) { + final Restriction restriction, + final String privacyGroupId, + final EventEmitter eventEmitterContract, + final int value) { final String transactionHash = node.execute( privateContractTransactions.callSmartContractWithPrivacyGroupId( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/FlexibleMultiTenancyAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/FlexibleMultiTenancyAcceptanceTest.java index da692f21ba1..646359bf943 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/FlexibleMultiTenancyAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/FlexibleMultiTenancyAcceptanceTest.java @@ -35,43 +35,26 @@ import org.hyperledger.enclave.testutil.EnclaveType; import java.math.BigInteger; -import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import java.util.stream.Stream; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.web3j.crypto.Credentials; import org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt; import org.web3j.protocol.core.methods.response.EthCall; import org.web3j.utils.Base64String; import org.web3j.utils.Restriction; -@RunWith(Parameterized.class) public class FlexibleMultiTenancyAcceptanceTest extends FlexiblePrivacyAcceptanceTestBase { - private final EnclaveType enclaveType; - private final EnclaveEncryptorType enclaveEncryptorType; - - public FlexibleMultiTenancyAcceptanceTest( - final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) { - this.enclaveType = enclaveType; - this.enclaveEncryptorType = enclaveEncryptorType; - } - - @Parameterized.Parameters(name = "{0} enclave type with {1} encryptor") - public static Collection enclaveParameters() { - return Arrays.asList( - new Object[][] { - {TESSERA, NACL}, - {TESSERA, EC} - }); + public static Stream enclaveParameters() { + return Stream.of(Arguments.of(TESSERA, NACL), Arguments.of(TESSERA, EC)); } private static final PermissioningTransactions permissioningTransactions = @@ -81,8 +64,8 @@ public static Collection enclaveParameters() { private PrivacyNode alice; private MultiTenancyPrivacyNode aliceMultiTenancyPrivacyNode; - @Before - public void setUp() throws Exception { + public void setUp(final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { alice = privacyBesu.createFlexiblePrivacyGroupEnabledMinerNode( "node1", @@ -112,26 +95,35 @@ public void setUp() throws Exception { .addTenantWithToken(alice3EnclaveKey, alice3Token); } - @After + @AfterEach public void tearDown() { privacyCluster.close(); } - @Test + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") public void createPrivacyGroup() { createFlexiblePrivacyGroup(alice); } - @Test - public void createPrivacyGroupWithAllTenants() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void createPrivacyGroupWithAllTenants( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final MultiTenancyPrivacyGroup privacyGroup = new MultiTenancyPrivacyGroup(); privacyGroup.addNodeWithTenants( aliceMultiTenancyPrivacyNode, aliceMultiTenancyPrivacyNode.getTenants()); createFlexiblePrivacyGroup(privacyGroup); } - @Test - public void noAccessWhenNotAMember() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void noAccessWhenNotAMember( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final MultiTenancyPrivacyGroup twoTenantsFromAlice = new MultiTenancyPrivacyGroup(); final List tenants = aliceMultiTenancyPrivacyNode.getTenants(); final String removedTenant = tenants.remove(tenants.size() - 1); @@ -330,8 +322,12 @@ public void noAccessWhenNotAMember() { // enclave key } - @Test - public void removedMemberCannotGetFilterChanges() { + @ParameterizedTest(name = "{0} enclave and {1} encryptor type") + @MethodSource("enclaveParameters") + public void removedMemberCannotGetFilterChanges( + final EnclaveType enclaveType, final EnclaveEncryptorType enclaveEncryptorType) + throws Exception { + setUp(enclaveType, enclaveEncryptorType); final MultiTenancyPrivacyGroup allTenantsFromAlice = new MultiTenancyPrivacyGroup(); final List tenants = aliceMultiTenancyPrivacyNode.getTenants(); allTenantsFromAlice.addNodeWithTenants(aliceMultiTenancyPrivacyNode, tenants); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java index e2fdd2188b1..f93f0034c42 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java @@ -55,10 +55,10 @@ import com.google.common.base.Suppliers; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; -import org.junit.After; -import org.junit.Before; import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { private BesuNode node; @@ -93,7 +93,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { @Rule public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort()); - @Before + @BeforeEach public void setUp() throws Exception { final ClusterConfiguration clusterConfiguration = new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); @@ -111,7 +111,7 @@ public void setUp() throws Exception { node.useAuthenticationTokenInHeaderForJsonRpc(token); } - @After + @AfterEach public void tearDown() { multiTenancyCluster.close(); } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyValidationFailAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyValidationFailAcceptanceTest.java index 84e6fa7ea3e..0a373a30354 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyValidationFailAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyValidationFailAcceptanceTest.java @@ -48,10 +48,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.junit.WireMockRule; import org.apache.tuweni.bytes.Bytes; -import org.junit.After; -import org.junit.Before; import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MultiTenancyValidationFailAcceptanceTest extends AcceptanceTestBase { private BesuNode node; @@ -67,7 +67,7 @@ public class MultiTenancyValidationFailAcceptanceTest extends AcceptanceTestBase @Rule public WireMockRule wireMockRule = new WireMockRule(options().dynamicPort()); - @Before + @BeforeEach public void setUp() throws Exception { final ClusterConfiguration clusterConfiguration = new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); @@ -86,7 +86,7 @@ public void setUp() throws Exception { node.useAuthenticationTokenInHeaderForJsonRpc(token); } - @After + @AfterEach public void tearDown() { multiTenancyCluster.close(); } diff --git a/ethereum/evmtool/build.gradle b/ethereum/evmtool/build.gradle index 5bc7877fc28..fb47db311f7 100644 --- a/ethereum/evmtool/build.gradle +++ b/ethereum/evmtool/build.gradle @@ -64,8 +64,6 @@ dependencies { testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-junit-jupiter' - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' - // No logging in graalvm EvmTool nativeImageClasspath 'org.slf4j:slf4j-nop' } diff --git a/gradle/versions.gradle b/gradle/versions.gradle index f239370ab7a..02080502827 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -120,7 +120,7 @@ dependencyManagement { } dependency 'junit:junit:4.13.2' - + dependency 'net.java.dev.jna:jna:5.13.0' dependency 'org.apache.commons:commons-compress:1.23.0' diff --git a/plugins/rocksdb/build.gradle b/plugins/rocksdb/build.gradle index f76e8d80ae0..8f1c8dab11d 100644 --- a/plugins/rocksdb/build.gradle +++ b/plugins/rocksdb/build.gradle @@ -56,6 +56,4 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.assertj:assertj-core' testImplementation 'org.mockito:mockito-junit-jupiter' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' }