Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions accounts/abi/bind/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"crypto/ecdsa"
"errors"
"io"
"io/ioutil"

"github.com/XinFinOrg/XDPoSChain/accounts/keystore"
"github.com/XinFinOrg/XDPoSChain/common"
Expand All @@ -31,7 +30,7 @@ import (
// NewTransactor is a utility method to easily create a transaction signer from
// an encrypted json key stream and the associated passphrase.
func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
json, err := ioutil.ReadAll(keyin)
json, err := io.ReadAll(keyin)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"math/big"
"os"
"sync"
Expand Down Expand Up @@ -76,7 +75,7 @@ type SimulatedBackend struct {
func SimulateWalletAddressAndSignFn() (common.Address, func(account accounts.Account, hash []byte) ([]byte, error), error) {
veryLightScryptN := 2
veryLightScryptP := 1
dir, _ := ioutil.TempDir("", "eth-SimulateWalletAddressAndSignFn-test")
dir, _ := os.MkdirTemp("", "eth-SimulateWalletAddressAndSignFn-test")

new := func(kd string) *keystore.KeyStore {
return keystore.NewKeyStore(kd, veryLightScryptN, veryLightScryptP)
Expand Down
7 changes: 3 additions & 4 deletions accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package bind

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -831,7 +830,7 @@ func TestBindings(t *testing.T) {
t.Skip("symlinked environment doesn't support bind (https://github.com/golang/go/issues/14845)")
}
// Create a temporary workspace for the test suite
ws, err := ioutil.TempDir("", "")
ws, err := os.MkdirTemp("", "")
if err != nil {
t.Fatalf("failed to create temporary workspace: %v", err)
}
Expand All @@ -848,7 +847,7 @@ func TestBindings(t *testing.T) {
if err != nil {
t.Fatalf("test %d: failed to generate binding: %v", i, err)
}
if err = ioutil.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+".go"), []byte(bind), 0600); err != nil {
if err = os.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+".go"), []byte(bind), 0600); err != nil {
t.Fatalf("test %d: failed to write binding: %v", i, err)
}
// Generate the test file with the injected test code
Expand All @@ -857,7 +856,7 @@ func TestBindings(t *testing.T) {
if err != nil {
t.Fatalf("test %d: failed to generate tests: %v", i, err)
}
if err := ioutil.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+"_test.go"), blob, 0600); err != nil {
if err := os.WriteFile(filepath.Join(pkg, strings.ToLower(tt.name)+"_test.go"), blob, 0600); err != nil {
t.Fatalf("test %d: failed to write tests: %v", i, err)
}
}
Expand Down
9 changes: 4 additions & 5 deletions accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package keystore

import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
Expand Down Expand Up @@ -381,11 +380,11 @@ func TestUpdatedKeyfileContents(t *testing.T) {
return
}

// needed so that modTime of `file` is different to its current value after ioutil.WriteFile
// needed so that modTime of `file` is different to its current value after os.WriteFile
time.Sleep(1000 * time.Millisecond)

// Now replace file contents with crap
if err := ioutil.WriteFile(file, []byte("foo"), 0644); err != nil {
if err := os.WriteFile(file, []byte("foo"), 0644); err != nil {
t.Fatal(err)
return
}
Expand All @@ -398,9 +397,9 @@ func TestUpdatedKeyfileContents(t *testing.T) {

// forceCopyFile is like cp.CopyFile, but doesn't complain if the destination exists.
func forceCopyFile(dst, src string) error {
data, err := ioutil.ReadFile(src)
data, err := os.ReadFile(src)
if err != nil {
return err
}
return ioutil.WriteFile(dst, data, 0644)
return os.WriteFile(dst, data, 0644)
}
11 changes: 7 additions & 4 deletions accounts/keystore/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package keystore

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand All @@ -41,7 +40,7 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
t0 := time.Now()

// List all the failes from the keystore folder
files, err := ioutil.ReadDir(keyDir)
files, err := os.ReadDir(keyDir)
if err != nil {
return nil, nil, nil, err
}
Expand All @@ -58,14 +57,18 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
for _, fi := range files {
// Skip any non-key files from the folder
path := filepath.Join(keyDir, fi.Name())
if skipKeyFile(fi) {
fiInfo, err := fi.Info()
if err != nil {
log.Warn("scan get FileInfo", "err", err, "path", path)
}
if skipKeyFile(fiInfo) {
log.Trace("Ignoring file on account scan", "path", path)
continue
}
// Gather the set of all and fresly modified files
all.Add(path)

modified := fi.ModTime()
modified := fiInfo.ModTime()
if modified.After(fc.lastMod) {
mods.Add(path)
}
Expand Down
3 changes: 1 addition & 2 deletions accounts/keystore/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -188,7 +187,7 @@ func writeKeyFile(file string, content []byte) error {
}
// Atomic write: create a temporary hidden file first
// then move it into place. TempFile assigns mode 0600.
f, err := ioutil.TempFile(filepath.Dir(file), "."+filepath.Base(file)+".tmp")
f, err := os.CreateTemp(filepath.Dir(file), "."+filepath.Base(file)+".tmp")
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions accounts/keystore/keystore_passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"

"github.com/XinFinOrg/XDPoSChain/common"
Expand Down Expand Up @@ -76,7 +76,7 @@ type keyStorePassphrase struct {

func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string) (*Key, error) {
// Load the key from the keystore and decrypt its contents
keyjson, err := ioutil.ReadFile(filename)
keyjson, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions accounts/keystore/keystore_passphrase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package keystore

import (
"io/ioutil"
"os"
"testing"

"github.com/XinFinOrg/XDPoSChain/common"
Expand All @@ -30,7 +30,7 @@ const (

// Tests that a json key file can be decrypted and encrypted in multiple rounds.
func TestKeyEncryptDecrypt(t *testing.T) {
keyjson, err := ioutil.ReadFile("testdata/very-light-scrypt.json")
keyjson, err := os.ReadFile("testdata/very-light-scrypt.json")
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions accounts/keystore/keystore_plain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"crypto/rand"
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand All @@ -32,7 +31,7 @@ import (
)

func tmpKeyStoreIface(t *testing.T, encrypted bool) (dir string, ks keyStore) {
d, err := ioutil.TempDir("", "geth-keystore-test")
d, err := os.MkdirTemp("", "geth-keystore-test")
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions accounts/keystore/keystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package keystore

import (
"io/ioutil"
"math/rand"
"os"
"runtime"
Expand Down Expand Up @@ -375,7 +374,7 @@ func checkEvents(t *testing.T, want []walletEvent, have []walletEvent) {
}

func tmpKeyStore(t *testing.T, encrypted bool) (string, *KeyStore) {
d, err := ioutil.TempDir("", "eth-keystore-test")
d, err := os.MkdirTemp("", "eth-keystore-test")
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"fmt"
"go/parser"
"go/token"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -149,7 +148,7 @@ func doInstall(cmdline []string) {
goinstall.Args = append(goinstall.Args, packages...)
build.MustRun(goinstall)

if cmds, err := ioutil.ReadDir("cmd"); err == nil {
if cmds, err := os.ReadDir("cmd"); err == nil {
for _, cmd := range cmds {
pkgs, err := parser.ParseDir(token.NewFileSet(), filepath.Join(".", "cmd", cmd.Name()), nil, parser.PackageClauseOnly)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/XDC/accountcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package main

import (
"fmt"
"io/ioutil"
"os"

"github.com/XinFinOrg/XDPoSChain/accounts"
"github.com/XinFinOrg/XDPoSChain/accounts/keystore"
Expand Down Expand Up @@ -340,7 +340,7 @@ func importWallet(ctx *cli.Context) error {
if len(keyfile) == 0 {
utils.Fatalf("keyfile must be given as argument")
}
keyJson, err := ioutil.ReadFile(keyfile)
keyJson, err := os.ReadFile(keyfile)
if err != nil {
utils.Fatalf("Could not read wallet file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/XDC/accountcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package main

import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -115,7 +115,7 @@ Passphrase: {{.InputLine "foo"}}
Address: {xdcd4584b5f6229b7be90727b0fc8c6b91bb427821f}
`)

files, err := ioutil.ReadDir(filepath.Join(XDC.Datadir, "keystore"))
files, err := os.ReadDir(filepath.Join(XDC.Datadir, "keystore"))
if len(files) != 1 {
t.Errorf("expected one key file in keystore directory, found %d files (error: %v)", len(files), err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/XDC/bugcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
"os/exec"
"runtime"
"strings"
Expand Down Expand Up @@ -74,7 +74,7 @@ func printOSDetails(w io.Writer) {
case "openbsd", "netbsd", "freebsd", "dragonfly":
printCmdOut(w, "uname -v: ", "uname", "-v")
case "solaris":
out, err := ioutil.ReadFile("/etc/release")
out, err := os.ReadFile("/etc/release")
if err == nil {
fmt.Fprintf(w, "/etc/release: %s\n", out)
} else {
Expand Down
6 changes: 3 additions & 3 deletions cmd/XDC/dao_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package main

import (
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
"io/ioutil"
"math/big"
"os"
"path/filepath"
"testing"

"github.com/XinFinOrg/XDPoSChain/core/rawdb"

"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/core"
)
Expand Down Expand Up @@ -108,7 +108,7 @@ func testDAOForkBlockNewChain(t *testing.T, test int, genesis string, expectBloc
// Start a XDC instance with the requested flags set and immediately terminate
if genesis != "" {
json := filepath.Join(datadir, "genesis.json")
if err := ioutil.WriteFile(json, []byte(genesis), 0600); err != nil {
if err := os.WriteFile(json, []byte(genesis), 0600); err != nil {
t.Fatalf("test %d: failed to write genesis file: %v", test, err)
}
runXDC(t, "--datadir", datadir, "init", json).WaitExit()
Expand Down
3 changes: 1 addition & 2 deletions cmd/XDC/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main

import (
"fmt"
"io/ioutil"
"os"
"testing"

Expand All @@ -27,7 +26,7 @@ import (
)

func tmpdir(t *testing.T) string {
dir, err := ioutil.TempDir("", "XDC-test")
dir, err := os.MkdirTemp("", "XDC-test")
if err != nil {
t.Fatal(err)
}
Expand Down
7 changes: 3 additions & 4 deletions cmd/abigen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -100,7 +99,7 @@ func main() {
}
} else {
// Otherwise load up the ABI, optional bytecode and type name from the parameters
abi, err := ioutil.ReadFile(*abiFlag)
abi, err := os.ReadFile(*abiFlag)
if err != nil {
fmt.Printf("Failed to read input ABI: %v\n", err)
os.Exit(-1)
Expand All @@ -109,7 +108,7 @@ func main() {

bin := []byte{}
if *binFlag != "" {
if bin, err = ioutil.ReadFile(*binFlag); err != nil {
if bin, err = os.ReadFile(*binFlag); err != nil {
fmt.Printf("Failed to read input bytecode: %v\n", err)
os.Exit(-1)
}
Expand All @@ -133,7 +132,7 @@ func main() {
fmt.Printf("%s\n", code)
return
}
if err := ioutil.WriteFile(*outFlag, []byte(code), 0600); err != nil {
if err := os.WriteFile(*outFlag, []byte(code), 0600); err != nil {
fmt.Printf("Failed to write ABI binding: %v\n", err)
os.Exit(-1)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/ethkey/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"crypto/ecdsa"
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -100,7 +99,7 @@ If you want to encrypt an existing private key, it can be specified by setting
if err := os.MkdirAll(filepath.Dir(keyfilepath), 0700); err != nil {
utils.Fatalf("Could not create directory %s", filepath.Dir(keyfilepath))
}
if err := ioutil.WriteFile(keyfilepath, keyjson, 0600); err != nil {
if err := os.WriteFile(keyfilepath, keyjson, 0600); err != nil {
utils.Fatalf("Failed to write keyfile to %s: %v", keyfilepath, err)
}

Expand Down
Loading