Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eth_getBlockByNumber with empty params returns #8134

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected BlockParameter blockParameter(final JsonRpcRequestContext request) {
return request.getRequiredParameter(0, BlockParameter.class);
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcParameters(
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e);
"Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,17 @@ public void returnsCorrectMethodName() {
@Test
public void exceptionWhenNoParamsSupplied() {
assertThatThrownBy(() -> method.response(requestWithParams()))
.isInstanceOf(InvalidJsonRpcParameters.class);
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasFieldOrPropertyWithValue("rpcErrorType", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS);
verifyNoMoreInteractions(blockchainQueries);
}

@Test
public void exceptionWhenNoNumberSupplied() {
assertThatThrownBy(() -> method.response(requestWithParams("false")))
.isInstanceOf(InvalidJsonRpcParameters.class);
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasFieldOrPropertyWithValue("rpcErrorType", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS);

verifyNoMoreInteractions(blockchainQueries);
}

Expand All @@ -129,7 +132,8 @@ public void exceptionWhenNoBoolSupplied() {
public void exceptionWhenNumberParamInvalid() {
assertThatThrownBy(() -> method.response(requestWithParams("invalid", "true")))
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Invalid block parameter (index 0)");
.hasMessage("Invalid block parameter (index 0)")
.hasFieldOrPropertyWithValue("rpcErrorType", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS);
verifyNoMoreInteractions(blockchainQueries);
}

Expand Down
Loading