From 49c6cbd1c32d46cea39ebd5d89804cf5204049ec Mon Sep 17 00:00:00 2001 From: Suyash Nayan <89125422+7suyash7@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:43:34 +0530 Subject: [PATCH] return list in engine_getClientVersionV1 response (#7663) Signed-off-by: 7suyash7 Signed-off-by: Sally MacFarlane Co-authored-by: Sally MacFarlane --- .../methods/engine/EngineGetClientVersionV1.java | 12 ++++++++---- .../engine/EngineGetClientVersionV1Test.java | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1.java index 149728186b..011ce577a6 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1.java @@ -22,6 +22,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetClientVersionResultV1; +import java.util.Collections; +import java.util.List; + import io.vertx.core.Vertx; public class EngineGetClientVersionV1 extends ExecutionEngineJsonRpcMethod { @@ -51,9 +54,10 @@ public class EngineGetClientVersionV1 extends ExecutionEngineJsonRpcMethod { public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) { String safeCommit = (commit != null && commit.length() >= 8) ? commit.substring(0, 8) : "unknown"; - return new JsonRpcSuccessResponse( - request.getRequest().getId(), - new EngineGetClientVersionResultV1( - ENGINE_CLIENT_CODE, ENGINE_CLIENT_NAME, clientVersion, safeCommit)); + List versions = + Collections.singletonList( + new EngineGetClientVersionResultV1( + ENGINE_CLIENT_CODE, ENGINE_CLIENT_NAME, clientVersion, safeCommit)); + return new JsonRpcSuccessResponse(request.getRequest().getId(), versions); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1Test.java index 1aa0def7e2..d1d53832c1 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1Test.java @@ -23,6 +23,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetClientVersionResultV1; +import java.util.List; + import io.vertx.core.Vertx; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -61,9 +63,18 @@ class EngineGetClientVersionV1Test { assertThat(actualResult).isInstanceOf(JsonRpcSuccessResponse.class); JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) actualResult; - assertThat(successResponse.getResult()).isInstanceOf(EngineGetClientVersionResultV1.class); + + assertThat(successResponse.getResult()).isInstanceOf(List.class); + + List resultList = (List) successResponse.getResult(); + assertThat(resultList).hasSize(1); + + Object firstElement = resultList.get(0); + assertThat(firstElement).isInstanceOf(EngineGetClientVersionResultV1.class); + EngineGetClientVersionResultV1 actualEngineGetClientVersionResultV1 = - (EngineGetClientVersionResultV1) successResponse.getResult(); + (EngineGetClientVersionResultV1) firstElement; + assertThat(actualEngineGetClientVersionResultV1.getName()).isEqualTo(ENGINE_CLIENT_NAME); assertThat(actualEngineGetClientVersionResultV1.getCode()).isEqualTo(ENGINE_CLIENT_CODE); assertThat(actualEngineGetClientVersionResultV1.getVersion()).isEqualTo(CLIENT_VERSION);