Skip to content

Commit

Permalink
return list in engine_getClientVersionV1 response (#7663)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
7suyash7 and macfarla authored Oct 3, 2024
1 parent 63b9ec9 commit 49c6cbd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
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 {
Expand Down Expand Up @@ -51,9 +54,10 @@ public String getName() {
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<EngineGetClientVersionResultV1> versions =
Collections.singletonList(
new EngineGetClientVersionResultV1(
ENGINE_CLIENT_CODE, ENGINE_CLIENT_NAME, clientVersion, safeCommit));
return new JsonRpcSuccessResponse(request.getRequest().getId(), versions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
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;
Expand Down Expand Up @@ -61,9 +63,18 @@ void testSyncResponse() {

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);
Expand Down

0 comments on commit 49c6cbd

Please sign in to comment.