RPC: Improve unsupported transaction error message (#28249)

This commit is contained in:
Justin Starry 2022-10-06 17:12:56 +08:00 committed by GitHub
parent 40ebebe140
commit db37d6b2ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -195,7 +195,12 @@ impl From<RpcCustomError> for Error {
},
RpcCustomError::UnsupportedTransactionVersion(version) => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION),
message: format!("Transaction version ({}) is not supported", version),
message: format!(
"Transaction version ({0}) is not supported by the requesting client. \
Please try the request again with the following configuration parameter: \
\"maxSupportedTransactionVersion\": {0}",
version
),
data: None,
},
RpcCustomError::MinContextSlotNotReached { context_slot } => Self {

View File

@ -6753,7 +6753,11 @@ pub mod tests {
let response = parse_failure_response(rpc.handle_request_sync(request));
let expected = (
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION,
String::from("Transaction version (0) is not supported"),
String::from(
"Transaction version (0) is not supported by the requesting client. \
Please try the request again with the following configuration parameter: \
\"maxSupportedTransactionVersion\": 0",
),
);
assert_eq!(response, expected);
}