forked from cerc-io/plugeth
all: replace uses of ioutil with io and os (#24869)
This commit is contained in:
@@ -20,9 +20,9 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -852,7 +852,7 @@ func TestDeriveLogFields(t *testing.T) {
|
||||
|
||||
func BenchmarkDecodeRLPLogs(b *testing.B) {
|
||||
// Encoded receipts from block 0x14ee094309fbe8f70b65f45ebcc08fb33f126942d97464aad5eb91cfd1e2d269
|
||||
buf, err := ioutil.ReadFile("testdata/stored_receipts.bin")
|
||||
buf, err := os.ReadFile("testdata/stored_receipts.bin")
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package rawdb
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReadWriteFreezerTableMeta(t *testing.T) {
|
||||
f, err := ioutil.TempFile(os.TempDir(), "*")
|
||||
f, err := os.CreateTemp(os.TempDir(), "*")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create file %v", err)
|
||||
}
|
||||
@@ -44,7 +43,7 @@ func TestReadWriteFreezerTableMeta(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInitializeFreezerTableMeta(t *testing.T) {
|
||||
f, err := ioutil.TempFile(os.TempDir(), "*")
|
||||
f, err := os.CreateTemp(os.TempDir(), "*")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create file %v", err)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package rawdb
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
@@ -30,7 +29,7 @@ import (
|
||||
// It is perfectly valid to have destPath == srcPath.
|
||||
func copyFrom(srcPath, destPath string, offset uint64, before func(f *os.File) error) error {
|
||||
// Create a temp file in the same dir where we want it to wind up
|
||||
f, err := ioutil.TempFile(filepath.Dir(destPath), "*")
|
||||
f, err := os.CreateTemp(filepath.Dir(destPath), "*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package rawdb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
@@ -44,7 +43,7 @@ func TestCopyFrom(t *testing.T) {
|
||||
{"foo", "bar", 8, true},
|
||||
}
|
||||
for _, c := range cases {
|
||||
ioutil.WriteFile(c.src, content, 0644)
|
||||
os.WriteFile(c.src, content, 0644)
|
||||
|
||||
if err := copyFrom(c.src, c.dest, c.offset, func(f *os.File) error {
|
||||
if !c.writePrefix {
|
||||
@@ -57,7 +56,7 @@ func TestCopyFrom(t *testing.T) {
|
||||
t.Fatalf("Failed to copy %v", err)
|
||||
}
|
||||
|
||||
blob, err := ioutil.ReadFile(c.dest)
|
||||
blob, err := os.ReadFile(c.dest)
|
||||
if err != nil {
|
||||
os.Remove(c.src)
|
||||
os.Remove(c.dest)
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"os"
|
||||
@@ -2243,7 +2242,7 @@ func testTransactionJournaling(t *testing.T, nolocals bool) {
|
||||
t.Parallel()
|
||||
|
||||
// Create a temporary file for the journal
|
||||
file, err := ioutil.TempFile("", "")
|
||||
file, err := os.CreateTemp("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temporary journal: %v", err)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -334,7 +334,7 @@ func TestPrecompiledBLS12381MapG1Fail(t *testing.T) { testJsonFail("blsMapG
|
||||
func TestPrecompiledBLS12381MapG2Fail(t *testing.T) { testJsonFail("blsMapG2", "12", t) }
|
||||
|
||||
func loadJson(name string) ([]precompiledTest, error) {
|
||||
data, err := ioutil.ReadFile(fmt.Sprintf("testdata/precompiles/%v.json", name))
|
||||
data, err := os.ReadFile(fmt.Sprintf("testdata/precompiles/%v.json", name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -344,7 +344,7 @@ func loadJson(name string) ([]precompiledTest, error) {
|
||||
}
|
||||
|
||||
func loadJsonFail(name string) ([]precompiledFailureTest, error) {
|
||||
data, err := ioutil.ReadFile(fmt.Sprintf("testdata/precompiles/fail-%v.json", name))
|
||||
data, err := os.ReadFile(fmt.Sprintf("testdata/precompiles/fail-%v.json", name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@@ -260,7 +260,7 @@ func TestWriteExpectedValues(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = ioutil.WriteFile(fmt.Sprintf("testdata/testcases_%v.json", name), data, 0644)
|
||||
_ = os.WriteFile(fmt.Sprintf("testdata/testcases_%v.json", name), data, 0644)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func TestWriteExpectedValues(t *testing.T) {
|
||||
// TestJsonTestcases runs through all the testcases defined as json-files
|
||||
func TestJsonTestcases(t *testing.T) {
|
||||
for name := range twoOpMethods {
|
||||
data, err := ioutil.ReadFile(fmt.Sprintf("testdata/testcases_%v.json", name))
|
||||
data, err := os.ReadFile(fmt.Sprintf("testdata/testcases_%v.json", name))
|
||||
if err != nil {
|
||||
t.Fatal("Failed to read file", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user