Revert engine getclientversionv1 changes (#7546)

* Revert "Check for commit hash before appending another in build.gradle caclulateVersion (#7537)"

This reverts commit a8bbcd5d8b.

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* Revert engine_getClientVersionV1 changes

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

---------

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
This commit is contained in:
Matilda-Clerke
2024-08-30 16:01:43 +10:00
committed by GitHub
parent 892846aeab
commit 1ea1d4cede
23 changed files with 49 additions and 323 deletions

View File

@@ -11,7 +11,6 @@
- Add 'inbound' field to admin_peers JSON-RPC Call [#7461](https://github.com/hyperledger/besu/pull/7461)
- Add pending block header to `TransactionEvaluationContext` plugin API [#7483](https://github.com/hyperledger/besu/pull/7483)
- Add bootnode to holesky config [#7500](https://github.com/hyperledger/besu/pull/7500)
- Implement engine_getClientVersionV1 [#7512](https://github.com/hyperledger/besu/pull/7512)
- Performance optimzation for ECMUL (1 of 2) [#7509](https://github.com/hyperledger/besu/pull/7509)
- Performance optimzation for ECMUL (2 of 2) [#7543](https://github.com/hyperledger/besu/pull/7543)

View File

@@ -17,8 +17,6 @@ package org.hyperledger.besu;
import org.hyperledger.besu.util.platform.PlatformDetector;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Represent Besu information such as version, OS etc. Used with --version option and during Besu
@@ -26,29 +24,9 @@ import java.util.regex.Pattern;
*/
public final class BesuInfo {
private static final String CLIENT = "besu";
private static final String VERSION = BesuInfo.class.getPackage().getImplementationVersion();
private static final String OS = PlatformDetector.getOS();
private static final String VM = PlatformDetector.getVM();
private static final String VERSION;
private static final String COMMIT;
static {
String projectVersion = BesuInfo.class.getPackage().getImplementationVersion();
if (projectVersion == null) {
// protect against unset project version (e.g. unit tests being run, etc)
VERSION = null;
COMMIT = null;
} else {
Pattern pattern =
Pattern.compile("(?<version>\\d+\\.\\d+\\.?\\d?-?\\w*)-(?<commit>[0-9a-fA-F]{8})");
Matcher matcher = pattern.matcher(projectVersion);
if (matcher.find()) {
VERSION = matcher.group("version");
COMMIT = matcher.group("commit");
} else {
throw new RuntimeException("Invalid project version: " + projectVersion);
}
}
}
private BesuInfo() {}
@@ -68,7 +46,7 @@ public final class BesuInfo {
* or "besu/v23.1.0/osx-aarch_64/corretto-java-19"
*/
public static String version() {
return String.format("%s/v%s-%s/%s/%s", CLIENT, VERSION, COMMIT, OS, VM);
return String.format("%s/v%s/%s/%s", CLIENT, VERSION, OS, VM);
}
/**
@@ -79,18 +57,7 @@ public final class BesuInfo {
*/
public static String nodeName(final Optional<String> maybeIdentity) {
return maybeIdentity
.map(
identity ->
String.format("%s/%s/v%s-%s/%s/%s", CLIENT, identity, VERSION, COMMIT, OS, VM))
.map(identity -> String.format("%s/%s/v%s/%s/%s", CLIENT, identity, VERSION, OS, VM))
.orElse(version());
}
/**
* Generate the commit hash for this besu version
*
* @return the commit hash for this besu version
*/
public static String commit() {
return COMMIT;
}
}

View File

@@ -1291,8 +1291,6 @@ public class RunnerBuilder {
new JsonRpcMethodsFactory()
.methods(
BesuInfo.nodeName(identityString),
BesuInfo.shortVersion(),
BesuInfo.commit(),
ethNetworkConfig.networkId(),
besuController.getGenesisConfigOptions(),
network,

View File

@@ -33,8 +33,7 @@ public final class BesuInfoTest {
*/
@Test
public void versionStringIsEthstatsFriendly() {
assertThat(BesuInfo.version())
.matches("[^/]+/v(\\d+\\.\\d+\\.\\d+[^/]*|null-null)/[^/]+/[^/]+");
assertThat(BesuInfo.version()).matches("[^/]+/v(\\d+\\.\\d+\\.\\d+[^/]*|null)/[^/]+/[^/]+");
}
/**
@@ -46,7 +45,7 @@ public final class BesuInfoTest {
@Test
public void noIdentityNodeNameIsEthstatsFriendly() {
assertThat(BesuInfo.nodeName(Optional.empty()))
.matches("[^/]+/v(\\d+\\.\\d+\\.\\d+[^/]*|null-null)/[^/]+/[^/]+");
.matches("[^/]+/v(\\d+\\.\\d+\\.\\d+[^/]*|null)/[^/]+/[^/]+");
}
/**
@@ -59,6 +58,6 @@ public final class BesuInfoTest {
@Test
public void userIdentityNodeNameIsEthstatsFriendly() {
assertThat(BesuInfo.nodeName(Optional.of("TestUserIdentity")))
.matches("[^/]+/[^/]+/v(\\d+\\.\\d+\\.\\d+[^/]*|null-null)/[^/]+/[^/]+");
.matches("[^/]+/[^/]+/v(\\d+\\.\\d+\\.\\d+[^/]*|null)/[^/]+/[^/]+");
}
}

View File

@@ -823,7 +823,7 @@ task distDocker {
dockerPlatform = "--platform ${project.getProperty('docker-platform')}"
println "Building for platform ${project.getProperty('docker-platform')}"
}
def gitDetails = getGitCommitDetails()
def gitDetails = getGitCommitDetails(7)
executable shell
workingDir dockerBuildDir
args "-c", "docker build ${dockerPlatform} --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${gitDetails.hash} -t ${image} ."
@@ -990,18 +990,18 @@ def buildTime() {
@Memoized
def calculateVersion() {
// Regex pattern for basic calendar versioning, with provision to omit patch rev
def calVerPattern = ~/\d+\.\d+(\.\d+)?(-\w+)?$/
def calVerWithCommitPattern = ~/\d+\.\d+(\.\d+)?(-\w+)?-[0-9a-fA-F]{7,8}$/
def gitDetails = getGitCommitDetails() // Adjust length as needed
if (project.hasProperty('version') && project.version =~ calVerWithCommitPattern) {
println("Utilising supplied version as it appears to already contain commit hash: ${project.version}")
return project.version
} else if (project.hasProperty('version') && project.version =~ calVerPattern) {
println("Generating project version using supplied version: ${project.version}-${gitDetails.hash}")
return "${project.version}-${gitDetails.hash}"
} else {
def calVerPattern = ~/\d+\.\d+(\.\d+)?(-.*)?/
if (project.hasProperty('version') && (project.version =~ calVerPattern)) {
if (project.hasProperty('versionappendcommit') && project.versionappendcommit == "true") {
def gitDetails = getGitCommitDetails(7) // Adjust length as needed
return "${project.version}-${gitDetails.hash}"
}
return "${project.version}"
} else {
// If no version is supplied or it doesn't match the semantic versioning, calculate from git
println("Generating project version using date (${gitDetails.date}-develop-${gitDetails.hash}), as supplied version is not semver: ${project.version}")
println("Generating project version as supplied is version not semver: ${project.version}")
def gitDetails = getGitCommitDetails(7) // Adjust length as needed
return "${gitDetails.date}-develop-${gitDetails.hash}"
}
}

View File

@@ -64,9 +64,7 @@ import io.vertx.core.VertxOptions;
/** Provides a facade to construct the JSON-RPC component. */
public class JsonRpcTestMethodsFactory {
private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
private static final BigInteger NETWORK_ID = BigInteger.valueOf(123);
private final BlockchainImporter importer;
@@ -177,9 +175,7 @@ public class JsonRpcTestMethodsFactory {
return new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
NETWORK_ID,
new StubGenesisConfigOptions(),
peerDiscovery,

View File

@@ -63,7 +63,6 @@ public enum RpcMethod {
ENGINE_FORKCHOICE_UPDATED_V2("engine_forkchoiceUpdatedV2"),
ENGINE_FORKCHOICE_UPDATED_V3("engine_forkchoiceUpdatedV3"),
ENGINE_EXCHANGE_TRANSITION_CONFIGURATION("engine_exchangeTransitionConfigurationV1"),
ENGINE_GET_CLIENT_VERSION_V1("engine_getClientVersionV1"),
ENGINE_GET_PAYLOAD_BODIES_BY_HASH_V1("engine_getPayloadBodiesByHashV1"),
ENGINE_GET_PAYLOAD_BODIES_BY_RANGE_V1("engine_getPayloadBodiesByRangeV1"),
ENGINE_EXCHANGE_CAPABILITIES("engine_exchangeCapabilities"),

View File

@@ -1,57 +0,0 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetClientVersionResultV1;
import io.vertx.core.Vertx;
public class EngineGetClientVersionV1 extends ExecutionEngineJsonRpcMethod {
private static final String ENGINE_CLIENT_CODE = "BU";
private static final String ENGINE_CLIENT_NAME = "Besu";
private final String clientVersion;
private final String commit;
public EngineGetClientVersionV1(
final Vertx vertx,
final ProtocolContext protocolContext,
final EngineCallListener engineCallListener,
final String clientVersion,
final String commit) {
super(vertx, protocolContext, engineCallListener);
this.clientVersion = clientVersion;
this.commit = commit;
}
@Override
public String getName() {
return RpcMethod.ENGINE_GET_CLIENT_VERSION_V1.getMethodName();
}
@Override
public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) {
return new JsonRpcSuccessResponse(
request.getRequest().getId(),
new EngineGetClientVersionResultV1(
ENGINE_CLIENT_CODE, ENGINE_CLIENT_NAME, clientVersion, commit));
}
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;
import com.fasterxml.jackson.annotation.JsonGetter;
public class EngineGetClientVersionResultV1 {
private final String code;
private final String name;
private final String version;
private final String commit;
public EngineGetClientVersionResultV1(
final String code, final String name, final String version, final String commit) {
this.code = code;
this.name = name;
this.version = version;
this.commit = commit;
}
@JsonGetter(value = "code")
public String getCode() {
return code;
}
@JsonGetter(value = "name")
public String getName() {
return name;
}
@JsonGetter(value = "version")
public String getVersion() {
return version;
}
@JsonGetter(value = "commit")
public String getCommit() {
return commit;
}
}

View File

@@ -23,7 +23,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineE
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineForkchoiceUpdatedV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineForkchoiceUpdatedV2;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineForkchoiceUpdatedV3;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetClientVersionV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadBodiesByHashV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadBodiesByRangeV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV1;
@@ -58,17 +57,13 @@ public class ExecutionEngineJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final ProtocolContext protocolContext;
private final EthPeers ethPeers;
private final Vertx consensusEngineServer;
private final String clientVersion;
private final String commit;
ExecutionEngineJsonRpcMethods(
final MiningCoordinator miningCoordinator,
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final EthPeers ethPeers,
final Vertx consensusEngineServer,
final String clientVersion,
final String commit) {
final Vertx consensusEngineServer) {
this.mergeCoordinator =
Optional.ofNullable(miningCoordinator)
.filter(mc -> mc.isCompatibleWithEngineApi())
@@ -77,8 +72,6 @@ public class ExecutionEngineJsonRpcMethods extends ApiGroupJsonRpcMethods {
this.protocolContext = protocolContext;
this.ethPeers = ethPeers;
this.consensusEngineServer = consensusEngineServer;
this.clientVersion = clientVersion;
this.commit = commit;
}
@Override
@@ -154,9 +147,7 @@ public class ExecutionEngineJsonRpcMethods extends ApiGroupJsonRpcMethods {
new EngineExchangeCapabilities(
consensusEngineServer, protocolContext, engineQosTimer),
new EnginePreparePayloadDebug(
consensusEngineServer, protocolContext, engineQosTimer, mergeCoordinator.get()),
new EngineGetClientVersionV1(
consensusEngineServer, protocolContext, engineQosTimer, clientVersion, commit)));
consensusEngineServer, protocolContext, engineQosTimer, mergeCoordinator.get())));
if (protocolSchedule.anyMatch(p -> p.spec().getName().equalsIgnoreCase("cancun"))) {
executionEngineApisSupported.add(

View File

@@ -54,9 +54,7 @@ import io.vertx.core.Vertx;
public class JsonRpcMethodsFactory {
public Map<String, JsonRpcMethod> methods(
final String clientNodeName,
final String clientVersion,
final String commit,
final BigInteger networkId,
final GenesisConfigOptions genesisConfigOptions,
final P2PNetwork p2pNetwork,
@@ -91,7 +89,7 @@ public class JsonRpcMethodsFactory {
final List<JsonRpcMethods> availableApiGroups =
List.of(
new AdminJsonRpcMethods(
clientNodeName,
clientVersion,
networkId,
genesisConfigOptions,
p2pNetwork,
@@ -117,9 +115,7 @@ public class JsonRpcMethodsFactory {
protocolSchedule,
protocolContext,
ethPeers,
consensusEngineServer,
clientVersion,
commit),
consensusEngineServer),
new EthJsonRpcMethods(
blockchainQueries,
synchronizer,
@@ -145,7 +141,7 @@ public class JsonRpcMethodsFactory {
filterManager),
new PrivxJsonRpcMethods(
blockchainQueries, protocolSchedule, transactionPool, privacyParameters),
new Web3JsonRpcMethods(clientNodeName),
new Web3JsonRpcMethods(clientVersion),
new TraceJsonRpcMethods(
blockchainQueries, protocolSchedule, protocolContext, apiConfiguration),
new TxPoolJsonRpcMethods(transactionPool),

View File

@@ -75,9 +75,7 @@ public abstract class AbstractJsonRpcHttpServiceTest {
protected BlockchainSetupUtil blockchainSetupUtil;
protected static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
protected static final String CLIENT_VERSION = "0.1.0";
protected static final String CLIENT_COMMIT = "12345678";
protected static String CLIENT_VERSION = "TestClientVersion/0.1.0";
protected static final BigInteger NETWORK_ID = BigInteger.valueOf(123);
protected static final Collection<String> JSON_RPC_APIS =
Arrays.asList(
@@ -170,9 +168,7 @@ public abstract class AbstractJsonRpcHttpServiceTest {
return new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
NETWORK_ID,
new StubGenesisConfigOptions(),
peerDiscoveryMock,

View File

@@ -58,13 +58,13 @@ public class AdminJsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
final List<EthPeer> peerList = new ArrayList<>();
final PeerInfo info1 =
new PeerInfo(
4, CLIENT_NODE_NAME, caps, 30302, Bytes.fromHexString(String.format("%0128x", 1)));
4, CLIENT_VERSION, caps, 30302, Bytes.fromHexString(String.format("%0128x", 1)));
final PeerInfo info2 =
new PeerInfo(
4, CLIENT_NODE_NAME, caps, 60302, Bytes.fromHexString(String.format("%0128x", 2)));
4, CLIENT_VERSION, caps, 60302, Bytes.fromHexString(String.format("%0128x", 2)));
final PeerInfo info3 =
new PeerInfo(
4, CLIENT_NODE_NAME, caps, 60303, Bytes.fromHexString(String.format("%0128x", 3)));
4, CLIENT_VERSION, caps, 60303, Bytes.fromHexString(String.format("%0128x", 3)));
final InetSocketAddress addr30301 = new InetSocketAddress("localhost", 30301);
final InetSocketAddress addr30302 = new InetSocketAddress("localhost", 30302);
final InetSocketAddress addr60301 = new InetSocketAddress("localhost", 60301);

View File

@@ -79,9 +79,7 @@ public class JsonRpcHttpServiceHostAllowlistTest {
private static OkHttpClient client;
private static String baseUrl;
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
private static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
private final JsonRpcConfiguration jsonRpcConfig = createJsonRpcConfig();
@@ -102,9 +100,7 @@ public class JsonRpcHttpServiceHostAllowlistTest {
rpcMethods =
new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID,
new StubGenesisConfigOptions(),
peerDiscoveryMock,

View File

@@ -100,9 +100,7 @@ public class JsonRpcHttpServiceLoginTest {
protected static OkHttpClient client;
protected static String baseUrl;
protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
protected static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
protected static final String CLIENT_VERSION = "0.1.0";
protected static final String CLIENT_COMMIT = "12345678";
protected static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
protected static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
protected static P2PNetwork peerDiscoveryMock;
protected static BlockchainQueries blockchainQueries;
@@ -133,9 +131,7 @@ public class JsonRpcHttpServiceLoginTest {
rpcMethods =
new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID,
genesisConfigOptions,
peerDiscoveryMock,

View File

@@ -94,9 +94,7 @@ public class JsonRpcHttpServiceRpcApisTest {
private JsonRpcHttpService service;
private static String baseUrl;
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
private static final BigInteger NETWORK_ID = BigInteger.valueOf(123);
private JsonRpcConfiguration configuration;
private static final List<String> netServices =
@@ -204,9 +202,7 @@ public class JsonRpcHttpServiceRpcApisTest {
final Map<String, JsonRpcMethod> rpcMethods =
new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
NETWORK_ID,
new StubGenesisConfigOptions(),
mock(P2PNetwork.class),
@@ -314,9 +310,7 @@ public class JsonRpcHttpServiceRpcApisTest {
final Map<String, JsonRpcMethod> rpcMethods =
new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
NETWORK_ID,
new StubGenesisConfigOptions(),
p2pNetwork,

View File

@@ -202,7 +202,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id);
// Check result
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1127,7 +1127,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id);
// Check result
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1143,7 +1143,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
final JsonObject json = new JsonObject(resp.body().string());
testHelper.assertValidJsonRpcResult(json, id);
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1175,7 +1175,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, null);
// Check result
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1197,7 +1197,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id);
// Check result
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1218,7 +1218,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id);
// Check result
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1242,7 +1242,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id);
// Check result
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1268,7 +1268,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id);
// Check result
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1289,7 +1289,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
testHelper.assertValidJsonRpcResult(json, id);
// Check result
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1353,7 +1353,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
final JsonObject json = new JsonObject(resp.body().string());
testHelper.assertValidJsonRpcResult(json, id);
final String result = json.getString("result");
assertThat(result).isEqualTo(CLIENT_NODE_NAME);
assertThat(result).isEqualTo(CLIENT_VERSION);
}
}
@@ -1485,7 +1485,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
// Check result web3_clientVersion
final JsonObject jsonClientVersion = responses.get(clientVersionRequestId);
testHelper.assertValidJsonRpcResult(jsonClientVersion, clientVersionRequestId);
assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_NODE_NAME);
assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_VERSION);
// Check result unknown method
final JsonObject jsonError = responses.get(brokenRequestId);
@@ -1540,7 +1540,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
// Check result web3_clientVersion
final JsonObject jsonClientVersion = responses.get(clientVersionRequestId);
testHelper.assertValidJsonRpcResult(jsonClientVersion, clientVersionRequestId);
assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_NODE_NAME);
assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_VERSION);
// Check invalid request
final JsonObject jsonError = responses.get(invalidId);
@@ -1605,7 +1605,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
// Check result web3_clientVersion
final JsonObject jsonClientVersion = responses.get(clientVersionRequestId);
testHelper.assertValidJsonRpcResult(jsonClientVersion, clientVersionRequestId);
assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_NODE_NAME);
assertThat(jsonClientVersion.getString("result")).isEqualTo(CLIENT_VERSION);
// Check result net_version
final JsonObject jsonNetVersion = responses.get(netVersionRequestId);

View File

@@ -78,9 +78,7 @@ public class JsonRpcHttpServiceTestBase {
protected static OkHttpClient client;
protected static String baseUrl;
protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
protected static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
protected static final String CLIENT_VERSION = "0.1.0";
protected static final String CLIENT_COMMIT = "12345678";
protected static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
protected static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
protected static P2PNetwork peerDiscoveryMock;
protected static EthPeers ethPeersMock;
@@ -110,9 +108,7 @@ public class JsonRpcHttpServiceTestBase {
rpcMethods =
new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID,
new StubGenesisConfigOptions(),
peerDiscoveryMock,

View File

@@ -85,9 +85,7 @@ public class JsonRpcHttpServiceTlsClientAuthTest {
protected static final Vertx vertx = Vertx.vertx();
private static final String JSON_HEADER = "application/json; charset=utf-8";
private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
private static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
private static final NatService natService = new NatService(Optional.empty());
@@ -116,9 +114,7 @@ public class JsonRpcHttpServiceTlsClientAuthTest {
rpcMethods =
new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID,
new StubGenesisConfigOptions(),
peerDiscoveryMock,

View File

@@ -75,9 +75,7 @@ class JsonRpcHttpServiceTlsMisconfigurationTest {
protected static final Vertx vertx = Vertx.vertx();
private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
private static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
private static final NatService natService = new NatService(Optional.empty());
private final SelfSignedP12Certificate besuCertificate = SelfSignedP12Certificate.create();
@@ -104,9 +102,7 @@ class JsonRpcHttpServiceTlsMisconfigurationTest {
rpcMethods =
new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID,
new StubGenesisConfigOptions(),
peerDiscoveryMock,

View File

@@ -81,9 +81,7 @@ public class JsonRpcHttpServiceTlsTest {
protected static final Vertx vertx = Vertx.vertx();
private static final String JSON_HEADER = "application/json; charset=utf-8";
private static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
private static final String CLIENT_VERSION = "0.1.0";
private static final String CLIENT_COMMIT = "12345678";
private static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
private static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
private static final NatService natService = new NatService(Optional.empty());
private JsonRpcHttpService service;
@@ -105,9 +103,7 @@ public class JsonRpcHttpServiceTlsTest {
rpcMethods =
new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID,
new StubGenesisConfigOptions(),
peerDiscoveryMock,

View File

@@ -1,72 +0,0 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetClientVersionResultV1;
import io.vertx.core.Vertx;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
class EngineGetClientVersionV1Test {
private static final String ENGINE_CLIENT_CODE = "BU";
private static final String ENGINE_CLIENT_NAME = "Besu";
private static final String CLIENT_VERSION = "v25.6.7-dev-abcdef12";
private static final String COMMIT = "abcdef12";
private EngineGetClientVersionV1 getClientVersion;
@BeforeEach
void before() {
getClientVersion =
new EngineGetClientVersionV1(
Mockito.mock(Vertx.class),
Mockito.mock(ProtocolContext.class),
Mockito.mock(EngineCallListener.class),
CLIENT_VERSION,
COMMIT);
}
@Test
void testGetName() {
assertThat(getClientVersion.getName()).isEqualTo("engine_getClientVersionV1");
}
@Test
void testSyncResponse() {
JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("v", "m", null));
JsonRpcResponse actualResult = getClientVersion.syncResponse(request);
assertThat(actualResult).isInstanceOf(JsonRpcSuccessResponse.class);
JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) actualResult;
assertThat(successResponse.getResult()).isInstanceOf(EngineGetClientVersionResultV1.class);
EngineGetClientVersionResultV1 actualEngineGetClientVersionResultV1 =
(EngineGetClientVersionResultV1) successResponse.getResult();
assertThat(actualEngineGetClientVersionResultV1.getName()).isEqualTo(ENGINE_CLIENT_NAME);
assertThat(actualEngineGetClientVersionResultV1.getCode()).isEqualTo(ENGINE_CLIENT_CODE);
assertThat(actualEngineGetClientVersionResultV1.getVersion()).isEqualTo(CLIENT_VERSION);
assertThat(actualEngineGetClientVersionResultV1.getCommit()).isEqualTo(COMMIT);
}
}

View File

@@ -115,9 +115,7 @@ public class WebSocketServiceLoginTest {
protected static OkHttpClient client;
protected static String baseUrl;
protected static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
protected static final String CLIENT_NODE_NAME = "TestClientVersion/0.1.0";
protected static final String CLIENT_VERSION = "0.1.0";
protected static final String CLIENT_COMMIT = "12345678";
protected static final String CLIENT_VERSION = "TestClientVersion/0.1.0";
protected static final BigInteger CHAIN_ID = BigInteger.valueOf(123);
protected static P2PNetwork peerDiscoveryMock;
protected static BlockchainQueries blockchainQueries;
@@ -169,9 +167,7 @@ public class WebSocketServiceLoginTest {
spy(
new JsonRpcMethodsFactory()
.methods(
CLIENT_NODE_NAME,
CLIENT_VERSION,
CLIENT_COMMIT,
CHAIN_ID,
genesisConfigOptions,
peerDiscoveryMock,