Fix tests in rpc module

pull/3907/head
harjas 3 years ago
parent c2a2dc7238
commit 2b2b32fe10
  1. 2
      eth/rpc/client.go
  2. 3
      eth/rpc/json.go
  3. 2
      eth/rpc/testdata/invalid-syntax.json

@ -300,7 +300,7 @@ func (c *Client) CallContext(ctx context.Context, result interface{}, method str
case len(resp.Result) == 0:
return ErrNoResult
default:
return json.Unmarshal(resp.Result, &result)
return json.Unmarshal(resp.Result, result)
}
}

@ -19,6 +19,7 @@ package rpc
import (
"bytes"
"context"
std_json "encoding/json"
"errors"
"fmt"
"github.com/goccy/go-json"
@ -239,7 +240,7 @@ func parseMessage(raw json.RawMessage) ([]*jsonrpcMessage, bool) {
json.Unmarshal(raw, &msgs[0])
return msgs, false
}
dec := json.NewDecoder(bytes.NewReader(raw))
dec := std_json.NewDecoder(bytes.NewReader(raw))
dec.Token() // skip '['
var msgs []*jsonrpcMessage
for dec.More() {

@ -1,5 +1,5 @@
// This test checks that an error is written for invalid JSON requests.
--> 'f
<-- {"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"invalid character '\\'' looking for beginning of value"}}
<-- {"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"json: invalid character \n as bool(false)"}}

Loading…
Cancel
Save