Skip to content

Commit

Permalink
update go 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
godeamon committed Jan 9, 2024
1 parent 88ca66e commit 28b4942
Show file tree
Hide file tree
Showing 34 changed files with 238 additions and 115 deletions.
4 changes: 2 additions & 2 deletions bcs/contract/evm/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package abi

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

func TestNewAbi(t *testing.T) {
abiFile := "abi_test.bin"
method := "getUint"

abiBuf, err := ioutil.ReadFile(abiFile)
abiBuf, err := os.ReadFile(abiFile)
if err != nil {
t.Error(err)
}
Expand Down
3 changes: 1 addition & 2 deletions bcs/contract/native/native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package native

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -31,7 +30,7 @@ func compile(th *mock.TestHelper, runtime string) ([]byte, error) {
if err != nil {
return nil, fmt.Errorf("%s:%s", err, out)
}
bin, err := ioutil.ReadFile(target)
bin, err := os.ReadFile(target)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions bcs/contract/native/process_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package native

import (
"encoding/hex"
"io/ioutil"
"os"
"path/filepath"
"sync"
Expand Down Expand Up @@ -47,7 +46,7 @@ func (p *processManager) makeProcess(name string, desc *protos.WasmCodeDesc, cod
}
contractFile := nativeCodeFileName(desc)
processBin := filepath.Join(processDir, contractFile)
err = ioutil.WriteFile(processBin, code, 0755)
err = os.WriteFile(processBin, code, 0755)
if err != nil {
return nil, err
}
Expand Down
9 changes: 4 additions & 5 deletions bcs/contract/xvm/aot_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package xvm

import (
"fmt"
"io/ioutil"
"os"
osexec "os/exec"
"path/filepath"
Expand Down Expand Up @@ -62,21 +61,21 @@ func newXVMCreator(creatorConfig *bridge.InstanceCreatorConfig) (bridge.Instance
}

func cpfile(dest, src string) error {
buf, err := ioutil.ReadFile(src)
buf, err := os.ReadFile(src)
if err != nil {
return err
}
return ioutil.WriteFile(dest, buf, 0700)
return os.WriteFile(dest, buf, 0700)
}

func (x *xvmCreator) CompileCode(buf []byte, outputPath string) error {
tmpdir, err := ioutil.TempDir("", "xvm-compile")
tmpdir, err := os.MkdirTemp("", "xvm-compile")
if err != nil {
return err
}
defer os.RemoveAll(tmpdir)
wasmpath := filepath.Join(tmpdir, "code.wasm")
err = ioutil.WriteFile(wasmpath, buf, 0600)
err = os.WriteFile(wasmpath, buf, 0600)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions bcs/contract/xvm/code_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
Expand Down Expand Up @@ -125,7 +124,7 @@ func (c *codeManager) lookupDiskCache(name string, desc *protos.WasmCodeDesc) (s
return "", false
}
var localDesc protos.WasmCodeDesc
descbuf, err := ioutil.ReadFile(descpath)
descbuf, err := os.ReadFile(descpath)
if err != nil {
return "", false
}
Expand Down Expand Up @@ -157,7 +156,7 @@ func (c *codeManager) makeDiskCache(name string, desc *protos.WasmCodeDesc, code
localDesc := *desc
localDesc.VmCompiler = compile.Version
descbuf, _ := json.Marshal(&localDesc)
err = ioutil.WriteFile(descpath, descbuf, 0600)
err = os.WriteFile(descpath, descbuf, 0600)
if err != nil {
os.RemoveAll(basedir)
return "", err
Expand Down
9 changes: 4 additions & 5 deletions bcs/contract/xvm/code_manager_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package xvm

import (
"io/ioutil"
"os"
"testing"
"time"
Expand Down Expand Up @@ -44,14 +43,14 @@ func (f *fakeCode) NewContext(cfg *exec.ContextConfig) (exec.Context, error) {
func (f *fakeCode) Release() {}

func TestGetCacheExecCode(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "xvm-test")
tmpdir, err := os.MkdirTemp("", "xvm-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpdir)

compileFunc := func(code []byte, output string) error {
return ioutil.WriteFile(output, code, 0700)
return os.WriteFile(output, code, 0700)
}

makeExecCodeFunc := func(libpath string) (exec.Code, error) {
Expand Down Expand Up @@ -104,15 +103,15 @@ func TestGetCacheExecCode(t *testing.T) {
}

func TestMakeCacheBlocking(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "xvm-test")
tmpdir, err := os.MkdirTemp("", "xvm-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpdir)

compileFunc := func(code []byte, output string) error {
time.Sleep(time.Second)
return ioutil.WriteFile(output, code, 0700)
return os.WriteFile(output, code, 0700)
}

makeExecCodeFunc := func(libpath string) (exec.Code, error) {
Expand Down
6 changes: 3 additions & 3 deletions bcs/contract/xvm/interp_creator.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package xvm

import (
"io/ioutil"
"os"

"github.com/xuperchain/xupercore/kernel/contract/bridge"
"github.com/xuperchain/xvm/exec"
Expand All @@ -28,11 +28,11 @@ func newXVMInterpCreator(creatorConfig *bridge.InstanceCreatorConfig) (bridge.In
}

func (x *xvmInterpCreator) compileCode(buf []byte, outputPath string) error {
return ioutil.WriteFile(outputPath, buf, 0600)
return os.WriteFile(outputPath, buf, 0600)
}

func (x *xvmInterpCreator) makeExecCode(codepath string) (exec.Code, error) {
codebuf, err := ioutil.ReadFile(codepath)
codebuf, err := os.ReadFile(codepath)
if err != nil {
return nil, err
}
Expand Down
8 changes: 2 additions & 6 deletions bcs/ledger/xledger/ledger/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import (
"crypto/elliptic"
"crypto/rand"
"fmt"
"io/ioutil"
"os"

//"io/ioutil"
"math/big"
//"os"
"os"
"testing"

"github.com/golang/protobuf/proto"
Expand All @@ -27,7 +23,7 @@ const AliceAddress = "TeyyPLpp9L7QAcxHangtcHTu7HUZ6iydY"
const BobAddress = "WNWk3ekXeM5M2232dY2uCJmEqWhfQiDYT"

func openLedger() (*Ledger, error) {
workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
return nil, dirErr
}
Expand Down
3 changes: 1 addition & 2 deletions bcs/ledger/xledger/state/context/context_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package context

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

Expand All @@ -12,7 +11,7 @@ import (
)

func TestNewNetCtx(t *testing.T) {
workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down
10 changes: 5 additions & 5 deletions bcs/ledger/xledger/state/meta/meta_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package meta

import (
"os"
"path/filepath"
"testing"

"github.com/xuperchain/xupercore/bcs/ledger/xledger/def"
"github.com/xuperchain/xupercore/kernel/mock"
"github.com/xuperchain/xupercore/lib/logs"
"github.com/xuperchain/xupercore/lib/storage/kvdb"
"github.com/xuperchain/xupercore/protos"
"io/ioutil"
"os"
"path/filepath"
"testing"

ledger_pkg "github.com/xuperchain/xupercore/bcs/ledger/xledger/ledger"
"github.com/xuperchain/xupercore/bcs/ledger/xledger/state/context"
Expand Down Expand Up @@ -59,7 +59,7 @@ var GenesisConf = []byte(`
`)

func TestMetaGetFunc(t *testing.T) {
workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down
9 changes: 4 additions & 5 deletions bcs/ledger/xledger/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"crypto/rand"
"errors"
"fmt"
"io/ioutil"
"math/big"
"os"
"path/filepath"
Expand Down Expand Up @@ -209,7 +208,7 @@ func transfer(from string, to string, t *testing.T, stateHandle *State, ledger *
}

func TestStateWorkWithLedger(t *testing.T) {
workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down Expand Up @@ -329,7 +328,7 @@ func TestStateWorkWithLedger(t *testing.T) {
t.Logf("bob balance: %s, alice balance: %s", bobBalance.String(), aliceBalance.String())

//再创建一个新账本,从前面一个账本复制数据
workspace2, dirErr := ioutil.TempDir("/tmp", "")
workspace2, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down Expand Up @@ -456,7 +455,7 @@ func TestCheckCylic(t *testing.T) {
}

func TestFrozenHeight(t *testing.T) {
workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down Expand Up @@ -575,7 +574,7 @@ func TestFrozenHeight(t *testing.T) {
}

func TestGetSnapShotWithBlock(t *testing.T) {
workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down
4 changes: 2 additions & 2 deletions bcs/ledger/xledger/state/utxo/txhash/txhash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package txhash

import (
"encoding/hex"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -17,7 +17,7 @@ var (
)

func readTxFile(tb testing.TB, name string) *pb.Transaction {
buf, err := ioutil.ReadFile(filepath.Join("testdata", name))
buf, err := os.ReadFile(filepath.Join("testdata", name))
if err != nil {
tb.Fatal(err)
}
Expand Down
3 changes: 1 addition & 2 deletions bcs/ledger/xledger/state/utxo/utxo_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package utxo_test

import (
"io/ioutil"
"math/big"
"os"
"testing"
Expand Down Expand Up @@ -61,7 +60,7 @@ var GenesisConf = []byte(`
`)

func TestBasicFunc(t *testing.T) {
workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down
3 changes: 1 addition & 2 deletions bcs/ledger/xledger/state/xmodel/xmodel_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package xmodel
import (
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -26,7 +25,7 @@ const (
)

func TestGet(t *testing.T) {
workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down
6 changes: 3 additions & 3 deletions bcs/ledger/xledger/state/xmodel/xmodel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package xmodel

import (
"fmt"
kledger "github.com/xuperchain/xupercore/kernel/ledger"
"io/ioutil"
"os"
"path/filepath"
"testing"

kledger "github.com/xuperchain/xupercore/kernel/ledger"

"github.com/xuperchain/xupercore/bcs/ledger/xledger/def"
ledger_pkg "github.com/xuperchain/xupercore/bcs/ledger/xledger/ledger"
"github.com/xuperchain/xupercore/bcs/ledger/xledger/state/context"
Expand Down Expand Up @@ -54,7 +54,7 @@ var GenesisConf = []byte(`
`)

func TestBaiscFunc(t *testing.T) {
workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down
3 changes: 1 addition & 2 deletions bcs/ledger/xledger/tx/tx_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tx

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -63,7 +62,7 @@ func TestTx(t *testing.T) {
t.Fatal(rtxErr)
}

workspace, dirErr := ioutil.TempDir("/tmp", "")
workspace, dirErr := os.MkdirTemp("/tmp", "")
if dirErr != nil {
t.Fatal(dirErr)
}
Expand Down
Loading

0 comments on commit 28b4942

Please sign in to comment.