From 4dd9c65ff7518d2254a45a40aea4f09449fd9a30 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Tue, 16 Apr 2024 23:23:10 +0200 Subject: [PATCH] Port permissioning acceptance tests to JUnit 5 (#6959) Signed-off-by: Fabio Di Fabio --- ...AndOnchainPermissioningAcceptanceTest.java | 6 ++-- ...ocalConfigPermissioningAcceptanceTest.java | 6 ++-- ...nfigPermissioningImportAcceptanceTest.java | 31 +++++++++---------- ...rtContractPermissioningAcceptanceTest.java | 6 ++-- .../AllowlistPersistorAcceptanceTest.java | 6 ++-- ...lowlistWithDnsPersistorAcceptanceTest.java | 6 ++-- ...AndOnchainPermissioningAcceptanceTest.java | 6 ++-- ...ocalConfigPermissioningAcceptanceTest.java | 6 ++-- ...rtContractPermissioningAcceptanceTest.java | 6 ++-- ...PermissioningIbft2StallAcceptanceTest.java | 2 +- ...tPermissioningOutOfSyncAcceptanceTest.java | 6 ++-- ...ContractPermissioningV2AcceptanceTest.java | 6 ++-- ...tractPermissioningV2DNSAcceptanceTest.java | 6 ++-- ...ermissioningStaticNodesAcceptanceTest.java | 6 ++-- 14 files changed, 52 insertions(+), 53 deletions(-) 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 4b6401303b..1d38f7e6c7 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 org.hyperledger.besu.tests.acceptance.dsl.transaction.account.TransferTra 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 78a9fee041..4b163a4efc 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 org.hyperledger.besu.tests.acceptance.dsl.transaction.account.TransferTra 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 4415a03f80..c3a2ab6e11 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 @@ -21,20 +21,19 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.Cluster; import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; -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 Path folder; private static final String GENESIS_FILE = "/ibft/ibft.json"; @@ -45,20 +44,20 @@ 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(); - persistAllowList(allowList, sharedFile.toPath()); + final Path sharedFile = Files.createFile(folder.resolve("sharedFile")); + persistAllowList(allowList, sharedFile); bootnode = besu.createIbft2NonValidatorBootnode("bootnode", GENESIS_FILE); nodeA = besu.createIbft2NodeWithLocalAccountPermissioning( - "nodeA", GENESIS_FILE, allowList, sharedFile); + "nodeA", GENESIS_FILE, allowList, sharedFile.toFile()); nodeB = besu.createIbft2NodeWithLocalAccountPermissioning( - "nodeB", GENESIS_FILE, allowList, sharedFile); + "nodeB", GENESIS_FILE, allowList, sharedFile.toFile()); permissionedCluster = new Cluster(new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(), net); @@ -67,12 +66,12 @@ public class AccountLocalConfigPermissioningImportAcceptanceTest extends Accepta @Test public void transactionFromDeniedAccountShouldNotBreakBlockImport() throws IOException { - final File newPermissionsFile = folder.newFile(); + final Path newPermissionsFile = Files.createFile(folder.resolve("newPermissionsFile")); final List allowList = List.of(beneficiary.getAddress()); - persistAllowList(allowList, newPermissionsFile.toPath()); + persistAllowList(allowList, newPermissionsFile); final BesuNode nodeC = besu.createIbft2NodeWithLocalAccountPermissioning( - "nodeC", GENESIS_FILE, allowList, newPermissionsFile); + "nodeC", GENESIS_FILE, allowList, newPermissionsFile.toFile()); waitForBlockHeight(bootnode, 2); @@ -91,7 +90,7 @@ public class AccountLocalConfigPermissioningImportAcceptanceTest extends Accepta 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 6d9e74e04a..9009721d94 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 org.hyperledger.besu.tests.acceptance.dsl.transaction.account.TransferTra 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 5a563cc526..71258222d7 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.ArrayList; 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 88c7e78377..08761ef6e0 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 @@ -31,8 +31,8 @@ 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; public class AllowlistWithDnsPersistorAcceptanceTest extends AcceptanceTestBase { @@ -48,7 +48,7 @@ public class AllowlistWithDnsPersistorAcceptanceTest extends AcceptanceTestBase private Account senderA; private Path tempFile; - @Before + @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; 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 6a7b8e9b35..3dfdae528a 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 @@ package org.hyperledger.besu.tests.acceptance.permissioning; 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 7d8128d66c..d889abb9fb 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.Cluster; 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 e9442bc007..8f17c78add 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 @@ package org.hyperledger.besu.tests.acceptance.permissioning; 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 e9da331a9e..ed48ad9db9 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 org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; 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 2f8adf4386..4315151473 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 @@ package org.hyperledger.besu.tests.acceptance.permissioning; 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 4e2cb9a877..843d14004f 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 @@ package org.hyperledger.besu.tests.acceptance.permissioning; 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 b2ed27d7c5..7a55283e4f 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.InetAddress; 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 57253d474c..4f516d1cda 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.Arrays; 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);