Search in sources :

Example 1 with JsonRpcIpcConfiguration

use of org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration in project besu by hyperledger.

the class RunnerBuilderTest method whenEngineApiAddedListensOnDefaultPort.

@Test
public void whenEngineApiAddedListensOnDefaultPort() {
    JsonRpcConfiguration jrpc = JsonRpcConfiguration.createDefault();
    jrpc.setEnabled(true);
    JsonRpcConfiguration engine = JsonRpcConfiguration.createEngineDefault();
    engine.setEnabled(true);
    EthNetworkConfig mockMainnet = mock(EthNetworkConfig.class);
    when(mockMainnet.getNetworkId()).thenReturn(BigInteger.ONE);
    MergeConfigOptions.setMergeEnabled(true);
    when(besuController.getMiningCoordinator()).thenReturn(mock(MergeMiningCoordinator.class));
    final Runner runner = new RunnerBuilder().discovery(true).p2pListenInterface("0.0.0.0").p2pListenPort(30303).p2pAdvertisedHost("127.0.0.1").p2pEnabled(true).natMethod(NatMethod.NONE).besuController(besuController).ethNetworkConfig(mockMainnet).metricsSystem(mock(ObservableMetricsSystem.class)).permissioningService(mock(PermissioningServiceImpl.class)).jsonRpcConfiguration(jrpc).engineJsonRpcConfiguration(engine).graphQLConfiguration(mock(GraphQLConfiguration.class)).webSocketConfiguration(mock(WebSocketConfiguration.class)).jsonRpcIpcConfiguration(mock(JsonRpcIpcConfiguration.class)).metricsConfiguration(mock(MetricsConfiguration.class)).vertx(Vertx.vertx()).dataDir(dataDir.getRoot().toPath()).storageProvider(mock(KeyValueStorageProvider.class)).forkIdSupplier(() -> Collections.singletonList(Bytes.EMPTY)).rpcEndpointService(new RpcEndpointServiceImpl()).besuPluginContext(mock(BesuPluginContextImpl.class)).build();
    assertThat(runner.getJsonRpcPort()).isPresent();
    assertThat(runner.getEngineJsonRpcPort()).isPresent();
}
Also used : MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) RpcEndpointServiceImpl(org.hyperledger.besu.services.RpcEndpointServiceImpl) ObservableMetricsSystem(org.hyperledger.besu.metrics.ObservableMetricsSystem) KeyValueStorageProvider(org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider) InMemoryKeyValueStorageProvider(org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider) MergeMiningCoordinator(org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator) JsonRpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration) EthNetworkConfig(org.hyperledger.besu.cli.config.EthNetworkConfig) JsonRpcIpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration) GraphQLConfiguration(org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration) Test(org.junit.Test)

Example 2 with JsonRpcIpcConfiguration

use of org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration in project besu by hyperledger.

the class ProcessBesuNodeRunner method startNode.

@Override
public void startNode(final BesuNode node) {
    final Path dataDir = node.homeDirectory();
    final List<String> params = new ArrayList<>();
    params.add("build/install/besu/bin/besu");
    params.add("--data-path");
    params.add(dataDir.toAbsolutePath().toString());
    if (node.isDevMode()) {
        params.add("--network");
        params.add("DEV");
    } else if (node.getNetwork() != null) {
        params.add("--network");
        params.add(node.getNetwork().name());
    }
    params.add("--sync-mode");
    params.add("FULL");
    params.add("--discovery-enabled");
    params.add(Boolean.toString(node.isDiscoveryEnabled()));
    params.add("--p2p-host");
    params.add(node.p2pListenHost());
    params.add("--p2p-port");
    params.add(node.getP2pPort());
    if (node.getMiningParameters().isMiningEnabled()) {
        params.add("--miner-enabled");
        params.add("--miner-coinbase");
        params.add(node.getMiningParameters().getCoinbase().get().toString());
        params.add("--miner-stratum-port");
        params.add(Integer.toString(node.getMiningParameters().getStratumPort()));
        params.add("--miner-stratum-host");
        params.add(node.getMiningParameters().getStratumNetworkInterface());
        params.add("--min-gas-price");
        params.add(Integer.toString(node.getMiningParameters().getMinTransactionGasPrice().intValue()));
        params.add("--Xminer-remote-sealers-limit");
        params.add(Integer.toString(node.getMiningParameters().getRemoteSealersLimit()));
        params.add("--Xminer-remote-sealers-hashrate-ttl");
        params.add(Long.toString(node.getMiningParameters().getRemoteSealersTimeToLive()));
    }
    if (node.getMiningParameters().isStratumMiningEnabled()) {
        params.add("--miner-stratum-enabled");
    }
    if (node.getPrivacyParameters().isEnabled()) {
        params.add("--privacy-enabled");
        params.add("--privacy-url");
        params.add(node.getPrivacyParameters().getEnclaveUri().toString());
        if (node.getPrivacyParameters().isMultiTenancyEnabled()) {
            params.add("--privacy-multi-tenancy-enabled");
        } else {
            params.add("--privacy-public-key-file");
            params.add(node.getPrivacyParameters().getEnclavePublicKeyFile().getAbsolutePath());
        }
        if (!node.getExtraCLIOptions().contains("--plugin-privacy-service-signing-enabled=true")) {
            params.add("--privacy-marker-transaction-signing-key-file");
            params.add(node.homeDirectory().resolve("key").toString());
        }
        if (node.getPrivacyParameters().isFlexiblePrivacyGroupsEnabled()) {
            params.add("--privacy-flexible-groups-enabled");
        }
        if (node.getPrivacyParameters().isPrivacyPluginEnabled()) {
            params.add("--Xprivacy-plugin-enabled");
        }
    }
    if (!node.getBootnodes().isEmpty()) {
        params.add("--bootnodes");
        params.add(node.getBootnodes().stream().map(URI::toString).collect(Collectors.joining(",")));
    }
    if (node.hasStaticNodes()) {
        createStaticNodes(node);
    }
    if (node.isDnsEnabled()) {
        params.add("--Xdns-enabled");
        params.add("true");
        params.add("--Xdns-update-enabled");
        params.add("true");
    }
    if (node.isJsonRpcEnabled()) {
        params.add("--rpc-http-enabled");
        params.add("--rpc-http-host");
        params.add(node.jsonRpcListenHost().get());
        params.add("--rpc-http-port");
        params.add(node.jsonRpcListenPort().map(Object::toString).get());
        params.add("--rpc-http-api");
        params.add(apiList(node.jsonRpcConfiguration().getRpcApis()));
        if (!node.jsonRpcConfiguration().getNoAuthRpcApis().isEmpty()) {
            params.add("--rpc-http-api-methods-no-auth");
            params.add(apiList(node.jsonRpcConfiguration().getNoAuthRpcApis()));
        }
        if (node.jsonRpcConfiguration().isAuthenticationEnabled()) {
            params.add("--rpc-http-authentication-enabled");
        }
        if (node.jsonRpcConfiguration().getAuthenticationCredentialsFile() != null) {
            params.add("--rpc-http-authentication-credentials-file");
            params.add(node.jsonRpcConfiguration().getAuthenticationCredentialsFile());
        }
        if (node.jsonRpcConfiguration().getAuthenticationPublicKeyFile() != null) {
            params.add("--rpc-http-authentication-jwt-public-key-file");
            params.add(node.jsonRpcConfiguration().getAuthenticationPublicKeyFile().getAbsolutePath());
        }
        if (node.jsonRpcConfiguration().getAuthenticationAlgorithm() != null) {
            params.add("--rpc-http-authentication-jwt-algorithm");
            params.add(node.jsonRpcConfiguration().getAuthenticationAlgorithm().toString());
        }
    }
    if (node.isEngineRpcEnabled()) {
        params.add("--engine-rpc-port");
        params.add(node.jsonEngineListenPort().get().toString());
        if (node.isEngineAuthDisabled()) {
            params.add("--engine-jwt-disabled");
        }
    }
    if (node.wsRpcEnabled()) {
        params.add("--rpc-ws-enabled");
        params.add("--rpc-ws-host");
        params.add(node.wsRpcListenHost().get());
        params.add("--rpc-ws-port");
        params.add(node.wsRpcListenPort().map(Object::toString).get());
        params.add("--rpc-ws-api");
        params.add(apiList(node.webSocketConfiguration().getRpcApis()));
        if (!node.webSocketConfiguration().getRpcApisNoAuth().isEmpty()) {
            params.add("--rpc-ws-api-methods-no-auth");
            params.add(apiList(node.webSocketConfiguration().getRpcApisNoAuth()));
        }
        if (node.webSocketConfiguration().isAuthenticationEnabled()) {
            params.add("--rpc-ws-authentication-enabled");
        }
        if (node.webSocketConfiguration().getAuthenticationCredentialsFile() != null) {
            params.add("--rpc-ws-authentication-credentials-file");
            params.add(node.webSocketConfiguration().getAuthenticationCredentialsFile());
        }
        if (node.webSocketConfiguration().getAuthenticationPublicKeyFile() != null) {
            params.add("--rpc-ws-authentication-jwt-public-key-file");
            params.add(node.webSocketConfiguration().getAuthenticationPublicKeyFile().getAbsolutePath());
        }
        if (node.webSocketConfiguration().getAuthenticationAlgorithm() != null) {
            params.add("--rpc-ws-authentication-jwt-algorithm");
            params.add(node.webSocketConfiguration().getAuthenticationAlgorithm().toString());
        }
    }
    if (node.isJsonRpcIpcEnabled()) {
        final JsonRpcIpcConfiguration ipcConfiguration = node.jsonRpcIpcConfiguration();
        params.add("--Xrpc-ipc-enabled");
        params.add("--Xrpc-ipc-path");
        params.add(ipcConfiguration.getPath().toString());
        params.add("--Xrpc-ipc-apis");
        params.add(String.join(",", ipcConfiguration.getEnabledApis()));
    }
    if (node.isMetricsEnabled()) {
        final MetricsConfiguration metricsConfiguration = node.getMetricsConfiguration();
        params.add("--metrics-enabled");
        params.add("--metrics-host");
        params.add(metricsConfiguration.getHost());
        params.add("--metrics-port");
        params.add(Integer.toString(metricsConfiguration.getPort()));
        for (final MetricCategory category : metricsConfiguration.getMetricCategories()) {
            params.add("--metrics-category");
            params.add(((Enum<?>) category).name());
        }
        if (node.isMetricsEnabled() || metricsConfiguration.isPushEnabled()) {
            params.add("--metrics-protocol");
            params.add(metricsConfiguration.getProtocol().name());
        }
        if (metricsConfiguration.isPushEnabled()) {
            params.add("--metrics-push-enabled");
            params.add("--metrics-push-host");
            params.add(metricsConfiguration.getPushHost());
            params.add("--metrics-push-port");
            params.add(Integer.toString(metricsConfiguration.getPushPort()));
            params.add("--metrics-push-interval");
            params.add(Integer.toString(metricsConfiguration.getPushInterval()));
            params.add("--metrics-push-prometheus-job");
            params.add(metricsConfiguration.getPrometheusJob());
        }
    }
    node.getGenesisConfig().ifPresent(genesis -> {
        final Path genesisFile = createGenesisFile(node, genesis);
        params.add("--genesis-file");
        params.add(genesisFile.toAbsolutePath().toString());
    });
    if (!node.isP2pEnabled()) {
        params.add("--p2p-enabled");
        params.add("false");
    } else {
        final List<String> networkConfigParams = NetworkingOptions.fromConfig(node.getNetworkingConfiguration()).getCLIOptions();
        params.addAll(networkConfigParams);
        if (node.getTLSConfiguration().isPresent()) {
            final TLSConfiguration config = node.getTLSConfiguration().get();
            params.add("--Xp2p-tls-enabled");
            params.add("--Xp2p-tls-keystore-type");
            params.add(config.getKeyStoreType());
            params.add("--Xp2p-tls-keystore-file");
            params.add(config.getKeyStorePath().toAbsolutePath().toString());
            params.add("--Xp2p-tls-keystore-password-file");
            params.add(config.getKeyStorePasswordPath().toAbsolutePath().toString());
            params.add("--Xp2p-tls-crl-file");
            params.add(config.getCrlPath().toAbsolutePath().toString());
            if (null != config.getTrustStoreType()) {
                params.add("--Xp2p-tls-truststore-type");
                params.add(config.getTrustStoreType());
                params.add("--Xp2p-tls-truststore-file");
                params.add(config.getTrustStorePath().toAbsolutePath().toString());
                params.add("--Xp2p-tls-truststore-password-file");
                params.add(config.getTrustStorePasswordPath().toAbsolutePath().toString());
            }
        }
    }
    if (node.isRevertReasonEnabled()) {
        params.add("--revert-reason-enabled");
    }
    params.add("--Xsecp256k1-native-enabled=" + node.isSecp256k1Native());
    params.add("--Xaltbn128-native-enabled=" + node.isAltbn128Native());
    node.getPermissioningConfiguration().flatMap(PermissioningConfiguration::getLocalConfig).ifPresent(permissioningConfiguration -> {
        if (permissioningConfiguration.isNodeAllowlistEnabled()) {
            params.add("--permissions-nodes-config-file-enabled");
        }
        if (permissioningConfiguration.getNodePermissioningConfigFilePath() != null) {
            params.add("--permissions-nodes-config-file");
            params.add(permissioningConfiguration.getNodePermissioningConfigFilePath());
        }
        if (permissioningConfiguration.isAccountAllowlistEnabled()) {
            params.add("--permissions-accounts-config-file-enabled");
        }
        if (permissioningConfiguration.getAccountPermissioningConfigFilePath() != null) {
            params.add("--permissions-accounts-config-file");
            params.add(permissioningConfiguration.getAccountPermissioningConfigFilePath());
        }
    });
    node.getPermissioningConfiguration().flatMap(PermissioningConfiguration::getSmartContractConfig).ifPresent(permissioningConfiguration -> {
        if (permissioningConfiguration.isSmartContractNodeAllowlistEnabled()) {
            params.add("--permissions-nodes-contract-enabled");
        }
        if (permissioningConfiguration.getNodeSmartContractAddress() != null) {
            params.add("--permissions-nodes-contract-address");
            params.add(permissioningConfiguration.getNodeSmartContractAddress().toString());
        }
        if (permissioningConfiguration.isSmartContractAccountAllowlistEnabled()) {
            params.add("--permissions-accounts-contract-enabled");
        }
        if (permissioningConfiguration.getAccountSmartContractAddress() != null) {
            params.add("--permissions-accounts-contract-address");
            params.add(permissioningConfiguration.getAccountSmartContractAddress().toString());
        }
        params.add("--permissions-nodes-contract-version");
        params.add(String.valueOf(permissioningConfiguration.getNodeSmartContractInterfaceVersion()));
    });
    node.getPkiKeyStoreConfiguration().ifPresent(pkiConfig -> {
        params.add("--Xpki-block-creation-enabled");
        params.add("--Xpki-block-creation-keystore-certificate-alias");
        params.add(pkiConfig.getCertificateAlias());
        params.add("--Xpki-block-creation-keystore-type");
        params.add(pkiConfig.getKeyStoreType());
        params.add("--Xpki-block-creation-keystore-file");
        params.add(pkiConfig.getKeyStorePath().toAbsolutePath().toString());
        params.add("--Xpki-block-creation-keystore-password-file");
        params.add(pkiConfig.getKeyStorePasswordPath().toAbsolutePath().toString());
        params.add("--Xpki-block-creation-truststore-type");
        params.add(pkiConfig.getTrustStoreType());
        params.add("--Xpki-block-creation-truststore-file");
        params.add(pkiConfig.getTrustStorePath().toAbsolutePath().toString());
        params.add("--Xpki-block-creation-truststore-password-file");
        params.add(pkiConfig.getTrustStorePasswordPath().toAbsolutePath().toString());
    });
    params.addAll(node.getExtraCLIOptions());
    params.add("--key-value-storage");
    params.add("rocksdb");
    params.add("--auto-log-bloom-caching-enabled");
    params.add("false");
    params.add("--strict-tx-replay-protection-enabled");
    params.add(Boolean.toString(node.isStrictTxReplayProtectionEnabled()));
    final String level = System.getProperty("root.log.level");
    if (level != null) {
        params.add("--logging=" + level);
    }
    params.addAll(node.getRunCommand());
    LOG.info("Creating besu process with params {}", params);
    final ProcessBuilder processBuilder = new ProcessBuilder(params).directory(new File(System.getProperty("user.dir")).getParentFile().getParentFile()).redirectErrorStream(true).redirectInput(Redirect.INHERIT);
    if (!node.getPlugins().isEmpty()) {
        processBuilder.environment().put("BESU_OPTS", "-Dbesu.plugins.dir=" + dataDir.resolve("plugins").toAbsolutePath().toString());
    }
    // Use non-blocking randomness for acceptance tests
    processBuilder.environment().put("JAVA_OPTS", "-Djava.security.properties=" + "acceptance-tests/tests/build/resources/test/acceptanceTesting.security");
    try {
        checkState(isNotAliveOrphan(node.getName()), "A live process with name: %s, already exists. Cannot create another with the same name as it would orphan the first", node.getName());
        final Process process = processBuilder.start();
        process.onExit().thenRun(() -> node.setExitCode(process.exitValue()));
        outputProcessorExecutor.execute(() -> printOutput(node, process));
        besuProcesses.put(node.getName(), process);
    } catch (final IOException e) {
        LOG.error("Error starting BesuNode process", e);
    }
    if (node.getRunCommand().isEmpty()) {
        waitForFile(dataDir, "besu.ports");
        waitForFile(dataDir, "besu.networks");
    }
    MDC.remove("node");
}
Also used : Path(java.nio.file.Path) TLSConfiguration(org.hyperledger.besu.ethereum.p2p.rlpx.connections.netty.TLSConfiguration) ArrayList(java.util.ArrayList) IOException(java.io.IOException) URI(java.net.URI) MetricsConfiguration(org.hyperledger.besu.metrics.prometheus.MetricsConfiguration) JsonRpcIpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration) File(java.io.File) MetricCategory(org.hyperledger.besu.plugin.services.metrics.MetricCategory)

Example 3 with JsonRpcIpcConfiguration

use of org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration in project besu by hyperledger.

the class Web3JSupportAcceptanceTest method setUp.

@Before
public void setUp() throws Exception {
    socketPath = Files.createTempFile("besu-test-", ".ipc");
    node = besu.createNode("node1", (configurationBuilder) -> configurationBuilder.jsonRpcIpcConfiguration(new JsonRpcIpcConfiguration(true, socketPath, Collections.singletonList(RpcApis.NET.name()))));
    cluster.start(node);
}
Also used : AcceptanceTestBase(org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase) Files(java.nio.file.Files) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RpcApis(org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis) IOException(java.io.IOException) Test(org.junit.Test) Request(org.web3j.protocol.core.Request) UnixIpcService(org.web3j.protocol.ipc.UnixIpcService) Assertions.fail(org.assertj.core.api.Assertions.fail) Web3j(org.web3j.protocol.Web3j) JsonRpcIpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration) Locale(java.util.Locale) NetVersion(org.web3j.protocol.core.methods.response.NetVersion) Assume.assumeTrue(org.junit.Assume.assumeTrue) Node(org.hyperledger.besu.tests.acceptance.dsl.node.Node) Path(java.nio.file.Path) Collections(java.util.Collections) Before(org.junit.Before) JsonRpcIpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration) Before(org.junit.Before)

Example 4 with JsonRpcIpcConfiguration

use of org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration in project besu by hyperledger.

the class RunnerBuilderTest method noEngineApiNoServiceForMethods.

@Test
public void noEngineApiNoServiceForMethods() {
    JsonRpcConfiguration defaultRpcConfig = JsonRpcConfiguration.createDefault();
    defaultRpcConfig.setEnabled(true);
    WebSocketConfiguration defaultWebSockConfig = WebSocketConfiguration.createDefault();
    defaultWebSockConfig.setEnabled(true);
    EthNetworkConfig mockMainnet = mock(EthNetworkConfig.class);
    when(mockMainnet.getNetworkId()).thenReturn(BigInteger.ONE);
    MergeConfigOptions.setMergeEnabled(true);
    when(besuController.getMiningCoordinator()).thenReturn(mock(MergeMiningCoordinator.class));
    final Runner runner = new RunnerBuilder().discovery(true).p2pListenInterface("0.0.0.0").p2pListenPort(30303).p2pAdvertisedHost("127.0.0.1").p2pEnabled(true).natMethod(NatMethod.NONE).besuController(besuController).ethNetworkConfig(mockMainnet).metricsSystem(mock(ObservableMetricsSystem.class)).permissioningService(mock(PermissioningServiceImpl.class)).jsonRpcConfiguration(defaultRpcConfig).graphQLConfiguration(mock(GraphQLConfiguration.class)).webSocketConfiguration(defaultWebSockConfig).jsonRpcIpcConfiguration(mock(JsonRpcIpcConfiguration.class)).metricsConfiguration(mock(MetricsConfiguration.class)).vertx(Vertx.vertx()).dataDir(dataDir.getRoot().toPath()).storageProvider(mock(KeyValueStorageProvider.class)).forkIdSupplier(() -> Collections.singletonList(Bytes.EMPTY)).rpcEndpointService(new RpcEndpointServiceImpl()).besuPluginContext(mock(BesuPluginContextImpl.class)).build();
    assertThat(runner.getJsonRpcPort()).isPresent();
    assertThat(runner.getEngineJsonRpcPort()).isEmpty();
}
Also used : MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) PermissioningServiceImpl(org.hyperledger.besu.services.PermissioningServiceImpl) RpcEndpointServiceImpl(org.hyperledger.besu.services.RpcEndpointServiceImpl) KeyValueStorageProvider(org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider) InMemoryKeyValueStorageProvider(org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider) MergeMiningCoordinator(org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator) JsonRpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration) WebSocketConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration) EthNetworkConfig(org.hyperledger.besu.cli.config.EthNetworkConfig) JsonRpcIpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration) GraphQLConfiguration(org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration) Test(org.junit.Test)

Example 5 with JsonRpcIpcConfiguration

use of org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration in project besu by hyperledger.

the class RunnerBuilderTest method assertTransitionStratumConfiguration.

@Test
public void assertTransitionStratumConfiguration() {
    JsonRpcConfiguration jrpc = JsonRpcConfiguration.createDefault();
    jrpc.setEnabled(true);
    JsonRpcConfiguration engine = JsonRpcConfiguration.createEngineDefault();
    engine.setEnabled(true);
    EthNetworkConfig mockMainnet = mock(EthNetworkConfig.class);
    when(mockMainnet.getNetworkId()).thenReturn(BigInteger.ONE);
    MergeConfigOptions.setMergeEnabled(true);
    MiningParameters mockMiningParams = besuController.getMiningParameters();
    when(mockMiningParams.isStratumMiningEnabled()).thenReturn(true);
    TransitionCoordinator mockTransitionCoordinator = spy(new TransitionCoordinator(mock(PoWMiningCoordinator.class), mock(MergeMiningCoordinator.class)));
    when(besuController.getMiningCoordinator()).thenReturn(mockTransitionCoordinator);
    new RunnerBuilder().discovery(true).p2pListenInterface("0.0.0.0").p2pListenPort(30303).p2pAdvertisedHost("127.0.0.1").p2pEnabled(true).natMethod(NatMethod.NONE).besuController(besuController).ethNetworkConfig(mockMainnet).metricsSystem(mock(ObservableMetricsSystem.class)).permissioningService(mock(PermissioningServiceImpl.class)).jsonRpcConfiguration(jrpc).engineJsonRpcConfiguration(engine).graphQLConfiguration(mock(GraphQLConfiguration.class)).webSocketConfiguration(mock(WebSocketConfiguration.class)).jsonRpcIpcConfiguration(mock(JsonRpcIpcConfiguration.class)).metricsConfiguration(mock(MetricsConfiguration.class)).vertx(Vertx.vertx()).dataDir(dataDir.getRoot().toPath()).storageProvider(mock(KeyValueStorageProvider.class)).forkIdSupplier(() -> Collections.singletonList(Bytes.EMPTY)).rpcEndpointService(new RpcEndpointServiceImpl()).besuPluginContext(mock(BesuPluginContextImpl.class)).build();
    verify(mockTransitionCoordinator, times(1)).getPreMergeObject();
    verify(mockTransitionCoordinator, times(1)).addEthHashObserver(any());
}
Also used : MiningParameters(org.hyperledger.besu.ethereum.core.MiningParameters) TransitionCoordinator(org.hyperledger.besu.consensus.merge.blockcreation.TransitionCoordinator) RpcEndpointServiceImpl(org.hyperledger.besu.services.RpcEndpointServiceImpl) ObservableMetricsSystem(org.hyperledger.besu.metrics.ObservableMetricsSystem) KeyValueStorageProvider(org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider) InMemoryKeyValueStorageProvider(org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider) JsonRpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration) EthNetworkConfig(org.hyperledger.besu.cli.config.EthNetworkConfig) JsonRpcIpcConfiguration(org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration) GraphQLConfiguration(org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration) Test(org.junit.Test)

Aggregations

JsonRpcIpcConfiguration (org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration)6 EthNetworkConfig (org.hyperledger.besu.cli.config.EthNetworkConfig)4 GraphQLConfiguration (org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration)4 JsonRpcConfiguration (org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration)4 InMemoryKeyValueStorageProvider (org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider)4 RpcEndpointServiceImpl (org.hyperledger.besu.services.RpcEndpointServiceImpl)4 Test (org.junit.Test)4 Path (java.nio.file.Path)3 KeyValueStorageProvider (org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider)3 ObservableMetricsSystem (org.hyperledger.besu.metrics.ObservableMetricsSystem)3 MockitoJUnitRunner (org.mockito.junit.MockitoJUnitRunner)3 IOException (java.io.IOException)2 MergeMiningCoordinator (org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator)2 WebSocketConfiguration (org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration)2 MetricsConfiguration (org.hyperledger.besu.metrics.prometheus.MetricsConfiguration)2 PermissioningServiceImpl (org.hyperledger.besu.services.PermissioningServiceImpl)2 HttpClient (io.vertx.core.http.HttpClient)1 JsonObject (io.vertx.core.json.JsonObject)1 File (java.io.File)1 BigInteger (java.math.BigInteger)1