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

5098 branch 2 update invalid accounts params #7402

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e41cf31
5098: Add RpcErrorTypes
Matilda-Clerke Jul 29, 2024
147d580
5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestExcept…
Matilda-Clerke Jul 29, 2024
8da4815
5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestExcept…
Matilda-Clerke Jul 30, 2024
8ca34d7
5098: Add JsonRpcParameterException for later use
Matilda-Clerke Jul 30, 2024
5b5631a
5098: Update locations for RpcErrorType.INVALID_ACCOUNTS_PARAMS
Matilda-Clerke Jul 30, 2024
950117b
5098: Address review comments, apply spotless
Matilda-Clerke Jul 30, 2024
0004fa2
Merge branch 'refs/heads/5098-branch-1-add-rpc-error-types' into 5098…
Matilda-Clerke Jul 30, 2024
7fc2c2b
5098: Update with changes from branch 1
Matilda-Clerke Jul 30, 2024
b70da06
Merge branch 'main' into 5098-branch-1-add-rpc-error-types
Matilda-Clerke Jul 30, 2024
5acb2d7
5098: apply spotless
Matilda-Clerke Jul 30, 2024
0d4a9b3
5098: Update plugin-api gradle hash
Matilda-Clerke Jul 30, 2024
ad7d7b3
Merge branch 'refs/heads/5098-branch-1-add-rpc-error-types' into 5098…
Matilda-Clerke Jul 30, 2024
9ba006b
5098: Add comment on INVALID_PARAMS_ERROR_CODE
Matilda-Clerke Jul 30, 2024
531c530
5098: Apply spotless on latest changes
Matilda-Clerke Jul 30, 2024
e946b06
Merge branch 'main' into 5098-branch-1-add-rpc-error-types
Matilda-Clerke Jul 30, 2024
b0dc1a8
Merge branch 'refs/heads/5098-branch-1-add-rpc-error-types' into 5098…
Matilda-Clerke Jul 30, 2024
983ac77
Merge branch 'main' into 5098-branch-2-update-invalid-accounts-params
Matilda-Clerke Jul 30, 2024
728ab2c
5098: Fix broken unit test
Matilda-Clerke Jul 30, 2024
6480308
Merge remote-tracking branch 'origin/5098-branch-2-update-invalid-acc…
Matilda-Clerke Jul 30, 2024
0fb6919
5098: Fix broken unit test
Matilda-Clerke Jul 31, 2024
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 @@ -16,6 +16,7 @@

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;
Expand Down Expand Up @@ -44,7 +45,13 @@ public String getName() {
@Override
@SuppressWarnings("unchecked")
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final List<String> accountsList = requestContext.getRequiredParameter(0, List.class);
final List<String> accountsList;
try {
accountsList = requestContext.getRequiredParameter(0, List.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid accounts list parameter", RpcErrorType.INVALID_ACCOUNT_PARAMS, e);
}

if (allowlistController.isPresent()) {
final AllowlistOperationResult addResult =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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;
Expand Down Expand Up @@ -44,7 +45,14 @@ public String getName() {
@Override
@SuppressWarnings("unchecked")
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final List<String> accountsList = requestContext.getRequiredParameter(0, List.class);
final List<String> accountsList;
try {
accountsList = requestContext.getRequiredParameter(0, List.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid accounts list parameter", RpcErrorType.INVALID_ACCOUNT_PARAMS, e);
}

if (allowlistController.isPresent()) {
final AllowlistOperationResult removeResult =
allowlistController.get().removeAccounts(accountsList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ public void whenEmptyParamOnRequestShouldThrowInvalidJsonRpcException() {

final Throwable thrown = catchThrowable(() -> method.response(request));
assertThat(thrown)
.hasNoCause()
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid accounts list parameter");
}

private JsonRpcRequestContext request(final List<String> accounts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ public void whenEmptyParamOnRequestShouldThrowInvalidJsonRpcException() {

final Throwable thrown = catchThrowable(() -> method.response(request));
assertThat(thrown)
.hasNoCause()
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid accounts list parameter");
}

private JsonRpcRequestContext request(final List<String> accounts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ public void whenEmptyParamOnRequestShouldThrowInvalidJsonRpcException() {

final Throwable thrown = catchThrowable(() -> method.response(request));
assertThat(thrown)
.hasNoCause()
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid accounts list parameter");
}

private JsonRpcRequestContext request(final List<String> accounts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ public void whenEmptyParamOnRequestShouldThrowInvalidJsonRpcException() {

final Throwable thrown = catchThrowable(() -> method.response(request));
assertThat(thrown)
.hasNoCause()
.isInstanceOf(InvalidJsonRpcParameters.class)
.hasMessage("Missing required json rpc parameter at index 0");
.hasMessage("Invalid accounts list parameter");
}

private JsonRpcRequestContext request(final List<String> accounts) {
Expand Down
Loading