Skip to content

Commit 49c6cbd

Browse files
7suyash7macfarla
andauthored
return list in engine_getClientVersionV1 response (#7663)
Signed-off-by: 7suyash7 <suyashnyn1@gmail.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
1 parent 63b9ec9 commit 49c6cbd

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
2323
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetClientVersionResultV1;
2424

25+
import java.util.Collections;
26+
import java.util.List;
27+
2528
import io.vertx.core.Vertx;
2629

2730
public class EngineGetClientVersionV1 extends ExecutionEngineJsonRpcMethod {
@@ -51,9 +54,10 @@ public String getName() {
5154
public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) {
5255
String safeCommit =
5356
(commit != null && commit.length() >= 8) ? commit.substring(0, 8) : "unknown";
54-
return new JsonRpcSuccessResponse(
55-
request.getRequest().getId(),
56-
new EngineGetClientVersionResultV1(
57-
ENGINE_CLIENT_CODE, ENGINE_CLIENT_NAME, clientVersion, safeCommit));
57+
List<EngineGetClientVersionResultV1> versions =
58+
Collections.singletonList(
59+
new EngineGetClientVersionResultV1(
60+
ENGINE_CLIENT_CODE, ENGINE_CLIENT_NAME, clientVersion, safeCommit));
61+
return new JsonRpcSuccessResponse(request.getRequest().getId(), versions);
5862
}
5963
}

ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetClientVersionV1Test.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
2424
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EngineGetClientVersionResultV1;
2525

26+
import java.util.List;
27+
2628
import io.vertx.core.Vertx;
2729
import org.junit.jupiter.api.BeforeEach;
2830
import org.junit.jupiter.api.Test;
@@ -61,9 +63,18 @@ void testSyncResponse() {
6163

6264
assertThat(actualResult).isInstanceOf(JsonRpcSuccessResponse.class);
6365
JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) actualResult;
64-
assertThat(successResponse.getResult()).isInstanceOf(EngineGetClientVersionResultV1.class);
66+
67+
assertThat(successResponse.getResult()).isInstanceOf(List.class);
68+
69+
List<?> resultList = (List<?>) successResponse.getResult();
70+
assertThat(resultList).hasSize(1);
71+
72+
Object firstElement = resultList.get(0);
73+
assertThat(firstElement).isInstanceOf(EngineGetClientVersionResultV1.class);
74+
6575
EngineGetClientVersionResultV1 actualEngineGetClientVersionResultV1 =
66-
(EngineGetClientVersionResultV1) successResponse.getResult();
76+
(EngineGetClientVersionResultV1) firstElement;
77+
6778
assertThat(actualEngineGetClientVersionResultV1.getName()).isEqualTo(ENGINE_CLIENT_NAME);
6879
assertThat(actualEngineGetClientVersionResultV1.getCode()).isEqualTo(ENGINE_CLIENT_CODE);
6980
assertThat(actualEngineGetClientVersionResultV1.getVersion()).isEqualTo(CLIENT_VERSION);

0 commit comments

Comments
 (0)