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 index 21c4fe8fa9..ec50920403 100644 --- 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 @@ -38,17 +38,21 @@ public class AcceptanceTestBaseTestWatcher implements TestWatcher { public void testSuccessful(final ExtensionContext extensionContext) { // if so configured, delete logs of successful tests if (!Boolean.getBoolean("acctests.keepLogsOfPassingTests")) { - // log4j is configured to create a file per test - // build/acceptanceTestLogs/${ctx:class}.${ctx:test}.log - String pathname = - "build/acceptanceTestLogs/" - + extensionContext.getTestClass().get().getSimpleName() - + "." - + extensionContext.getTestMethod().get().getName() - + ".log"; - LOG.info("Test successful, deleting log at {}", pathname); - File file = new File(pathname); - file.delete(); + try { + // log4j is configured to create a file per test + // build/acceptanceTestLogs/${ctx:class}.${ctx:test}.log + String pathname = + "build/acceptanceTestLogs/" + + extensionContext.getTestClass().get().getSimpleName() + + "." + + extensionContext.getTestMethod().get().getName() + + ".log"; + LOG.info("Test successful, deleting log at {}", pathname); + final File file = new File(pathname); + file.delete(); + } catch (final Exception e) { + LOG.error("could not delete test file", e); + } } } } 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 b7464190ab..c9fcf36484 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,22 @@ package org.hyperledger.besu.tests.acceptance.bft; 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 4225035b7f..86978ae0b0 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.NavigableMap; 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 class BftBlockRewardPaymentAcceptanceTest extends ParameterizedBftTestBas 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 class BftBlockRewardPaymentAcceptanceTest extends ParameterizedBftTestBas 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 class BftBlockRewardPaymentAcceptanceTest extends ParameterizedBftTestBas 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 40d0e88145..0e7484529f 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 @@ package org.hyperledger.besu.tests.acceptance.bft; 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 a109a3b856..71eb3908a7 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.List; 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 class BftMiningAcceptanceTest extends ParameterizedBftTestBase { 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 class BftMiningAcceptanceTest extends ParameterizedBftTestBase { 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 class BftMiningAcceptanceTest extends ParameterizedBftTestBase { 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 class BftMiningAcceptanceTest extends ParameterizedBftTestBase { 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 class BftMiningAcceptanceTest extends ParameterizedBftTestBase { 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 class BftMiningAcceptanceTest extends ParameterizedBftTestBase { 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 7fccf33fa2..eecd383003 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 @@ package org.hyperledger.besu.tests.acceptance.bft; 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 7db3d6a5b9..191884f41a 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 @@ package org.hyperledger.besu.tests.acceptance.bft; 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/BftZeroValidatorsAcceptanceTest.java similarity index 73% rename from acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftZeroValidators.java rename to acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftZeroValidatorsAcceptanceTest.java index 898ad47b3f..2b107937b8 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/BftZeroValidatorsAcceptanceTest.java @@ -16,17 +16,16 @@ package org.hyperledger.besu.tests.acceptance.bft; 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 class BftZeroValidatorsAcceptanceTest 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 e08d4a5c20..b3d1e321ae 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 @@ -14,29 +14,23 @@ */ package org.hyperledger.besu.tests.acceptance.bft; -import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; +import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5; -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.api.Disabled; +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 { +@Disabled("This is not a test class, it offers BFT parameterization only.") +public abstract class ParameterizedBftTestBase extends AcceptanceTestBaseJunit5 { + 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 29c00b65d9..b1ffcff371 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 @@ -14,28 +14,16 @@ */ package org.hyperledger.besu.tests.acceptance.bft.pki; -import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; +import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBaseJunit5; -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.api.Disabled; +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() { +@Disabled("This is not a test class, it offers PKI QBFT parameterization only.") +public abstract class ParameterizedPkiQbftTestBase extends AcceptanceTestBaseJunit5 { + 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 8fecb5f677..12ae887a51 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 @@ package org.hyperledger.besu.tests.acceptance.bft.pki; 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 class PkiQbftAcceptanceTest extends ParameterizedPkiQbftTestBase { 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 class PkiQbftAcceptanceTest extends ParameterizedPkiQbftTestBase { 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 10d4866fef..7bcf09afd3 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 org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeFact 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