mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 09:29:38 +00:00
Merge pull request #3199 from nspcc-dev/fix-err
neorpc: adjust common error messages
This commit is contained in:
commit
5e220754d7
4 changed files with 9 additions and 9 deletions
|
@ -282,13 +282,13 @@ func NewError(code int64, message string, data string) *Error {
|
|||
// NewParseError creates a new error with code
|
||||
// -32700.
|
||||
func NewParseError(data string) *Error {
|
||||
return NewError(BadRequestCode, "Parse Error", data)
|
||||
return NewError(BadRequestCode, "Parse error", data)
|
||||
}
|
||||
|
||||
// NewInvalidRequestError creates a new error with
|
||||
// code -32600.
|
||||
func NewInvalidRequestError(data string) *Error {
|
||||
return NewError(InvalidRequestCode, "Invalid Request", data)
|
||||
return NewError(InvalidRequestCode, "Invalid request", data)
|
||||
}
|
||||
|
||||
// NewMethodNotFoundError creates a new error with
|
||||
|
@ -300,7 +300,7 @@ func NewMethodNotFoundError(data string) *Error {
|
|||
// NewInvalidParamsError creates a new error with
|
||||
// code -32602.
|
||||
func NewInvalidParamsError(data string) *Error {
|
||||
return NewError(InvalidParamsCode, "Invalid Params", data)
|
||||
return NewError(InvalidParamsCode, "Invalid params", data)
|
||||
}
|
||||
|
||||
// NewInternalServerError creates a new error with
|
||||
|
|
|
@ -1456,7 +1456,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
|
|||
},
|
||||
},
|
||||
},
|
||||
`{"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params"}}`: {
|
||||
`{"id":1,"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params"}}`: {
|
||||
{
|
||||
name: "getapplicationlog_invalid_params_error",
|
||||
invoke: func(c *Client) (any, error) {
|
||||
|
|
|
@ -83,7 +83,7 @@ func TestWSClientSubscription(t *testing.T) {
|
|||
t.Run("bad", func(t *testing.T) {
|
||||
for name, f := range cases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
srv := initTestServer(t, `{"jsonrpc": "2.0", "id": 1, "error":{"code":-32602,"message":"Invalid Params"}}`)
|
||||
srv := initTestServer(t, `{"jsonrpc": "2.0", "id": 1, "error":{"code":-32602,"message":"Invalid params"}}`)
|
||||
wsc, err := NewWS(context.TODO(), httpURLtoWS(srv.URL), WSOptions{})
|
||||
require.NoError(t, err)
|
||||
wsc.getNextRequestID = getTestRequestID
|
||||
|
@ -118,7 +118,7 @@ func TestWSClientUnsubscription(t *testing.T) {
|
|||
err := wsc.Unsubscribe("0")
|
||||
require.Error(t, err)
|
||||
}},
|
||||
"error returned": {`{"jsonrpc": "2.0", "id": 1, "error":{"code":-32602,"message":"Invalid Params"}}`, func(t *testing.T, wsc *WSClient) {
|
||||
"error returned": {`{"jsonrpc": "2.0", "id": 1, "error":{"code":-32602,"message":"Invalid params"}}`, func(t *testing.T, wsc *WSClient) {
|
||||
// We can't really subscribe using this stub server, so set up wsc internals.
|
||||
wsc.subscriptions["0"] = &blockReceiver{}
|
||||
err := wsc.Unsubscribe("0")
|
||||
|
|
|
@ -3148,15 +3148,15 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
t.Run("calculatenetworkfee", func(t *testing.T) {
|
||||
t.Run("no parameters", func(t *testing.T) {
|
||||
body := doRPCCall(`{"jsonrpc": "2.0", "id": 1, "method": "calculatenetworkfee", "params": []}"`, httpSrv.URL, t)
|
||||
_ = checkErrGetResult(t, body, true, neorpc.InvalidParamsCode, "Invalid Params")
|
||||
_ = checkErrGetResult(t, body, true, neorpc.InvalidParamsCode, "Invalid params")
|
||||
})
|
||||
t.Run("non-base64 parameter", func(t *testing.T) {
|
||||
body := doRPCCall(`{"jsonrpc": "2.0", "id": 1, "method": "calculatenetworkfee", "params": ["noatbase64"]}"`, httpSrv.URL, t)
|
||||
_ = checkErrGetResult(t, body, true, neorpc.InvalidParamsCode, "Invalid Params")
|
||||
_ = checkErrGetResult(t, body, true, neorpc.InvalidParamsCode, "Invalid params")
|
||||
})
|
||||
t.Run("non-transaction parameter", func(t *testing.T) {
|
||||
body := doRPCCall(`{"jsonrpc": "2.0", "id": 1, "method": "calculatenetworkfee", "params": ["bm90IGEgdHJhbnNhY3Rpb24K"]}"`, httpSrv.URL, t)
|
||||
_ = checkErrGetResult(t, body, true, neorpc.InvalidParamsCode, "Invalid Params")
|
||||
_ = checkErrGetResult(t, body, true, neorpc.InvalidParamsCode, "Invalid params")
|
||||
})
|
||||
calcReq := func(t *testing.T, tx *transaction.Transaction) []byte {
|
||||
rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "calculatenetworkfee", "params": ["%s"]}"`, base64.StdEncoding.EncodeToString(tx.Bytes()))
|
||||
|
|
Loading…
Reference in a new issue