Skip to content

Commit

Permalink
[TESTING] remove junit4 assumeThat (hyperledger#7788)
Browse files Browse the repository at this point in the history
* use junit5 assumeTrue/false

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
macfarla authored Oct 22, 2024
1 parent 1b0da83 commit d8d1237
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,7 +80,7 @@ public void transactionShouldBeSuccessful() {
// 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

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;
Expand All @@ -33,7 +32,7 @@
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;
Expand Down Expand Up @@ -2392,7 +2391,7 @@ public void nativeLibrariesAreEnabledByDefault() {

@Test
public void logsWarningWhenFailToLoadJemalloc() {
assumeThat(PlatformDetector.getOSType(), is("linux"));
assumeTrue(PlatformDetector.getOSType().equals("linux"));
setEnvironmentVariable("BESU_USING_JEMALLOC", "true");
parseCommand();
verify(mockLogger)
Expand All @@ -2404,7 +2403,7 @@ public void logsWarningWhenFailToLoadJemalloc() {

@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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

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;
Expand Down Expand Up @@ -415,10 +414,9 @@ public void canNotUseFlexiblePrivacyWhenPrivacyPluginEnabled() {

@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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -148,18 +148,15 @@ public static void executeTest(final BlockchainReferenceTestCaseSpec spec) {
}

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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -136,7 +136,7 @@ void testMCopy(
"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()
Expand All @@ -158,7 +158,7 @@ void testMCopy(
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()
Expand Down

0 comments on commit d8d1237

Please sign in to comment.