migrate away from deprecated ioutil APIs (#7175)

Co-authored-by: Callum Waters <cmwaters19@gmail.com>
Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
This commit is contained in:
Sharad Chand
2021-10-28 10:34:07 -07:00
committed by GitHub
co-authored by Callum Waters M. J. Fromberger
parent 6108d0a9b5
commit 8441b3715a
58 changed files with 158 additions and 192 deletions
+5 -5
View File
@@ -4,7 +4,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/http/httptest"
@@ -101,7 +101,7 @@ func TestServeTLS(t *testing.T) {
defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode)
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
require.NoError(t, err)
assert.Equal(t, []byte("some body"), body)
}
@@ -114,7 +114,7 @@ func TestWriteRPCResponseHTTP(t *testing.T) {
err := WriteRPCResponseHTTP(w, true, rpctypes.NewRPCSuccessResponse(id, &sampleResult{"hello"}))
require.NoError(t, err)
resp := w.Result()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
_ = resp.Body.Close()
require.NoError(t, err)
assert.Equal(t, 200, resp.StatusCode)
@@ -136,7 +136,7 @@ func TestWriteRPCResponseHTTP(t *testing.T) {
rpctypes.NewRPCSuccessResponse(id, &sampleResult{"world"}))
require.NoError(t, err)
resp = w.Result()
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
_ = resp.Body.Close()
require.NoError(t, err)
@@ -165,7 +165,7 @@ func TestWriteRPCResponseHTTPError(t *testing.T) {
err := WriteRPCResponseHTTPError(w, rpctypes.RPCInternalError(rpctypes.JSONRPCIntID(-1), errors.New("foo")))
require.NoError(t, err)
resp := w.Result()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
_ = resp.Body.Close()
require.NoError(t, err)
assert.Equal(t, http.StatusInternalServerError, resp.StatusCode)