all: replace uses of ioutil with io and os (#24869)

This commit is contained in:
Håvard Anda Estensen
2022-05-16 11:59:35 +02:00
committed by GitHub
parent 330e53fbb9
commit 07508ac0e9
97 changed files with 203 additions and 257 deletions
+1 -2
View File
@@ -19,7 +19,6 @@ package ethash
import (
"bytes"
"encoding/binary"
"io/ioutil"
"math/big"
"os"
"reflect"
@@ -700,7 +699,7 @@ func TestConcurrentDiskCacheGeneration(t *testing.T) {
// Create a temp folder to generate the caches into
// TODO: t.TempDir fails to remove the directory on Windows
// \AppData\Local\Temp\1\TestConcurrentDiskCacheGeneration2382060137\001\cache-R23-1dca8a85e74aa763: Access is denied.
cachedir, err := ioutil.TempDir("", "")
cachedir, err := os.MkdirTemp("", "")
if err != nil {
t.Fatalf("Failed to create temporary cache dir: %v", err)
}
+1 -2
View File
@@ -17,7 +17,6 @@
package ethash
import (
"io/ioutil"
"math/big"
"math/rand"
"os"
@@ -59,7 +58,7 @@ func TestTestMode(t *testing.T) {
func TestCacheFileEvict(t *testing.T) {
// TODO: t.TempDir fails to remove the directory on Windows
// \AppData\Local\Temp\1\TestCacheFileEvict2179435125\001\cache-R23-0000000000000000: Access is denied.
tmpdir, err := ioutil.TempDir("", "ethash-test")
tmpdir, err := os.MkdirTemp("", "ethash-test")
if err != nil {
t.Fatal(err)
}
+5 -5
View File
@@ -18,7 +18,7 @@ package ethash
import (
"encoding/json"
"io/ioutil"
"io"
"math/big"
"net/http"
"net/http/httptest"
@@ -37,7 +37,7 @@ func TestRemoteNotify(t *testing.T) {
// Start a simple web server to capture notifications.
sink := make(chan [3]string)
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
blob, err := ioutil.ReadAll(req.Body)
blob, err := io.ReadAll(req.Body)
if err != nil {
t.Errorf("failed to read miner notification: %v", err)
}
@@ -80,7 +80,7 @@ func TestRemoteNotifyFull(t *testing.T) {
// Start a simple web server to capture notifications.
sink := make(chan map[string]interface{})
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
blob, err := ioutil.ReadAll(req.Body)
blob, err := io.ReadAll(req.Body)
if err != nil {
t.Errorf("failed to read miner notification: %v", err)
}
@@ -125,7 +125,7 @@ func TestRemoteMultiNotify(t *testing.T) {
// Start a simple web server to capture notifications.
sink := make(chan [3]string, 64)
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
blob, err := ioutil.ReadAll(req.Body)
blob, err := io.ReadAll(req.Body)
if err != nil {
t.Errorf("failed to read miner notification: %v", err)
}
@@ -170,7 +170,7 @@ func TestRemoteMultiNotifyFull(t *testing.T) {
// Start a simple web server to capture notifications.
sink := make(chan map[string]interface{}, 64)
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
blob, err := ioutil.ReadAll(req.Body)
blob, err := io.ReadAll(req.Body)
if err != nil {
t.Errorf("failed to read miner notification: %v", err)
}