5098 branch 11 update invalid block hash params (#7421)

* 5098: Add RpcErrorTypes

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

---------

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
Signed-off-by: Matilda-Clerke <matilda.clerke@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/7452/head
Matilda-Clerke 4 months ago committed by GitHub
parent 47fff38cf6
commit fab239341d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/CliqueGetSignersAtHash.java
  2. 2
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/jsonrpc/methods/CliqueGetSignersAtHashTest.java
  3. 10
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/methods/IbftGetValidatorsByBlockHash.java
  4. 10
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/jsonrpc/methods/QbftGetValidatorsByBlockHash.java
  5. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AbstractBlockParameterOrBlockHashMethod.java
  6. 9
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBadBlockToFile.java
  7. 9
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStandardTraceBlockToFile.java
  8. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHash.java
  9. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByHash.java
  10. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockTransactionCountByHash.java
  11. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockHash.java
  12. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetUncleByBlockHashAndIndex.java
  13. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetUncleCountByBlockHash.java
  14. 9
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadBodiesByHashV1.java
  15. 10
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTest.java
  16. 3
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByHashTest.java
  17. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetMinerDataByBlockHashTest.java
  18. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetUncleByBlockHashAndIndexTest.java
  19. 2
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getBlockTransactionCountByHash_invalidParams.json

@ -18,6 +18,7 @@ import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -67,7 +68,13 @@ public class CliqueGetSignersAtHash implements JsonRpcMethod {
}
private Optional<BlockHeader> determineBlockHeader(final JsonRpcRequestContext request) {
final Hash hash = request.getRequiredParameter(0, Hash.class);
final Hash hash;
try {
hash = request.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
return blockchainQueries.blockByHash(hash).map(BlockWithMetadata::getHeader);
}
}

@ -101,7 +101,7 @@ public class CliqueGetSignersAtHashTest {
assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid block hash parameter (index 0)");
}
@Test

@ -18,9 +18,11 @@ import org.hyperledger.besu.consensus.common.BlockInterface;
import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
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.response.RpcErrorType;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -61,7 +63,13 @@ public class IbftGetValidatorsByBlockHash implements JsonRpcMethod {
}
private Object blockResult(final JsonRpcRequestContext request) {
final Hash hash = request.getRequiredParameter(0, Hash.class);
final Hash hash;
try {
hash = request.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
LOG.trace("Received RPC rpcName={} blockHash={}", getName(), hash);
final Optional<BlockHeader> blockHeader = blockchain.getBlockHeader(hash);
return blockHeader

@ -19,9 +19,11 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
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.response.RpcErrorType;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -62,7 +64,13 @@ public class QbftGetValidatorsByBlockHash implements JsonRpcMethod {
}
private Object blockResult(final JsonRpcRequestContext request) {
final Hash hash = request.getRequiredParameter(0, Hash.class);
final Hash hash;
try {
hash = request.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
LOG.trace("Received RPC rpcName={} blockHash={}", getName(), hash);
final Optional<BlockHeader> blockHeader = blockchain.getBlockHeader(hash);
return blockHeader

@ -123,7 +123,7 @@ public abstract class AbstractBlockParameterOrBlockHashMethod implements JsonRpc
Optional<Hash> blockHash = blockParameterOrBlockHash.getHash();
if (blockHash.isEmpty()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS);
requestContext.getRequest().getId(), RpcErrorType.INVALID_BLOCK_HASH_PARAMS);
}
// return error if block hash does not find a block

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
@ -52,7 +53,13 @@ public class DebugStandardTraceBadBlockToFile extends DebugStandardTraceBlockToF
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Hash blockHash = requestContext.getRequiredParameter(0, Hash.class);
final Hash blockHash;
try {
blockHash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
final Optional<TransactionTraceParams> transactionTraceParams =
requestContext.getOptionalParameter(1, TransactionTraceParams.class);

@ -19,6 +19,7 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Trans
import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer;
@ -59,7 +60,13 @@ public class DebugStandardTraceBlockToFile implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Hash blockHash = requestContext.getRequiredParameter(0, Hash.class);
final Hash blockHash;
try {
blockHash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
final Optional<TransactionTraceParams> transactionTraceParams =
requestContext.getOptionalParameter(1, TransactionTraceParams.class);

@ -17,12 +17,14 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTrace;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
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.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.DebugTraceTransactionResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.debug.TraceOptions;
@ -50,7 +52,13 @@ public class DebugTraceBlockByHash implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Hash blockHash = requestContext.getRequiredParameter(0, Hash.class);
final Hash blockHash;
try {
blockHash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
final TraceOptions traceOptions =
requestContext
.getOptionalParameter(1, TransactionTraceParams.class)

@ -17,8 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
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.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -59,7 +61,13 @@ public class EthGetBlockByHash implements JsonRpcMethod {
}
private BlockResult blockResult(final JsonRpcRequestContext request) {
final Hash hash = request.getRequiredParameter(0, Hash.class);
final Hash hash;
try {
hash = request.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
if (isCompleteTransactions(request)) {
return transactionComplete(hash);

@ -17,8 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
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.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -37,7 +39,15 @@ public class EthGetBlockTransactionCountByHash implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block header hash parameter (index 0)",
RpcErrorType.INVALID_BLOCK_HASH_PARAMS,
e);
}
final Integer count = blockchain.getTransactionCount(hash);
if (count == -1) {

@ -18,8 +18,10 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
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.exception.InvalidJsonRpcParameters;
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.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.ImmutableMinerDataResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.ImmutableUncleRewardResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.MinerDataResult;
@ -60,7 +62,13 @@ public class EthGetMinerDataByBlockHash implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Hash hash = requestContext.getRequest().getRequiredParameter(0, Hash.class);
final Hash hash;
try {
hash = requestContext.getRequest().getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
BlockWithMetadata<TransactionWithMetadata, Hash> block =
blockchain.get().blockByHash(hash).orElse(null);

@ -17,9 +17,11 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedIntParameter;
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.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.UncleBlockResult;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -44,7 +46,13 @@ public class EthGetUncleByBlockHashAndIndex implements JsonRpcMethod {
}
private BlockResult blockResult(final JsonRpcRequestContext requestContext) {
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
final int index = requestContext.getRequiredParameter(1, UnsignedIntParameter.class).getValue();
return blockchain.getOmmer(hash, index).map(UncleBlockResult::build).orElse(null);

@ -17,8 +17,10 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
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.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
@ -37,7 +39,13 @@ public class EthGetUncleCountByBlockHash implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Hash hash = requestContext.getRequiredParameter(0, Hash.class);
final Hash hash;
try {
hash = requestContext.getRequiredParameter(0, Hash.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameter (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
final String result = blockchain.getOmmerCount(hash).map(Quantity::create).orElse(null);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result);
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash;
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.exception.InvalidJsonRpcParameters;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
@ -60,7 +61,13 @@ public class EngineGetPayloadBodiesByHashV1 extends ExecutionEngineJsonRpcMethod
final Object reqId = request.getRequest().getId();
final Hash[] blockHashes = request.getRequiredParameter(0, Hash[].class);
final Hash[] blockHashes;
try {
blockHashes = request.getRequiredParameter(0, Hash[].class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid block hash parameters (index 0)", RpcErrorType.INVALID_BLOCK_HASH_PARAMS, e);
}
LOG.atTrace()
.setMessage("{} parameters: blockHashes {}")

@ -760,7 +760,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
assertThat(resp.code()).isEqualTo(200);
// Check general format of result
final JsonObject json = new JsonObject(resp.body().string());
final RpcErrorType expectedError = RpcErrorType.INVALID_PARAMS;
final RpcErrorType expectedError = RpcErrorType.INVALID_BLOCK_HASH_PARAMS;
testHelper.assertValidJsonRpcError(
json, id, expectedError.getCode(), expectedError.getMessage());
}
@ -807,7 +807,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
assertThat(resp.code()).isEqualTo(200);
// Check general format of result
final JsonObject json = new JsonObject(resp.body().string());
final RpcErrorType expectedError = RpcErrorType.INVALID_PARAMS;
final RpcErrorType expectedError = RpcErrorType.INVALID_BLOCK_HASH_PARAMS;
testHelper.assertValidJsonRpcError(
json, id, expectedError.getCode(), expectedError.getMessage());
}
@ -830,7 +830,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
assertThat(resp.code()).isEqualTo(200);
// Check general format of result
final JsonObject json = new JsonObject(resp.body().string());
final RpcErrorType expectedError = RpcErrorType.INVALID_PARAMS;
final RpcErrorType expectedError = RpcErrorType.INVALID_BLOCK_HASH_PARAMS;
testHelper.assertValidJsonRpcError(
json, id, expectedError.getCode(), expectedError.getMessage());
}
@ -874,7 +874,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
assertThat(resp.code()).isEqualTo(200);
// Check general format of result
final JsonObject json = new JsonObject(resp.body().string());
final RpcErrorType expectedError = RpcErrorType.INVALID_PARAMS;
final RpcErrorType expectedError = RpcErrorType.INVALID_BLOCK_HASH_PARAMS;
testHelper.assertValidJsonRpcError(
json, id, expectedError.getCode(), expectedError.getMessage());
}
@ -894,7 +894,7 @@ public class JsonRpcHttpServiceTest extends JsonRpcHttpServiceTestBase {
assertThat(resp.code()).isEqualTo(200);
// Check general format of result
final JsonObject json = new JsonObject(resp.body().string());
final RpcErrorType expectedError = RpcErrorType.INVALID_PARAMS;
final RpcErrorType expectedError = RpcErrorType.INVALID_BLOCK_HASH_PARAMS;
testHelper.assertValidJsonRpcError(
json, id, expectedError.getCode(), expectedError.getMessage());
}

@ -77,8 +77,7 @@ public class EthGetBlockByHashTest {
public void exceptionWhenHashParamInvalid() {
assertThatThrownBy(() -> method.response(requestWithParams("hash", "true")))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage(
"Invalid json rpc parameter at index 0. Supplied value was: 'hash' of type: 'java.lang.String' - expected type: 'org.hyperledger.besu.datatypes.Hash'");
.hasMessage("Invalid block hash parameter (index 0)");
verifyNoMoreInteractions(blockchainQueries);
}

@ -109,7 +109,7 @@ public class EthGetMinerDataByBlockHashTest {
JsonRpcRequestContext requestContext = new JsonRpcRequestContext(request);
assertThatThrownBy(() -> method.response(requestContext))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid block hash parameter (index 0)");
verifyNoMoreInteractions(blockchainQueries);
}
@ -120,7 +120,7 @@ public class EthGetMinerDataByBlockHashTest {
JsonRpcRequestContext requestContext = new JsonRpcRequestContext(request);
assertThatThrownBy(() -> method.response(requestContext))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessageContaining("Invalid json rpc parameter at index 0");
.hasMessageContaining("Invalid block hash parameter (index 0)");
verifyNoMoreInteractions(blockchainQueries);
}

@ -79,7 +79,7 @@ public class EthGetUncleByBlockHashAndIndexTest {
assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid block hash parameter (index 0)");
}
@Test
@ -101,7 +101,7 @@ public class EthGetUncleByBlockHashAndIndexTest {
assertThat(thrown)
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessageContaining("Invalid json rpc parameter at index 0");
.hasMessageContaining("Invalid block hash parameter (index 0)");
}
@Test

@ -10,7 +10,7 @@
"id": 209,
"error": {
"code" : -32602,
"message" : "Invalid params"
"message" : "Invalid block hash params"
}
},
"statusCode": 200

Loading…
Cancel
Save