Skip to content

Commit 4a4d86c

Browse files
committed
Update requirements.
1 parent 82ff7c7 commit 4a4d86c

File tree

4 files changed

+31
-35
lines changed

4 files changed

+31
-35
lines changed

ethrpc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"log"
99
"math/big"
1010
"net/http"
@@ -102,7 +102,7 @@ func (rpc *EthRPC) Call(method string, params ...interface{}) (json.RawMessage,
102102
return nil, err
103103
}
104104

105-
data, err := ioutil.ReadAll(response.Body)
105+
data, err := io.ReadAll(response.Body)
106106
if err != nil {
107107
return nil, err
108108
}

ethrpc_test.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package ethrpc
22

33
import (
4+
"encoding/json"
45
"errors"
56
"fmt"
6-
"io/ioutil"
7+
"io"
78
"math/big"
89
"net/http"
910
"strconv"
@@ -12,7 +13,6 @@ import (
1213
"github.com/jarcoal/httpmock"
1314
"github.com/stretchr/testify/require"
1415
"github.com/stretchr/testify/suite"
15-
"github.com/tidwall/gjson"
1616
)
1717

1818
type EthRPCTestSuite struct {
@@ -38,25 +38,36 @@ func (s *EthRPCTestSuite) registerResponseError(err error) {
3838

3939
func (s *EthRPCTestSuite) getBody(request *http.Request) []byte {
4040
defer request.Body.Close()
41-
body, err := ioutil.ReadAll(request.Body)
41+
body, err := io.ReadAll(request.Body)
4242
s.Require().Nil(err)
4343

4444
return body
4545
}
4646

4747
func (s *EthRPCTestSuite) methodEqual(body []byte, expected string) {
48-
value := gjson.GetBytes(body, "method").String()
48+
response := struct {
49+
Method string `json:"method"`
50+
}{}
51+
err := json.Unmarshal(body, &response)
52+
s.Require().Nil(err)
4953

50-
s.Require().Equal(expected, value)
54+
s.Require().Equal(expected, response.Method)
5155
}
5256

5357
func (s *EthRPCTestSuite) paramsEqual(body []byte, expected string) {
54-
value := gjson.GetBytes(body, "params").Raw
58+
response := struct {
59+
Params *json.RawMessage `json:"params"`
60+
}{}
61+
err := json.Unmarshal(body, &response)
62+
s.Require().Nil(err)
63+
5564
if expected == "null" {
56-
s.Require().Equal(expected, value)
57-
} else {
58-
s.JSONEq(expected, value)
65+
s.Require().Nil(response.Params)
66+
return
5967
}
68+
69+
s.Require().NotNil(response.Params)
70+
s.JSONEq(expected, string(*response.Params))
6071
}
6172

6273
func (s *EthRPCTestSuite) SetupSuite() {
@@ -526,7 +537,7 @@ func (s *EthRPCTestSuite) TestSendTransaction() {
526537
httpmock.Reset()
527538
s.registerResponse(fmt.Sprintf(`"%s"`, result), func(body []byte) {
528539
s.methodEqual(body, "eth_sendTransaction")
529-
s.paramsEqual(body,`[{}]`)
540+
s.paramsEqual(body, `[{}]`)
530541
})
531542

532543
txid, err = s.rpc.EthSendTransaction(t)

go.mod

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
module github.com/onrik/ethrpc
22

3-
go 1.17
3+
go 1.19
44

55
require (
6-
github.com/jarcoal/httpmock v1.2.0
7-
github.com/stretchr/testify v1.8.0
8-
github.com/tidwall/gjson v1.14.2
6+
github.com/jarcoal/httpmock v1.3.0
7+
github.com/stretchr/testify v1.8.4
98
)
109

1110
require (
1211
github.com/davecgh/go-spew v1.1.1 // indirect
1312
github.com/pmezard/go-difflib v1.0.0 // indirect
14-
github.com/tidwall/match v1.1.1 // indirect
15-
github.com/tidwall/pretty v1.2.0 // indirect
1613
gopkg.in/yaml.v3 v3.0.1 // indirect
1714
)

go.sum

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
1-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
21
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
32
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc=
5-
github.com/jarcoal/httpmock v1.2.0/go.mod h1:oCoTsnAz4+UoOUIf5lJOWV2QQIW5UoeUI6aM2YnWAZk=
6-
github.com/maxatome/go-testdeep v1.11.0 h1:Tgh5efyCYyJFGUYiT0qxBSIDeXw0F5zSoatlou685kk=
7-
github.com/maxatome/go-testdeep v1.11.0/go.mod h1:011SgQ6efzZYAen6fDn4BqQ+lUR72ysdyKe7Dyogw70=
3+
github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc=
4+
github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
5+
github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g=
86
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
97
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
10-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
11-
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
12-
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
13-
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
14-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
15-
github.com/tidwall/gjson v1.14.2 h1:6BBkirS0rAHjumnjHF6qgy5d2YAJ1TLIaFE2lzfOLqo=
16-
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
17-
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
18-
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
19-
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
20-
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
8+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
9+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
2110
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2211
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
23-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2412
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2513
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)