From d8d1237252bd84fa3d797480e47b20bb4c0e5ff1 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 22 Oct 2024 10:11:28 +1000 Subject: [PATCH] [TESTING] remove junit4 assumeThat (#7788) * use junit5 assumeTrue/false Signed-off-by: Sally MacFarlane --------- Signed-off-by: Sally MacFarlane --- .../crypto/SECP256R1AcceptanceTest.java | 4 ++-- .../hyperledger/besu/cli/BesuCommandTest.java | 7 +++---- .../besu/cli/PrivacyOptionsTest.java | 10 ++++------ .../vm/BlockchainReferenceTestTools.java | 17 +++++++---------- .../evm/operation/DataCopyOperationTest.java | 6 +++--- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java index 27679463bf..cc2d1a36bc 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.tests.acceptance.crypto; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assumptions.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SECP256R1; @@ -80,7 +80,7 @@ public class SECP256R1AcceptanceTest extends AcceptanceTestBase { // the signature algorithm instance to SECP256R1 as it could influence other tests running at // the same time. So we only execute the test when ProcessBesuNodeRunner is used, as there is // not conflict because we use separate processes. - assumeThat(BesuNodeRunner.isProcessBesuNodeRunner()).isTrue(); + assumeTrue(BesuNodeRunner.isProcessBesuNodeRunner()); minerNode.verify(net.awaitPeerCount(1)); otherNode.verify(net.awaitPeerCount(1)); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index e5848ee5f3..399b82be12 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -16,7 +16,6 @@ package org.hyperledger.besu.cli; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.is; import static org.hyperledger.besu.cli.config.NetworkName.CLASSIC; import static org.hyperledger.besu.cli.config.NetworkName.DEV; import static org.hyperledger.besu.cli.config.NetworkName.EPHEMERY; @@ -33,7 +32,7 @@ import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfigura import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfiguration.SEPOLIA_BOOTSTRAP_NODES; import static org.hyperledger.besu.ethereum.p2p.config.DefaultDiscoveryConfiguration.SEPOLIA_DISCOVERY_URL; import static org.hyperledger.besu.plugin.services.storage.DataStorageFormat.BONSAI; -import static org.junit.Assume.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.contains; import static org.mockito.ArgumentMatchers.eq; @@ -2392,7 +2391,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void logsWarningWhenFailToLoadJemalloc() { - assumeThat(PlatformDetector.getOSType(), is("linux")); + assumeTrue(PlatformDetector.getOSType().equals("linux")); setEnvironmentVariable("BESU_USING_JEMALLOC", "true"); parseCommand(); verify(mockLogger) @@ -2404,7 +2403,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void logsSuggestInstallingJemallocWhenEnvVarNotPresent() { - assumeThat(PlatformDetector.getOSType(), is("linux")); + assumeTrue(PlatformDetector.getOSType().equals("linux")); parseCommand(); verify(mockLogger) .info("jemalloc library not found, memory usage may be reduced by installing it"); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java index af43535a8f..6a2c376436 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/PrivacyOptionsTest.java @@ -16,8 +16,7 @@ package org.hyperledger.besu.cli; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assume.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -415,10 +414,9 @@ public class PrivacyOptionsTest extends CommandTestAbstract { @Test public void privEnclaveKeyFileDoesNotExist() { - assumeThat( - "Ignored if system language is not English", - System.getProperty("user.language"), - startsWith("en")); + assumeTrue( + System.getProperty("user.language").startsWith("en"), + "Ignored if system language is not English"); parseCommand("--privacy-enabled=true", "--privacy-public-key-file", "/non/existent/file"); assertThat(commandOutput.toString(UTF_8)).isEmpty(); diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTestTools.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTestTools.java index aabc674087..f7a15e5eae 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTestTools.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTestTools.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.vm; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assumptions.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; @@ -148,18 +148,15 @@ public class BlockchainReferenceTestTools { } static void verifyJournaledEVMAccountCompatability( - final MutableWorldState worldState, final ProtocolSpec protocolSpec) { + final MutableWorldState worldState, final ProtocolSpec protocolSpec) { EVM evm = protocolSpec.getEvm(); if (evm.getEvmConfiguration().worldUpdaterMode() == WorldUpdaterMode.JOURNALED) { - assumeThat( + assumeFalse( worldState - .streamAccounts(Bytes32.ZERO, Integer.MAX_VALUE) - .anyMatch(AccountState::isEmpty)) - .withFailMessage("Journaled account configured and empty account detected") - .isFalse(); - assumeThat(EvmSpecVersion.SPURIOUS_DRAGON.compareTo(evm.getEvmVersion()) > 0) - .withFailMessage("Journaled account configured and fork prior to the merge specified") - .isFalse(); + .streamAccounts(Bytes32.ZERO, Integer.MAX_VALUE).anyMatch(AccountState::isEmpty), + "Journaled account configured and empty account detected"); + assumeFalse(EvmSpecVersion.SPURIOUS_DRAGON.compareTo(evm.getEvmVersion()) > 0, + "Journaled account configured and fork prior to the merge specified"); } } } diff --git a/evm/src/test/java/org/hyperledger/besu/evm/operation/DataCopyOperationTest.java b/evm/src/test/java/org/hyperledger/besu/evm/operation/DataCopyOperationTest.java index aa2ed37b5c..a4e93bf9d3 100644 --- a/evm/src/test/java/org/hyperledger/besu/evm/operation/DataCopyOperationTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/operation/DataCopyOperationTest.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.evm.operation; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assumptions.assumeThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hyperledger.besu.evm.Code; import org.hyperledger.besu.evm.EVM; @@ -136,7 +136,7 @@ class DataCopyOperationTest { "0xef0001010004020001001d04%04x000080000367%016x67%016x67%016xd300%s" .formatted(data.size(), dst, src, len, data.toUnprefixedHexString()); Code code = evm.getCodeUncached(Bytes.fromHexString(eofCode)); - assumeThat(code.isValid()).isTrue(); + assumeTrue(code.isValid()); MessageFrame frame = new TestMessageFrameBuilder() @@ -158,7 +158,7 @@ class DataCopyOperationTest { void legacyCallFails() { DataCopyOperation subject = new DataCopyOperation(new PragueGasCalculator()); Code code = evm.getCodeUncached(Bytes.fromHexString("0x600460046004d3")); - assumeThat(code.isValid()).isTrue(); + assumeTrue(code.isValid()); MessageFrame frame = new TestMessageFrameBuilder()