Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/6239/head
Sally MacFarlane 11 months ago committed by GitHub
parent 7a96a650d6
commit 4bc04b2939
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      acceptance-tests/test-plugins/build.gradle
  2. 10
      acceptance-tests/test-plugins/src/test/java/org/hyperledger/besu/services/BesuPluginContextImplTest.java
  3. 28
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/AbstractJsonRpcTest.java
  4. 23
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugReplayBlockAcceptanceTest.java
  5. 23
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugSetHeadAcceptanceTest.java
  6. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthEstimateGasAcceptanceTest.java
  7. 24
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthGetBlockByNumberAndHashShanghaiAcceptanceTest.java
  8. 24
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineCancunBlockBuildingAcceptanceTest.java
  9. 23
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java
  10. 23
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineParisAcceptanceTest.java
  11. 24
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineShanghaiAcceptanceTest.java
  12. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/ipc/Web3JSupportAcceptanceTest.java

@ -11,7 +11,6 @@ dependencies {
implementation 'com.google.auto.service:auto-service'
implementation 'info.picocli:picocli'
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'

@ -29,13 +29,13 @@ import java.util.Optional;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.ThrowableAssert;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class BesuPluginContextImplTest {
@BeforeClass
@BeforeAll
public static void createFakePluginDir() throws IOException {
if (System.getProperty("besu.plugins.dir") == null) {
final Path pluginDir = Files.createTempDirectory("besuTest");
@ -44,7 +44,7 @@ public class BesuPluginContextImplTest {
}
}
@After
@AfterEach
public void clearTestPluginState() {
System.clearProperty("testPicoCLIPlugin.testOption");
}

@ -30,7 +30,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@ -40,10 +40,12 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.junit.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
abstract class AbstractJsonRpcTest {
private static final MediaType MEDIA_TYPE_JSON =
protected static final MediaType MEDIA_TYPE_JSON =
MediaType.parse("application/json; charset=utf-8");
static class JsonRpcTestsContext {
@ -69,16 +71,14 @@ abstract class AbstractJsonRpcTest {
}
private final JsonRpcTestsContext testsContext;
private final URI testCaseFileURI;
public AbstractJsonRpcTest(
final String ignored, final JsonRpcTestsContext testsContext, final URI testCaseFileURI) {
this.testCaseFileURI = testCaseFileURI;
public AbstractJsonRpcTest(final JsonRpcTestsContext testsContext) {
this.testsContext = testsContext;
}
@Test
public void test() throws IOException {
@ParameterizedTest(name = "{index}: {0}")
@MethodSource("testCases")
public void test(final URI testCaseFileURI) throws IOException {
final JsonRpcTestCase testCase =
testsContext.mapper.readValue(testCaseFileURI.toURL(), JsonRpcTestCase.class);
@ -118,7 +118,7 @@ abstract class AbstractJsonRpcTest {
final JsonRpcTestCase testCase,
final URL url) {}
private String getRpcUrl(final String rpcMethod) {
protected String getRpcUrl(final String rpcMethod) {
if (rpcMethod.contains("eth_") || rpcMethod.contains("engine_")) {
return testsContext.besuNode.engineRpcUrl().get();
}
@ -126,14 +126,12 @@ abstract class AbstractJsonRpcTest {
return testsContext.besuNode.jsonRpcBaseUrl().get();
}
public static Iterable<Object[]> testCases(final String testCasesPath) throws URISyntaxException {
public static Stream<Arguments> testCasesFromPath(final String testCasesPath)
throws URISyntaxException {
final File[] testCasesList =
new File(AbstractJsonRpcTest.class.getResource(testCasesPath).toURI()).listFiles();
return Arrays.stream(testCasesList)
.sorted()
.map(file -> new Object[] {file.getName(), file.toURI()})
.collect(Collectors.toList());
return Arrays.stream(testCasesList).sorted().map(File::toURI).map(Arguments::of);
}
}

@ -15,36 +15,33 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class DebugReplayBlockAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/debug/replayBlock/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/debug/replayBlock/test-cases/";
private static AbstractJsonRpcTest.JsonRpcTestsContext testsContext;
public DebugReplayBlockAcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public DebugReplayBlockAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

@ -15,36 +15,33 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class DebugSetHeadAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/debug/setHead/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/debug/setHead/test-cases/";
private static JsonRpcTestsContext testsContext;
public DebugSetHeadAcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public DebugSetHeadAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

@ -28,8 +28,8 @@ import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class EthEstimateGasAcceptanceTest extends AcceptanceTestBase {
@ -38,7 +38,7 @@ public class EthEstimateGasAcceptanceTest extends AcceptanceTestBase {
List<SimpleEntry<Integer, Long>> testCase = new ArrayList<>();
@Before
@BeforeEach
public void setUp() throws Exception {
node =
besu.createMinerNode(

@ -15,15 +15,13 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class EthGetBlockByNumberAndHashShanghaiAcceptanceTest extends AbstractJsonRpcTest {
private static final String TEST_RESOURCES_DIR = "/jsonrpc/eth/getBlockBy/";
private static final String GENESIS_FILE = TEST_RESOURCES_DIR + "genesis.json";
@ -31,22 +29,20 @@ public class EthGetBlockByNumberAndHashShanghaiAcceptanceTest extends AbstractJs
private static AbstractJsonRpcTest.JsonRpcTestsContext testsContext;
public EthGetBlockByNumberAndHashShanghaiAcceptanceTest(
final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public EthGetBlockByNumberAndHashShanghaiAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

@ -19,39 +19,35 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.tests.acceptance.dsl.rpc.JsonRpcTestCase;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.node.ObjectNode;
import okhttp3.Call;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class ExecutionEngineCancunBlockBuildingAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/cancun/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/cancun/test-cases/block-production";
private static JsonRpcTestsContext testsContext;
public ExecutionEngineCancunBlockBuildingAcceptanceTest(
final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public ExecutionEngineCancunBlockBuildingAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@Override
@ -90,7 +86,7 @@ public class ExecutionEngineCancunBlockBuildingAcceptanceTest extends AbstractJs
}
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

@ -15,36 +15,33 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class ExecutionEngineEip6110AcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/eip6110/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/eip6110/test-cases/";
private static JsonRpcTestsContext testsContext;
public ExecutionEngineEip6110AcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public ExecutionEngineEip6110AcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

@ -15,36 +15,33 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class ExecutionEngineParisAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/paris/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/paris/test-cases/";
private static JsonRpcTestsContext testsContext;
public ExecutionEngineParisAcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public ExecutionEngineParisAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws URISyntaxException {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

@ -15,36 +15,32 @@
package org.hyperledger.besu.tests.acceptance.jsonrpc;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;
@RunWith(Parameterized.class)
public class ExecutionEngineShanghaiAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/shanghai/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/shanghai/test-cases/";
private static JsonRpcTestsContext testsContext;
public ExecutionEngineShanghaiAcceptanceTest(final String ignored, final URI testCaseFileURI) {
super(ignored, testsContext, testCaseFileURI);
public ExecutionEngineShanghaiAcceptanceTest() {
super(testsContext);
}
@BeforeClass
@BeforeAll
public static void init() throws IOException {
testsContext = new JsonRpcTestsContext(GENESIS_FILE);
}
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> testCases() throws URISyntaxException {
return testCases(TEST_CASE_PATH);
public static Stream<Arguments> testCases() throws Exception {
return testCasesFromPath(TEST_CASE_PATH);
}
@AfterClass
@AfterAll
public static void tearDown() {
testsContext.cluster.close();
}

@ -29,8 +29,8 @@ import java.nio.file.Path;
import java.util.Collections;
import java.util.Locale;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.methods.response.NetVersion;
@ -41,7 +41,7 @@ public class Web3JSupportAcceptanceTest extends AcceptanceTestBase {
private Node node;
private Path socketPath;
@Before
@BeforeEach
public void setUp() throws Exception {
socketPath = Files.createTempFile("besu-test-", ".ipc");
node =

Loading…
Cancel
Save