Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
eth_protocolVersion is a Quantity, not an Integer (#1470)
Browse files Browse the repository at this point in the history
Per the eth JSON-RPC spec all values are strings, not raw json numbers, hence eth_protocolVersion is a Quantity ("0x3f"), not an Integer (63)
  • Loading branch information
Danno Ferrin authored May 20, 2019
1 parent 51cc362 commit 0ef1d8f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.Quantity;
import tech.pegasys.pantheon.ethereum.p2p.wire.Capability;

import java.util.OptionalInt;
Expand All @@ -42,6 +43,7 @@ public String getName() {

@Override
public JsonRpcResponse response(final JsonRpcRequest req) {
return new JsonRpcSuccessResponse(req.getId(), highestEthVersion);
return new JsonRpcSuccessResponse(
req.getId(), highestEthVersion == null ? null : Quantity.create(highestEthVersion));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.EthNewBlockFilter;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.EthNewFilter;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.EthNewPendingTransactionFilter;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.EthProtocolVersion;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.EthSendRawTransaction;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.EthUninstallFilter;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod;
Expand Down Expand Up @@ -235,6 +236,8 @@ public static Collection<String> specs() {
specs.put(EthEstimateGas.class, "eth_estimateGas_noParams");
specs.put(EthEstimateGas.class, "eth_estimateGas_insufficientGas");

specs.put(EthProtocolVersion.class, "eth_protocolVersion");

return specs.values();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void shouldReturn63WhenMaxProtocolIsETH63() {
setupSupportedEthProtocols();

final JsonRpcRequest request = requestWithParams();
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getId(), 63);
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getId(), "0x3f");
final JsonRpcResponse actualResponse = method.response(request);
assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
}
Expand All @@ -69,7 +69,7 @@ public void shouldReturn63WhenMixedProtocolsSupported() {
method = new EthProtocolVersion(supportedCapabilities);

final JsonRpcRequest request = requestWithParams();
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getId(), 63);
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getId(), "0x3f");
final JsonRpcResponse actualResponse = method.response(request);
assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"request": {
"id": 2,
"jsonrpc": "2.0",
"method": "eth_protocolVersion",
"params": []
},
"response": {
"jsonrpc": "2.0",
"id": 2,
"result": "0x3f"
},
"statusCode": 200
}

0 comments on commit 0ef1d8f

Please sign in to comment.