forked from TrueCloudLab/neoneo-go
parent
df3eb76aa2
commit
2096ad6e81
32 changed files with 134 additions and 159 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -35,12 +34,12 @@ func TestCalcHash(t *testing.T) {
|
||||||
e := newExecutor(t, false)
|
e := newExecutor(t, false)
|
||||||
|
|
||||||
nefPath := "./testdata/verify.nef"
|
nefPath := "./testdata/verify.nef"
|
||||||
src, err := ioutil.ReadFile(nefPath)
|
src, err := os.ReadFile(nefPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
nefF, err := nef.FileFromBytes(src)
|
nefF, err := nef.FileFromBytes(src)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
manifestPath := "./testdata/verify.manifest.json"
|
manifestPath := "./testdata/verify.manifest.json"
|
||||||
manifestBytes, err := ioutil.ReadFile(manifestPath)
|
manifestBytes, err := os.ReadFile(manifestPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
manif := &manifest.Manifest{}
|
manif := &manifest.Manifest{}
|
||||||
err = json.Unmarshal(manifestBytes, manif)
|
err = json.Unmarshal(manifestBytes, manif)
|
||||||
|
@ -67,12 +66,12 @@ func TestCalcHash(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("invalid nef file", func(t *testing.T) {
|
t.Run("invalid nef file", func(t *testing.T) {
|
||||||
p := filepath.Join(tmpDir, "neogo.calchash.verify.nef")
|
p := filepath.Join(tmpDir, "neogo.calchash.verify.nef")
|
||||||
require.NoError(t, ioutil.WriteFile(p, src[:4], os.ModePerm))
|
require.NoError(t, os.WriteFile(p, src[:4], os.ModePerm))
|
||||||
e.RunWithError(t, append(cmd, "--sender", sender.StringLE(), "--in", p, "--manifest", manifestPath)...)
|
e.RunWithError(t, append(cmd, "--sender", sender.StringLE(), "--in", p, "--manifest", manifestPath)...)
|
||||||
})
|
})
|
||||||
t.Run("invalid manifest file", func(t *testing.T) {
|
t.Run("invalid manifest file", func(t *testing.T) {
|
||||||
p := filepath.Join(tmpDir, "neogo.calchash.verify.manifest.json")
|
p := filepath.Join(tmpDir, "neogo.calchash.verify.manifest.json")
|
||||||
require.NoError(t, ioutil.WriteFile(p, manifestBytes[:4], os.ModePerm))
|
require.NoError(t, os.WriteFile(p, manifestBytes[:4], os.ModePerm))
|
||||||
e.RunWithError(t, append(cmd, "--sender", sender.StringLE(), "--in", nefPath, "--manifest", p)...)
|
e.RunWithError(t, append(cmd, "--sender", sender.StringLE(), "--in", nefPath, "--manifest", p)...)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -106,7 +105,7 @@ func TestContractBindings(t *testing.T) {
|
||||||
e.Run(t, "neo-go", "contract", "init", "--name", ctrPath)
|
e.Run(t, "neo-go", "contract", "init", "--name", ctrPath)
|
||||||
|
|
||||||
srcPath := filepath.Join(ctrPath, "main.go")
|
srcPath := filepath.Join(ctrPath, "main.go")
|
||||||
require.NoError(t, ioutil.WriteFile(srcPath, []byte(`package testcontract
|
require.NoError(t, os.WriteFile(srcPath, []byte(`package testcontract
|
||||||
import(
|
import(
|
||||||
alias "github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
alias "github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
|
||||||
)
|
)
|
||||||
|
@ -140,7 +139,7 @@ func Blocks() []*alias.Block {
|
||||||
|
|
||||||
// Replace `pkg/interop` in go.mod to avoid getting an actual module version.
|
// Replace `pkg/interop` in go.mod to avoid getting an actual module version.
|
||||||
goMod := filepath.Join(ctrPath, "go.mod")
|
goMod := filepath.Join(ctrPath, "go.mod")
|
||||||
data, err := ioutil.ReadFile(goMod)
|
data, err := os.ReadFile(goMod)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
i := bytes.IndexByte(data, '\n')
|
i := bytes.IndexByte(data, '\n')
|
||||||
|
@ -150,7 +149,7 @@ func Blocks() []*alias.Block {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
data = append(data, "\nreplace github.com/nspcc-dev/neo-go/pkg/interop => "...)
|
data = append(data, "\nreplace github.com/nspcc-dev/neo-go/pkg/interop => "...)
|
||||||
data = append(data, filepath.Join(wd, "../pkg/interop")...)
|
data = append(data, filepath.Join(wd, "../pkg/interop")...)
|
||||||
require.NoError(t, ioutil.WriteFile(goMod, data, os.ModePerm))
|
require.NoError(t, os.WriteFile(goMod, data, os.ModePerm))
|
||||||
|
|
||||||
cmd = append(cmd, "--config", cfgPath,
|
cmd = append(cmd, "--config", cfgPath,
|
||||||
"--out", filepath.Join(tmpDir, "out.nef"),
|
"--out", filepath.Join(tmpDir, "out.nef"),
|
||||||
|
@ -165,7 +164,7 @@ func Blocks() []*alias.Block {
|
||||||
"--config", bindingsPath, "--manifest", manifestPath,
|
"--config", bindingsPath, "--manifest", manifestPath,
|
||||||
"--out", outPath, "--hash", "0x0123456789987654321001234567899876543210")
|
"--out", outPath, "--hash", "0x0123456789987654321001234567899876543210")
|
||||||
|
|
||||||
bs, err := ioutil.ReadFile(outPath)
|
bs, err := os.ReadFile(outPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, `// Package testcontract contains wrappers for testcontract contract.
|
require.Equal(t, `// Package testcontract contains wrappers for testcontract contract.
|
||||||
package testcontract
|
package testcontract
|
||||||
|
@ -244,23 +243,23 @@ func TestContractInitAndCompile(t *testing.T) {
|
||||||
e.RunWithError(t, append(cmd, "--config", cfgName)...)
|
e.RunWithError(t, append(cmd, "--config", cfgName)...)
|
||||||
})
|
})
|
||||||
t.Run("provided corrupted config", func(t *testing.T) {
|
t.Run("provided corrupted config", func(t *testing.T) {
|
||||||
data, err := ioutil.ReadFile(cfgPath)
|
data, err := os.ReadFile(cfgPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
badCfg := filepath.Join(tmpDir, "bad.yml")
|
badCfg := filepath.Join(tmpDir, "bad.yml")
|
||||||
require.NoError(t, ioutil.WriteFile(badCfg, data[:len(data)-5], os.ModePerm))
|
require.NoError(t, os.WriteFile(badCfg, data[:len(data)-5], os.ModePerm))
|
||||||
e.RunWithError(t, append(cmd, "--config", badCfg)...)
|
e.RunWithError(t, append(cmd, "--config", badCfg)...)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Replace `pkg/interop` in go.mod to avoid getting an actual module version.
|
// Replace `pkg/interop` in go.mod to avoid getting an actual module version.
|
||||||
goMod := filepath.Join(ctrPath, "go.mod")
|
goMod := filepath.Join(ctrPath, "go.mod")
|
||||||
data, err := ioutil.ReadFile(goMod)
|
data, err := os.ReadFile(goMod)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
data = append(data, "\nreplace github.com/nspcc-dev/neo-go/pkg/interop => "...)
|
data = append(data, "\nreplace github.com/nspcc-dev/neo-go/pkg/interop => "...)
|
||||||
data = append(data, filepath.Join(wd, "../pkg/interop")...)
|
data = append(data, filepath.Join(wd, "../pkg/interop")...)
|
||||||
require.NoError(t, ioutil.WriteFile(goMod, data, os.ModePerm))
|
require.NoError(t, os.WriteFile(goMod, data, os.ModePerm))
|
||||||
|
|
||||||
cmd = append(cmd, "--config", cfgPath)
|
cmd = append(cmd, "--config", cfgPath)
|
||||||
e.Run(t, cmd...)
|
e.Run(t, cmd...)
|
||||||
|
@ -481,7 +480,7 @@ func TestContractManifestGroups(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("corrupted NEF file", func(t *testing.T) {
|
t.Run("corrupted NEF file", func(t *testing.T) {
|
||||||
f := filepath.Join(tmpDir, "invalid.nef")
|
f := filepath.Join(tmpDir, "invalid.nef")
|
||||||
require.NoError(t, ioutil.WriteFile(f, []byte{1, 2, 3}, os.ModePerm))
|
require.NoError(t, os.WriteFile(f, []byte{1, 2, 3}, os.ModePerm))
|
||||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||||
"--wallet", testWalletPath, "--account", testWalletAccount,
|
"--wallet", testWalletPath, "--account", testWalletAccount,
|
||||||
"--sender", testWalletAccount, "--nef", f)
|
"--sender", testWalletAccount, "--nef", f)
|
||||||
|
@ -494,7 +493,7 @@ func TestContractManifestGroups(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("corrupted manifest file", func(t *testing.T) {
|
t.Run("corrupted manifest file", func(t *testing.T) {
|
||||||
f := filepath.Join(tmpDir, "invalid.manifest.json")
|
f := filepath.Join(tmpDir, "invalid.manifest.json")
|
||||||
require.NoError(t, ioutil.WriteFile(f, []byte{1, 2, 3}, os.ModePerm))
|
require.NoError(t, os.WriteFile(f, []byte{1, 2, 3}, os.ModePerm))
|
||||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||||
"--wallet", testWalletPath, "--account", testWalletAccount,
|
"--wallet", testWalletPath, "--account", testWalletAccount,
|
||||||
"--sender", testWalletAccount, "--nef", nefName,
|
"--sender", testWalletAccount, "--nef", nefName,
|
||||||
|
@ -573,7 +572,7 @@ func TestContract_TestInvokeScript(t *testing.T) {
|
||||||
"--in", badNef)
|
"--in", badNef)
|
||||||
})
|
})
|
||||||
t.Run("invalid nef", func(t *testing.T) {
|
t.Run("invalid nef", func(t *testing.T) {
|
||||||
require.NoError(t, ioutil.WriteFile(badNef, []byte("qwer"), os.ModePerm))
|
require.NoError(t, os.WriteFile(badNef, []byte("qwer"), os.ModePerm))
|
||||||
e.RunWithError(t, "neo-go", "contract", "testinvokescript",
|
e.RunWithError(t, "neo-go", "contract", "testinvokescript",
|
||||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||||
"--in", badNef)
|
"--in", badNef)
|
||||||
|
@ -689,10 +688,9 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
||||||
e.RunWithError(t, cmd...)
|
e.RunWithError(t, cmd...)
|
||||||
})
|
})
|
||||||
t.Run("corrupted wallet", func(t *testing.T) {
|
t.Run("corrupted wallet", func(t *testing.T) {
|
||||||
tmp, err := ioutil.TempDir("", "tmp")
|
tmp := t.TempDir()
|
||||||
require.NoError(t, err)
|
|
||||||
tmpPath := filepath.Join(tmp, "wallet.json")
|
tmpPath := filepath.Join(tmp, "wallet.json")
|
||||||
require.NoError(t, ioutil.WriteFile(tmpPath, []byte("{"), os.ModePerm))
|
require.NoError(t, os.WriteFile(tmpPath, []byte("{"), os.ModePerm))
|
||||||
|
|
||||||
cmd := append(cmd, "--wallet", tmpPath,
|
cmd := append(cmd, "--wallet", tmpPath,
|
||||||
h.StringLE(), "getValue")
|
h.StringLE(), "getValue")
|
||||||
|
@ -854,9 +852,9 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
||||||
os.Remove(manifestName)
|
os.Remove(manifestName)
|
||||||
})
|
})
|
||||||
|
|
||||||
rawNef, err := ioutil.ReadFile(nefName)
|
rawNef, err := os.ReadFile(nefName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
rawManifest, err := ioutil.ReadFile(manifestName)
|
rawManifest, err := os.ReadFile(manifestName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
e.In.WriteString("one\r")
|
e.In.WriteString("one\r")
|
||||||
|
@ -918,7 +916,7 @@ func TestContractInspect(t *testing.T) {
|
||||||
func TestCompileExamples(t *testing.T) {
|
func TestCompileExamples(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
const examplePath = "../examples"
|
const examplePath = "../examples"
|
||||||
infos, err := ioutil.ReadDir(examplePath)
|
infos, err := os.ReadDir(examplePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// For proper nef generation.
|
// For proper nef generation.
|
||||||
|
@ -933,7 +931,7 @@ func TestCompileExamples(t *testing.T) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t.Run(info.Name(), func(t *testing.T) {
|
t.Run(info.Name(), func(t *testing.T) {
|
||||||
infos, err := ioutil.ReadDir(filepath.Join(examplePath, info.Name()))
|
infos, err := os.ReadDir(filepath.Join(examplePath, info.Name()))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.False(t, len(infos) == 0, "detected smart contract folder with no contract in it")
|
require.False(t, len(infos) == 0, "detected smart contract folder with no contract in it")
|
||||||
|
|
||||||
|
@ -951,7 +949,7 @@ func TestCompileExamples(t *testing.T) {
|
||||||
e.Run(t, opts...)
|
e.Run(t, opts...)
|
||||||
|
|
||||||
if info.Name() == "storage" {
|
if info.Name() == "storage" {
|
||||||
rawM, err := ioutil.ReadFile(manifestF)
|
rawM, err := os.ReadFile(manifestF)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
m := new(manifest.Manifest)
|
m := new(manifest.Manifest)
|
||||||
|
@ -983,7 +981,7 @@ func TestCompileExamples(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func filterFilename(infos []os.FileInfo, ext string) string {
|
func filterFilename(infos []os.DirEntry, ext string) string {
|
||||||
for _, info := range infos {
|
for _, info := range infos {
|
||||||
if !info.IsDir() {
|
if !info.IsDir() {
|
||||||
name := info.Name()
|
name := info.Name()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -29,7 +28,7 @@ func TestDBRestoreDump(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cfgPath := filepath.Join(tmpDir, "protocol.unit_testnet.yml")
|
cfgPath := filepath.Join(tmpDir, "protocol.unit_testnet.yml")
|
||||||
require.NoError(t, ioutil.WriteFile(cfgPath, out, os.ModePerm))
|
require.NoError(t, os.WriteFile(cfgPath, out, os.ModePerm))
|
||||||
|
|
||||||
// generated via `go run ./scripts/gendump/main.go --out ./cli/testdata/chain50x2.acc --blocks 50 --txs 2`
|
// generated via `go run ./scripts/gendump/main.go --out ./cli/testdata/chain50x2.acc --blocks 50 --txs 2`
|
||||||
const inDump = "./testdata/chain50x2.acc"
|
const inDump = "./testdata/chain50x2.acc"
|
||||||
|
@ -61,14 +60,14 @@ func TestDBRestoreDump(t *testing.T) {
|
||||||
t.Run("bad logger config", func(t *testing.T) {
|
t.Run("bad logger config", func(t *testing.T) {
|
||||||
badConfigDir := t.TempDir()
|
badConfigDir := t.TempDir()
|
||||||
logfile := filepath.Join(badConfigDir, "logdir")
|
logfile := filepath.Join(badConfigDir, "logdir")
|
||||||
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
||||||
cfg = loadConfig(t)
|
cfg = loadConfig(t)
|
||||||
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
||||||
out, err = yaml.Marshal(cfg)
|
out, err = yaml.Marshal(cfg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cfgPath = filepath.Join(badConfigDir, "protocol.unit_testnet.yml")
|
cfgPath = filepath.Join(badConfigDir, "protocol.unit_testnet.yml")
|
||||||
require.NoError(t, ioutil.WriteFile(cfgPath, out, os.ModePerm))
|
require.NoError(t, os.WriteFile(cfgPath, out, os.ModePerm))
|
||||||
|
|
||||||
e.RunWithError(t, "neo-go", "db", "dump", "--unittest",
|
e.RunWithError(t, "neo-go", "db", "dump", "--unittest",
|
||||||
"--config-path", badConfigDir, "--out", dumpPath)
|
"--config-path", badConfigDir, "--out", dumpPath)
|
||||||
|
@ -76,14 +75,14 @@ func TestDBRestoreDump(t *testing.T) {
|
||||||
t.Run("bad storage config", func(t *testing.T) {
|
t.Run("bad storage config", func(t *testing.T) {
|
||||||
badConfigDir := t.TempDir()
|
badConfigDir := t.TempDir()
|
||||||
logfile := filepath.Join(badConfigDir, "logdir")
|
logfile := filepath.Join(badConfigDir, "logdir")
|
||||||
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
||||||
cfg = loadConfig(t)
|
cfg = loadConfig(t)
|
||||||
cfg.ApplicationConfiguration.DBConfiguration.Type = ""
|
cfg.ApplicationConfiguration.DBConfiguration.Type = ""
|
||||||
out, err = yaml.Marshal(cfg)
|
out, err = yaml.Marshal(cfg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cfgPath = filepath.Join(badConfigDir, "protocol.unit_testnet.yml")
|
cfgPath = filepath.Join(badConfigDir, "protocol.unit_testnet.yml")
|
||||||
require.NoError(t, ioutil.WriteFile(cfgPath, out, os.ModePerm))
|
require.NoError(t, os.WriteFile(cfgPath, out, os.ModePerm))
|
||||||
|
|
||||||
e.RunWithError(t, "neo-go", "db", "dump", "--unittest",
|
e.RunWithError(t, "neo-go", "db", "dump", "--unittest",
|
||||||
"--config-path", badConfigDir, "--out", dumpPath)
|
"--config-path", badConfigDir, "--out", dumpPath)
|
||||||
|
@ -98,9 +97,9 @@ func TestDBRestoreDump(t *testing.T) {
|
||||||
|
|
||||||
e.Run(t, baseCmd...)
|
e.Run(t, baseCmd...)
|
||||||
|
|
||||||
d1, err := ioutil.ReadFile(inDump)
|
d1, err := os.ReadFile(inDump)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
d2, err := ioutil.ReadFile(dumpPath)
|
d2, err := os.ReadFile(dumpPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, d1, d2, "dumps differ")
|
require.Equal(t, d1, d2, "dumps differ")
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -269,7 +268,7 @@ func (e *executor) run(args ...string) error {
|
||||||
e.Err.Reset()
|
e.Err.Reset()
|
||||||
input.Terminal = term.NewTerminal(input.ReadWriter{
|
input.Terminal = term.NewTerminal(input.ReadWriter{
|
||||||
Reader: e.In,
|
Reader: e.In,
|
||||||
Writer: ioutil.Discard,
|
Writer: io.Discard,
|
||||||
}, "")
|
}, "")
|
||||||
err := e.CLI.Run(args)
|
err := e.CLI.Run(args)
|
||||||
input.Terminal = nil
|
input.Terminal = nil
|
||||||
|
|
|
@ -2,7 +2,7 @@ package flags
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/internal/random"
|
"github.com/nspcc-dev/neo-go/internal/random"
|
||||||
|
@ -119,7 +119,7 @@ func TestAddressFlag_GetName(t *testing.T) {
|
||||||
|
|
||||||
func TestAddress(t *testing.T) {
|
func TestAddress(t *testing.T) {
|
||||||
f := flag.NewFlagSet("", flag.ContinueOnError)
|
f := flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
f.SetOutput(ioutil.Discard) // don't pollute test output
|
f.SetOutput(io.Discard) // don't pollute test output
|
||||||
addr := AddressFlag{Name: "addr, a"}
|
addr := AddressFlag{Name: "addr, a"}
|
||||||
addr.Apply(f)
|
addr.Apply(f)
|
||||||
require.NoError(t, f.Parse([]string{"--addr", "NRHkiY2hLy5ypD32CKZtL6pNwhbFMqDEhR"}))
|
require.NoError(t, f.Parse([]string{"--addr", "NRHkiY2hLy5ypD32CKZtL6pNwhbFMqDEhR"}))
|
||||||
|
|
|
@ -2,7 +2,7 @@ package flags
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
|
@ -55,7 +55,7 @@ func TestFixed8Flag_GetName(t *testing.T) {
|
||||||
|
|
||||||
func TestFixed8(t *testing.T) {
|
func TestFixed8(t *testing.T) {
|
||||||
f := flag.NewFlagSet("", flag.ContinueOnError)
|
f := flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
f.SetOutput(ioutil.Discard) // don't pollute test output
|
f.SetOutput(io.Discard) // don't pollute test output
|
||||||
gas := Fixed8Flag{Name: "gas, g"}
|
gas := Fixed8Flag{Name: "gas, g"}
|
||||||
gas.Apply(f)
|
gas.Apply(f)
|
||||||
require.NoError(t, f.Parse([]string{"--gas", "0.123"}))
|
require.NoError(t, f.Parse([]string{"--gas", "0.123"}))
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -104,10 +104,10 @@ func TestNEP11_ND_OwnerOf_BalanceOf_Transfer(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// copy wallet to temp dir in order not to overwrite the original file
|
// copy wallet to temp dir in order not to overwrite the original file
|
||||||
bytesRead, err := ioutil.ReadFile(nftOwnerWallet)
|
bytesRead, err := os.ReadFile(nftOwnerWallet)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
wall := filepath.Join(tmpDir, "my_wallet.json")
|
wall := filepath.Join(tmpDir, "my_wallet.json")
|
||||||
err = ioutil.WriteFile(wall, bytesRead, 0755)
|
err = os.WriteFile(wall, bytesRead, 0755)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// transfer funds to contract owner
|
// transfer funds to contract owner
|
||||||
|
@ -336,10 +336,10 @@ func TestNEP11_D_OwnerOf_BalanceOf_Transfer(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// copy wallet to temp dir in order not to overwrite the original file
|
// copy wallet to temp dir in order not to overwrite the original file
|
||||||
bytesRead, err := ioutil.ReadFile(validatorWallet)
|
bytesRead, err := os.ReadFile(validatorWallet)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
wall := filepath.Join(tmpDir, "my_wallet.json")
|
wall := filepath.Join(tmpDir, "my_wallet.json")
|
||||||
err = ioutil.WriteFile(wall, bytesRead, 0755)
|
err = os.WriteFile(wall, bytesRead, 0755)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// deploy NeoFS Object contract
|
// deploy NeoFS Object contract
|
||||||
|
|
|
@ -3,7 +3,7 @@ package paramcontext
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
@ -36,7 +36,7 @@ func InitAndSave(net netmode.Magic, tx *transaction.Transaction, acc *wallet.Acc
|
||||||
|
|
||||||
// Read reads parameter context from file.
|
// Read reads parameter context from file.
|
||||||
func Read(filename string) (*context.ParameterContext, error) {
|
func Read(filename string) (*context.ParameterContext, error) {
|
||||||
data, err := ioutil.ReadFile(filename)
|
data, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't read input file: %w", err)
|
return nil, fmt.Errorf("can't read input file: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ func Read(filename string) (*context.ParameterContext, error) {
|
||||||
func Save(c *context.ParameterContext, filename string) error {
|
func Save(c *context.ParameterContext, filename string) error {
|
||||||
if data, err := json.Marshal(c); err != nil {
|
if data, err := json.Marshal(c); err != nil {
|
||||||
return fmt.Errorf("can't marshal transaction: %w", err)
|
return fmt.Errorf("can't marshal transaction: %w", err)
|
||||||
} else if err := ioutil.WriteFile(filename, data, 0644); err != nil {
|
} else if err := os.WriteFile(filename, data, 0644); err != nil {
|
||||||
return fmt.Errorf("can't write transaction to file: %w", err)
|
return fmt.Errorf("can't write transaction to file: %w", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -3,7 +3,6 @@ package server
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
@ -63,7 +62,7 @@ func (d *dump) tryPersist(prefix string, index uint32) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readFile(path string) (*dump, error) {
|
func readFile(path string) (*dump, error) {
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package server
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -46,7 +45,7 @@ func TestHandleLoggingParams(t *testing.T) {
|
||||||
|
|
||||||
t.Run("logdir is a file", func(t *testing.T) {
|
t.Run("logdir is a file", func(t *testing.T) {
|
||||||
logfile := filepath.Join(d, "logdir")
|
logfile := filepath.Join(d, "logdir")
|
||||||
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
||||||
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
||||||
ctx := cli.NewContext(cli.NewApp(), set, nil)
|
ctx := cli.NewContext(cli.NewApp(), set, nil)
|
||||||
cfg := config.ApplicationConfiguration{
|
cfg := config.ApplicationConfiguration{
|
||||||
|
@ -196,7 +195,7 @@ func TestRestoreDB(t *testing.T) {
|
||||||
t.Run("invalid logger path", func(t *testing.T) {
|
t.Run("invalid logger path", func(t *testing.T) {
|
||||||
badCfgDir := t.TempDir()
|
badCfgDir := t.TempDir()
|
||||||
logfile := filepath.Join(badCfgDir, "logdir")
|
logfile := filepath.Join(badCfgDir, "logdir")
|
||||||
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
||||||
cfg, err := config.LoadFile(filepath.Join(goodCfg, "protocol.privnet.yml"))
|
cfg, err := config.LoadFile(filepath.Join(goodCfg, "protocol.privnet.yml"))
|
||||||
require.NoError(t, err, "could not load config")
|
require.NoError(t, err, "could not load config")
|
||||||
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
||||||
|
@ -204,7 +203,7 @@ func TestRestoreDB(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
badCfgPath := filepath.Join(badCfgDir, "protocol.privnet.yml")
|
badCfgPath := filepath.Join(badCfgDir, "protocol.privnet.yml")
|
||||||
require.NoError(t, ioutil.WriteFile(badCfgPath, out, os.ModePerm))
|
require.NoError(t, os.WriteFile(badCfgPath, out, os.ModePerm))
|
||||||
|
|
||||||
*cfgPath = badCfgDir
|
*cfgPath = badCfgDir
|
||||||
require.Error(t, restoreDB(ctx))
|
require.Error(t, restoreDB(ctx))
|
||||||
|
@ -220,7 +219,7 @@ func TestRestoreDB(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
badCfgPath := filepath.Join(badCfgDir, "protocol.privnet.yml")
|
badCfgPath := filepath.Join(badCfgDir, "protocol.privnet.yml")
|
||||||
require.NoError(t, ioutil.WriteFile(badCfgPath, out, os.ModePerm))
|
require.NoError(t, os.WriteFile(badCfgPath, out, os.ModePerm))
|
||||||
|
|
||||||
*cfgPath = badCfgDir
|
*cfgPath = badCfgDir
|
||||||
require.Error(t, restoreDB(ctx))
|
require.Error(t, restoreDB(ctx))
|
||||||
|
@ -238,7 +237,7 @@ func TestRestoreDB(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("corrupted in: invalid block count", func(t *testing.T) {
|
t.Run("corrupted in: invalid block count", func(t *testing.T) {
|
||||||
inPath := filepath.Join(t.TempDir(), "file3.acc")
|
inPath := filepath.Join(t.TempDir(), "file3.acc")
|
||||||
require.NoError(t, ioutil.WriteFile(inPath, []byte{1, 2, 3}, // file is expected to start from uint32
|
require.NoError(t, os.WriteFile(inPath, []byte{1, 2, 3}, // file is expected to start from uint32
|
||||||
os.ModePerm))
|
os.ModePerm))
|
||||||
*in = inPath
|
*in = inPath
|
||||||
require.Error(t, restoreDB(ctx))
|
require.Error(t, restoreDB(ctx))
|
||||||
|
@ -247,10 +246,10 @@ func TestRestoreDB(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("corrupted in: corrupted block", func(t *testing.T) {
|
t.Run("corrupted in: corrupted block", func(t *testing.T) {
|
||||||
inPath := filepath.Join(t.TempDir(), "file3.acc")
|
inPath := filepath.Join(t.TempDir(), "file3.acc")
|
||||||
b, err := ioutil.ReadFile(testDump)
|
b, err := os.ReadFile(testDump)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
b[5] = 0xff // file is expected to start from uint32 (4 bytes) followed by the first block, so corrupt the first block bytes
|
b[5] = 0xff // file is expected to start from uint32 (4 bytes) followed by the first block, so corrupt the first block bytes
|
||||||
require.NoError(t, ioutil.WriteFile(inPath, b, os.ModePerm))
|
require.NoError(t, os.WriteFile(inPath, b, os.ModePerm))
|
||||||
*in = inPath
|
*in = inPath
|
||||||
require.Error(t, restoreDB(ctx))
|
require.Error(t, restoreDB(ctx))
|
||||||
|
|
||||||
|
@ -258,12 +257,12 @@ func TestRestoreDB(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("incremental dump", func(t *testing.T) {
|
t.Run("incremental dump", func(t *testing.T) {
|
||||||
inPath := filepath.Join(t.TempDir(), "file1_incremental.acc")
|
inPath := filepath.Join(t.TempDir(), "file1_incremental.acc")
|
||||||
b, err := ioutil.ReadFile(testDump)
|
b, err := os.ReadFile(testDump)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
start := make([]byte, 4)
|
start := make([]byte, 4)
|
||||||
t.Run("good", func(t *testing.T) {
|
t.Run("good", func(t *testing.T) {
|
||||||
binary.LittleEndian.PutUint32(start, 1) // start from the first block
|
binary.LittleEndian.PutUint32(start, 1) // start from the first block
|
||||||
require.NoError(t, ioutil.WriteFile(inPath, append(start, b...),
|
require.NoError(t, os.WriteFile(inPath, append(start, b...),
|
||||||
os.ModePerm))
|
os.ModePerm))
|
||||||
*in = inPath
|
*in = inPath
|
||||||
*incremental = true
|
*incremental = true
|
||||||
|
@ -272,7 +271,7 @@ func TestRestoreDB(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("dump is too high", func(t *testing.T) {
|
t.Run("dump is too high", func(t *testing.T) {
|
||||||
binary.LittleEndian.PutUint32(start, 2) // start from the second block
|
binary.LittleEndian.PutUint32(start, 2) // start from the second block
|
||||||
require.NoError(t, ioutil.WriteFile(inPath, append(start, b...),
|
require.NoError(t, os.WriteFile(inPath, append(start, b...),
|
||||||
os.ModePerm))
|
os.ModePerm))
|
||||||
*in = inPath
|
*in = inPath
|
||||||
*incremental = true
|
*incremental = true
|
||||||
|
|
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -31,7 +30,7 @@ func TestServerStart(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cfgPath := filepath.Join(tmpDir, "protocol.unit_testnet.yml")
|
cfgPath := filepath.Join(tmpDir, "protocol.unit_testnet.yml")
|
||||||
require.NoError(t, ioutil.WriteFile(cfgPath, out, os.ModePerm))
|
require.NoError(t, os.WriteFile(cfgPath, out, os.ModePerm))
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
require.NoError(t, os.Remove(cfgPath))
|
require.NoError(t, os.Remove(cfgPath))
|
||||||
})
|
})
|
||||||
|
@ -47,7 +46,7 @@ func TestServerStart(t *testing.T) {
|
||||||
t.Run("bad logger config", func(t *testing.T) {
|
t.Run("bad logger config", func(t *testing.T) {
|
||||||
badConfigDir := t.TempDir()
|
badConfigDir := t.TempDir()
|
||||||
logfile := filepath.Join(badConfigDir, "logdir")
|
logfile := filepath.Join(badConfigDir, "logdir")
|
||||||
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
|
||||||
saveCfg(t, func(cfg *config.Config) {
|
saveCfg(t, func(cfg *config.Config) {
|
||||||
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,6 @@ package smartcontract
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -47,7 +46,7 @@ func contractGenerateWrapper(ctx *cli.Context) error {
|
||||||
|
|
||||||
cfg := binding.NewConfig()
|
cfg := binding.NewConfig()
|
||||||
if cfgPath := ctx.String("config"); cfgPath != "" {
|
if cfgPath := ctx.String("config"); cfgPath != "" {
|
||||||
bs, err := ioutil.ReadFile(cfgPath)
|
bs, err := os.ReadFile(cfgPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("can't read config file: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("can't read config file: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package smartcontract
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -115,7 +114,7 @@ func TestGenerate(t *testing.T) {
|
||||||
|
|
||||||
rawManifest, err := json.Marshal(m)
|
rawManifest, err := json.Marshal(m)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, ioutil.WriteFile(manifestFile, rawManifest, os.ModePerm))
|
require.NoError(t, os.WriteFile(manifestFile, rawManifest, os.ModePerm))
|
||||||
|
|
||||||
h := util.Uint160{
|
h := util.Uint160{
|
||||||
0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01,
|
0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01,
|
||||||
|
@ -139,7 +138,7 @@ callflags:
|
||||||
doSomething: ReadStates
|
doSomething: ReadStates
|
||||||
`
|
`
|
||||||
cfgPath := filepath.Join(t.TempDir(), "binding.yml")
|
cfgPath := filepath.Join(t.TempDir(), "binding.yml")
|
||||||
require.NoError(t, ioutil.WriteFile(cfgPath, []byte(rawCfg), os.ModePerm))
|
require.NoError(t, os.WriteFile(cfgPath, []byte(rawCfg), os.ModePerm))
|
||||||
|
|
||||||
require.NoError(t, app.Run([]string{"", "generate-wrapper",
|
require.NoError(t, app.Run([]string{"", "generate-wrapper",
|
||||||
"--manifest", manifestFile,
|
"--manifest", manifestFile,
|
||||||
|
@ -225,7 +224,7 @@ func MyFunc(in map[int]mycontract.Input) []mycontract.Output {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
data, err := ioutil.ReadFile(outFile)
|
data, err := os.ReadFile(outFile)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, expected, string(data))
|
require.Equal(t, expected, string(data))
|
||||||
}
|
}
|
||||||
|
@ -245,7 +244,7 @@ func TestGenerateValidPackageName(t *testing.T) {
|
||||||
|
|
||||||
rawManifest, err := json.Marshal(m)
|
rawManifest, err := json.Marshal(m)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, ioutil.WriteFile(manifestFile, rawManifest, os.ModePerm))
|
require.NoError(t, os.WriteFile(manifestFile, rawManifest, os.ModePerm))
|
||||||
|
|
||||||
h := util.Uint160{
|
h := util.Uint160{
|
||||||
0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01,
|
0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01,
|
||||||
|
@ -259,7 +258,7 @@ func TestGenerateValidPackageName(t *testing.T) {
|
||||||
"--hash", "0x" + h.StringLE(),
|
"--hash", "0x" + h.StringLE(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
data, err := ioutil.ReadFile(outFile)
|
data, err := os.ReadFile(outFile)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, `// Package myspacecontract contains wrappers for My space contract contract.
|
require.Equal(t, `// Package myspacecontract contains wrappers for My space contract contract.
|
||||||
package myspacecontract
|
package myspacecontract
|
||||||
|
@ -297,7 +296,7 @@ func TestGenerate_Errors(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("invalid manifest", func(t *testing.T) {
|
t.Run("invalid manifest", func(t *testing.T) {
|
||||||
manifestFile := filepath.Join(t.TempDir(), "invalid.json")
|
manifestFile := filepath.Join(t.TempDir(), "invalid.json")
|
||||||
require.NoError(t, ioutil.WriteFile(manifestFile, []byte("[]"), os.ModePerm))
|
require.NoError(t, os.WriteFile(manifestFile, []byte("[]"), os.ModePerm))
|
||||||
checkError(t, "", "--manifest", manifestFile)
|
checkError(t, "", "--manifest", manifestFile)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -305,7 +304,7 @@ func TestGenerate_Errors(t *testing.T) {
|
||||||
m := manifest.NewManifest("MyContract")
|
m := manifest.NewManifest("MyContract")
|
||||||
rawManifest, err := json.Marshal(m)
|
rawManifest, err := json.Marshal(m)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, ioutil.WriteFile(manifestFile, rawManifest, os.ModePerm))
|
require.NoError(t, os.WriteFile(manifestFile, rawManifest, os.ModePerm))
|
||||||
|
|
||||||
t.Run("invalid hash", func(t *testing.T) {
|
t.Run("invalid hash", func(t *testing.T) {
|
||||||
checkError(t, "invalid contract hash", "--manifest", manifestFile, "--hash", "xxx")
|
checkError(t, "invalid contract hash", "--manifest", manifestFile, "--hash", "xxx")
|
||||||
|
@ -321,7 +320,7 @@ callflags:
|
||||||
someFunc: ReadSometimes
|
someFunc: ReadSometimes
|
||||||
`
|
`
|
||||||
cfgPath := filepath.Join(t.TempDir(), "binding.yml")
|
cfgPath := filepath.Join(t.TempDir(), "binding.yml")
|
||||||
require.NoError(t, ioutil.WriteFile(cfgPath, []byte(rawCfg), os.ModePerm))
|
require.NoError(t, os.WriteFile(cfgPath, []byte(rawCfg), os.ModePerm))
|
||||||
|
|
||||||
checkError(t, "can't parse config file",
|
checkError(t, "can't parse config file",
|
||||||
"--manifest", manifestFile, "--hash", util.Uint160{}.StringLE(),
|
"--manifest", manifestFile, "--hash", util.Uint160{}.StringLE(),
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/cli/flags"
|
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||||
|
@ -78,7 +77,7 @@ func manifestAddGroup(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(fmt.Errorf("can't marshal manifest: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("can't marshal manifest: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(mPath, rawM, os.ModePerm)
|
err = os.WriteFile(mPath, rawM, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("can't write manifest file: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("can't write manifest file: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
@ -90,7 +89,7 @@ func readNEFFile(filename string) (*nef.File, []byte, error) {
|
||||||
return nil, nil, errors.New("no nef file was provided")
|
return nil, nil, errors.New("no nef file was provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := ioutil.ReadFile(filename)
|
f, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -108,7 +107,7 @@ func readManifest(filename string) (*manifest.Manifest, []byte, error) {
|
||||||
return nil, nil, errNoManifestFile
|
return nil, nil, errNoManifestFile
|
||||||
}
|
}
|
||||||
|
|
||||||
manifestBytes, err := ioutil.ReadFile(filename)
|
manifestBytes, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -455,7 +454,7 @@ func initSmartContract(ctx *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(filepath.Join(basePath, "neo-go.yml"), b, 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(basePath, "neo-go.yml"), b, 0644); err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,12 +467,12 @@ func initSmartContract(ctx *cli.Context) error {
|
||||||
require (
|
require (
|
||||||
github.com/nspcc-dev/neo-go/pkg/interop ` + ver + `
|
github.com/nspcc-dev/neo-go/pkg/interop ` + ver + `
|
||||||
)`)
|
)`)
|
||||||
if err := ioutil.WriteFile(filepath.Join(basePath, "go.mod"), gm, 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(basePath, "go.mod"), gm, 0644); err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
data := []byte(fmt.Sprintf(smartContractTmpl, contractName))
|
data := []byte(fmt.Sprintf(smartContractTmpl, contractName))
|
||||||
if err := ioutil.WriteFile(filepath.Join(basePath, fileName), data, 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(basePath, fileName), data, 0644); err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +547,7 @@ func calcHash(ctx *cli.Context) error {
|
||||||
if mpath == "" {
|
if mpath == "" {
|
||||||
return cli.NewExitError(errors.New("no manifest file provided"), 1)
|
return cli.NewExitError(errors.New("no manifest file provided"), 1)
|
||||||
}
|
}
|
||||||
f, err := ioutil.ReadFile(p)
|
f, err := os.ReadFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("can't read .nef file: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("can't read .nef file: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
@ -556,7 +555,7 @@ func calcHash(ctx *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("can't unmarshal .nef file: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("can't unmarshal .nef file: %w", err), 1)
|
||||||
}
|
}
|
||||||
manifestBytes, err := ioutil.ReadFile(mpath)
|
manifestBytes, err := os.ReadFile(mpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("failed to read manifest file: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("failed to read manifest file: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
@ -734,7 +733,7 @@ func testInvokeScript(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(errNoInput, 1)
|
return cli.NewExitError(errNoInput, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(src)
|
b, err := os.ReadFile(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
@ -798,7 +797,7 @@ func inspect(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(fmt.Errorf("failed to compile: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("failed to compile: %w", err), 1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
f, err := ioutil.ReadFile(in)
|
f, err := os.ReadFile(in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("failed to read .nef file: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("failed to read .nef file: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
@ -935,7 +934,7 @@ func contractDeploy(ctx *cli.Context) error {
|
||||||
// ParseContractConfig reads contract configuration file (.yaml) and returns unmarshalled ProjectConfig.
|
// ParseContractConfig reads contract configuration file (.yaml) and returns unmarshalled ProjectConfig.
|
||||||
func ParseContractConfig(confFile string) (ProjectConfig, error) {
|
func ParseContractConfig(confFile string) (ProjectConfig, error) {
|
||||||
conf := ProjectConfig{}
|
conf := ProjectConfig{}
|
||||||
confBytes, err := ioutil.ReadFile(confFile)
|
confBytes, err := os.ReadFile(confFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return conf, cli.NewExitError(err, 1)
|
return conf, cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package smartcontract
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -31,13 +30,13 @@ func TestInitSmartContract(t *testing.T) {
|
||||||
dirInfo, err := os.Stat(contractName)
|
dirInfo, err := os.Stat(contractName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, dirInfo.IsDir())
|
require.True(t, dirInfo.IsDir())
|
||||||
files, err := ioutil.ReadDir(contractName)
|
files, err := os.ReadDir(contractName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 3, len(files))
|
require.Equal(t, 3, len(files))
|
||||||
require.Equal(t, "go.mod", files[0].Name())
|
require.Equal(t, "go.mod", files[0].Name())
|
||||||
require.Equal(t, "main.go", files[1].Name())
|
require.Equal(t, "main.go", files[1].Name())
|
||||||
require.Equal(t, "neo-go.yml", files[2].Name())
|
require.Equal(t, "neo-go.yml", files[2].Name())
|
||||||
main, err := ioutil.ReadFile(contractName + "/" + files[1].Name())
|
main, err := os.ReadFile(contractName + "/" + files[1].Name())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t,
|
require.Equal(t,
|
||||||
`package `+contractName+`
|
`package `+contractName+`
|
||||||
|
@ -56,7 +55,7 @@ func RuntimeNotify(args []interface{}) {
|
||||||
runtime.Notify(notificationName, args)
|
runtime.Notify(notificationName, args)
|
||||||
}`, string(main))
|
}`, string(main))
|
||||||
|
|
||||||
manifest, err := ioutil.ReadFile(contractName + "/" + files[2].Name())
|
manifest, err := os.ReadFile(contractName + "/" + files[2].Name())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t,
|
require.Equal(t,
|
||||||
`name: testContract
|
`name: testContract
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
"go/types"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -156,7 +155,7 @@ func getBuildInfo(name string, src interface{}) (*buildInfo, error) {
|
||||||
case string:
|
case string:
|
||||||
buf = []byte(s)
|
buf = []byte(s)
|
||||||
case io.Reader:
|
case io.Reader:
|
||||||
buf, err = ioutil.ReadAll(s)
|
buf, err = io.ReadAll(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -164,10 +163,7 @@ func getBuildInfo(name string, src interface{}) (*buildInfo, error) {
|
||||||
panic(fmt.Sprintf("unsupported src type: %T", s))
|
panic(fmt.Sprintf("unsupported src type: %T", s))
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(runtime.Version(), "go1.15") {
|
if strings.HasPrefix(runtime.Version(), "go1.15") {
|
||||||
dir, err = ioutil.TempDir("", "*")
|
dir = os.TempDir()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
name = filepath.Join(dir, filepath.Base(name))
|
name = filepath.Join(dir, filepath.Base(name))
|
||||||
absName = name
|
absName = name
|
||||||
names = append(names, "file="+name)
|
names = append(names, "file="+name)
|
||||||
|
@ -259,7 +255,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
|
||||||
return nil, fmt.Errorf("error while serializing .nef file: %w", err)
|
return nil, fmt.Errorf("error while serializing .nef file: %w", err)
|
||||||
}
|
}
|
||||||
out := fmt.Sprintf("%s.%s", o.Outfile, o.Ext)
|
out := fmt.Sprintf("%s.%s", o.Outfile, o.Ext)
|
||||||
err = ioutil.WriteFile(out, bytes, os.ModePerm)
|
err = os.WriteFile(out, bytes, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return f.Script, err
|
return f.Script, err
|
||||||
}
|
}
|
||||||
|
@ -289,7 +285,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return f.Script, err
|
return f.Script, err
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(o.DebugInfo, data, os.ModePerm); err != nil {
|
if err := os.WriteFile(o.DebugInfo, data, os.ModePerm); err != nil {
|
||||||
return f.Script, err
|
return f.Script, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,7 +307,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't marshal bindings configuration: %w", err)
|
return nil, fmt.Errorf("can't marshal bindings configuration: %w", err)
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(o.BindingsFile, data, os.ModePerm)
|
err = os.WriteFile(o.BindingsFile, data, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't write bindings configuration: %w", err)
|
return nil, fmt.Errorf("can't write bindings configuration: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -326,7 +322,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return f.Script, fmt.Errorf("failed to marshal manifest to JSON: %w", err)
|
return f.Script, fmt.Errorf("failed to marshal manifest to JSON: %w", err)
|
||||||
}
|
}
|
||||||
return f.Script, ioutil.WriteFile(o.ManifestFile, mData, os.ModePerm)
|
return f.Script, os.WriteFile(o.ManifestFile, mData, os.ModePerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
return f.Script, nil
|
return f.Script, nil
|
||||||
|
|
|
@ -2,7 +2,6 @@ package compiler_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -49,7 +48,7 @@ func TestCompiler(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "TestCompile",
|
name: "TestCompile",
|
||||||
function: func(t *testing.T) {
|
function: func(t *testing.T) {
|
||||||
infos, err := ioutil.ReadDir(examplePath)
|
infos, err := os.ReadDir(examplePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
for _, info := range infos {
|
for _, info := range infos {
|
||||||
if !info.IsDir() {
|
if !info.IsDir() {
|
||||||
|
@ -66,7 +65,7 @@ func TestCompiler(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "TestCompileAndSave",
|
name: "TestCompileAndSave",
|
||||||
function: func(t *testing.T) {
|
function: func(t *testing.T) {
|
||||||
infos, err := ioutil.ReadDir(exampleCompilePath)
|
infos, err := os.ReadDir(exampleCompilePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
err = os.MkdirAll(exampleSavePath, os.ModePerm)
|
err = os.MkdirAll(exampleSavePath, os.ModePerm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -2,7 +2,6 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
|
@ -40,7 +39,7 @@ func LoadFile(configPath string) (Config, error) {
|
||||||
return Config{}, fmt.Errorf("config '%s' doesn't exist", configPath)
|
return Config{}, fmt.Errorf("config '%s' doesn't exist", configPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
configData, err := ioutil.ReadFile(configPath)
|
configData, err := os.ReadFile(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Config{}, fmt.Errorf("unable to read config: %w", err)
|
return Config{}, fmt.Errorf("unable to read config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
||||||
|
@ -25,7 +25,7 @@ func getDecodedBlock(t *testing.T, i int) *Block {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBlockData(i int) (map[string]interface{}, error) {
|
func getBlockData(i int) (map[string]interface{}, error) {
|
||||||
b, err := ioutil.ReadFile(fmt.Sprintf("../test_data/block_%d.json", i))
|
b, err := os.ReadFile(fmt.Sprintf("../test_data/block_%d.json", i))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
|
@ -988,7 +987,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
|
||||||
bytes, err := ne.Bytes()
|
bytes, err := ne.Bytes()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if saveState {
|
if saveState {
|
||||||
err = ioutil.WriteFile(helper1ContractNEFPath, bytes, os.ModePerm)
|
err = os.WriteFile(helper1ContractNEFPath, bytes, os.ModePerm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,7 +995,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
|
||||||
mData, err := json.Marshal(m)
|
mData, err := json.Marshal(m)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if saveState {
|
if saveState {
|
||||||
err = ioutil.WriteFile(helper1ContractManifestPath, mData, os.ModePerm)
|
err = os.WriteFile(helper1ContractManifestPath, mData, os.ModePerm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1022,7 +1021,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
|
||||||
bytes, err = ne.Bytes()
|
bytes, err = ne.Bytes()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if saveState {
|
if saveState {
|
||||||
err = ioutil.WriteFile(helper2ContractNEFPath, bytes, os.ModePerm)
|
err = os.WriteFile(helper2ContractNEFPath, bytes, os.ModePerm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1030,7 +1029,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
|
||||||
mData, err = json.Marshal(m)
|
mData, err = json.Marshal(m)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if saveState {
|
if saveState {
|
||||||
err = ioutil.WriteFile(helper2ContractManifestPath, mData, os.ModePerm)
|
err = os.WriteFile(helper2ContractManifestPath, mData, os.ModePerm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,12 +1040,12 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
|
||||||
func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*state.Contract, *state.Contract) {
|
func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*state.Contract, *state.Contract) {
|
||||||
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
|
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
|
||||||
|
|
||||||
neBytes, err := ioutil.ReadFile(helper1ContractNEFPath)
|
neBytes, err := os.ReadFile(helper1ContractNEFPath)
|
||||||
require.NoError(t, err, fmt.Errorf("nef1: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("nef1: %w", errNotFound))
|
||||||
ne, err := nef.FileFromBytes(neBytes)
|
ne, err := nef.FileFromBytes(neBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mBytes, err := ioutil.ReadFile(helper1ContractManifestPath)
|
mBytes, err := os.ReadFile(helper1ContractManifestPath)
|
||||||
require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound))
|
||||||
m := &manifest.Manifest{}
|
m := &manifest.Manifest{}
|
||||||
err = json.Unmarshal(mBytes, m)
|
err = json.Unmarshal(mBytes, m)
|
||||||
|
@ -1060,12 +1059,12 @@ func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
neBytes, err = ioutil.ReadFile(helper2ContractNEFPath)
|
neBytes, err = os.ReadFile(helper2ContractNEFPath)
|
||||||
require.NoError(t, err, fmt.Errorf("nef2: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("nef2: %w", errNotFound))
|
||||||
ne, err = nef.FileFromBytes(neBytes)
|
ne, err = nef.FileFromBytes(neBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mBytes, err = ioutil.ReadFile(helper2ContractManifestPath)
|
mBytes, err = os.ReadFile(helper2ContractManifestPath)
|
||||||
require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound))
|
||||||
m = &manifest.Manifest{}
|
m = &manifest.Manifest{}
|
||||||
err = json.Unmarshal(mBytes, m)
|
err = json.Unmarshal(mBytes, m)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -49,12 +49,12 @@ func TestManagement_MinimumDeploymentFee(t *testing.T) {
|
||||||
func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*state.Contract, *state.Contract) {
|
func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*state.Contract, *state.Contract) {
|
||||||
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
|
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
|
||||||
|
|
||||||
neBytes, err := ioutil.ReadFile(helper1ContractNEFPath)
|
neBytes, err := os.ReadFile(helper1ContractNEFPath)
|
||||||
require.NoError(t, err, fmt.Errorf("nef1: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("nef1: %w", errNotFound))
|
||||||
ne, err := nef.FileFromBytes(neBytes)
|
ne, err := nef.FileFromBytes(neBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mBytes, err := ioutil.ReadFile(helper1ContractManifestPath)
|
mBytes, err := os.ReadFile(helper1ContractManifestPath)
|
||||||
require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound))
|
||||||
m := &manifest.Manifest{}
|
m := &manifest.Manifest{}
|
||||||
err = json.Unmarshal(mBytes, m)
|
err = json.Unmarshal(mBytes, m)
|
||||||
|
@ -68,12 +68,12 @@ func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
neBytes, err = ioutil.ReadFile(helper2ContractNEFPath)
|
neBytes, err = os.ReadFile(helper2ContractNEFPath)
|
||||||
require.NoError(t, err, fmt.Errorf("nef2: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("nef2: %w", errNotFound))
|
||||||
ne, err = nef.FileFromBytes(neBytes)
|
ne, err = nef.FileFromBytes(neBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mBytes, err = ioutil.ReadFile(helper2ContractManifestPath)
|
mBytes, err = os.ReadFile(helper2ContractManifestPath)
|
||||||
require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound))
|
||||||
m = &manifest.Manifest{}
|
m = &manifest.Manifest{}
|
||||||
err = json.Unmarshal(mBytes, m)
|
err = json.Unmarshal(mBytes, m)
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -45,12 +45,12 @@ func getOracleContractState(t *testing.T, sender util.Uint160, id int32) *state.
|
||||||
)
|
)
|
||||||
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
|
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
|
||||||
|
|
||||||
neBytes, err := ioutil.ReadFile(oracleContractNEFPath)
|
neBytes, err := os.ReadFile(oracleContractNEFPath)
|
||||||
require.NoError(t, err, fmt.Errorf("nef: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("nef: %w", errNotFound))
|
||||||
ne, err := nef.FileFromBytes(neBytes)
|
ne, err := nef.FileFromBytes(neBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mBytes, err := ioutil.ReadFile(oracleContractManifestPath)
|
mBytes, err := os.ReadFile(oracleContractManifestPath)
|
||||||
require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound))
|
||||||
m := &manifest.Manifest{}
|
m := &manifest.Manifest{}
|
||||||
err = json.Unmarshal(mBytes, m)
|
err = json.Unmarshal(mBytes, m)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
gio "io"
|
gio "io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -124,7 +123,7 @@ func TestGenerateOracleContract(t *testing.T) {
|
||||||
bytes, err := ne.Bytes()
|
bytes, err := ne.Bytes()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if saveState {
|
if saveState {
|
||||||
err = ioutil.WriteFile(oracleContractNEFPath, bytes, os.ModePerm)
|
err = os.WriteFile(oracleContractNEFPath, bytes, os.ModePerm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ func TestGenerateOracleContract(t *testing.T) {
|
||||||
mData, err := json.Marshal(m)
|
mData, err := json.Marshal(m)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if saveState {
|
if saveState {
|
||||||
err = ioutil.WriteFile(oracleContractManifestPath, mData, os.ModePerm)
|
err = os.WriteFile(oracleContractManifestPath, mData, os.ModePerm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,12 +143,12 @@ func TestGenerateOracleContract(t *testing.T) {
|
||||||
func getOracleContractState(t *testing.T, sender util.Uint160, id int32) *state.Contract {
|
func getOracleContractState(t *testing.T, sender util.Uint160, id int32) *state.Contract {
|
||||||
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
|
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
|
||||||
|
|
||||||
neBytes, err := ioutil.ReadFile(oracleContractNEFPath)
|
neBytes, err := os.ReadFile(oracleContractNEFPath)
|
||||||
require.NoError(t, err, fmt.Errorf("nef: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("nef: %w", errNotFound))
|
||||||
ne, err := nef.FileFromBytes(neBytes)
|
ne, err := nef.FileFromBytes(neBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mBytes, err := ioutil.ReadFile(oracleContractManifestPath)
|
mBytes, err := os.ReadFile(oracleContractManifestPath)
|
||||||
require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound))
|
require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound))
|
||||||
m := &manifest.Manifest{}
|
m := &manifest.Manifest{}
|
||||||
err = json.Unmarshal(mBytes, m)
|
err = json.Unmarshal(mBytes, m)
|
||||||
|
@ -639,5 +638,5 @@ func newDefaultHTTPClient(returnOracleRedirectionErrOn func(address string) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newResponseBody(resp []byte) gio.ReadCloser {
|
func newResponseBody(resp []byte) gio.ReadCloser {
|
||||||
return ioutil.NopCloser(bytes.NewReader(resp))
|
return gio.NopCloser(bytes.NewReader(resp))
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
gio "io"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
@ -2029,7 +2029,7 @@ func doRPCCallOverHTTP(rpcCall string, url string, t *testing.T) []byte {
|
||||||
cl := http.Client{Timeout: time.Second}
|
cl := http.Client{Timeout: time.Second}
|
||||||
resp, err := cl.Post(url, "application/json", strings.NewReader(rpcCall))
|
resp, err := cl.Post(url, "application/json", strings.NewReader(rpcCall))
|
||||||
require.NoErrorf(t, err, "could not make a POST request")
|
require.NoErrorf(t, err, "could not make a POST request")
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := gio.ReadAll(resp.Body)
|
||||||
assert.NoErrorf(t, err, "could not read response from the request: %s", rpcCall)
|
assert.NoErrorf(t, err, "could not read response from the request: %s", rpcCall)
|
||||||
return bytes.TrimSpace(body)
|
return bytes.TrimSpace(body)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
@ -436,7 +436,7 @@ func NewParameterFromString(in string) (*Parameter, error) {
|
||||||
res.Type = inferParamType(val)
|
res.Type = inferParamType(val)
|
||||||
}
|
}
|
||||||
if res.Type == ByteArrayType && typStr == fileBytesParamType {
|
if res.Type == ByteArrayType && typStr == fileBytesParamType {
|
||||||
res.Value, err = ioutil.ReadFile(val)
|
res.Value, err = os.ReadFile(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read '%s' parameter from file '%s': %w", fileBytesParamType, val, err)
|
return nil, fmt.Errorf("failed to read '%s' parameter from file '%s': %w", fileBytesParamType, val, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -503,7 +502,7 @@ func handleReset(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getManifestFromFile(name string) (*manifest.Manifest, error) {
|
func getManifestFromFile(name string) (*manifest.Manifest, error) {
|
||||||
bs, err := ioutil.ReadFile(name)
|
bs, err := os.ReadFile(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%w: can't read manifest", ErrInvalidParameter)
|
return nil, fmt.Errorf("%w: can't read manifest", ErrInvalidParameter)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
gio "io"
|
gio "io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -209,14 +208,14 @@ func TestLoad(t *testing.T) {
|
||||||
checkLoadgo := func(t *testing.T, tName, cName, cErrName string) {
|
checkLoadgo := func(t *testing.T, tName, cName, cErrName string) {
|
||||||
t.Run("loadgo "+tName, func(t *testing.T) {
|
t.Run("loadgo "+tName, func(t *testing.T) {
|
||||||
filename := filepath.Join(tmpDir, cName)
|
filename := filepath.Join(tmpDir, cName)
|
||||||
require.NoError(t, ioutil.WriteFile(filename, []byte(src), os.ModePerm))
|
require.NoError(t, os.WriteFile(filename, []byte(src), os.ModePerm))
|
||||||
filename = "'" + filename + "'"
|
filename = "'" + filename + "'"
|
||||||
filenameErr := filepath.Join(tmpDir, cErrName)
|
filenameErr := filepath.Join(tmpDir, cErrName)
|
||||||
require.NoError(t, ioutil.WriteFile(filenameErr, []byte(src+"invalid_token"), os.ModePerm))
|
require.NoError(t, os.WriteFile(filenameErr, []byte(src+"invalid_token"), os.ModePerm))
|
||||||
filenameErr = "'" + filenameErr + "'"
|
filenameErr = "'" + filenameErr + "'"
|
||||||
goMod := []byte(`module test.example/vmcli
|
goMod := []byte(`module test.example/vmcli
|
||||||
go 1.16`)
|
go 1.16`)
|
||||||
require.NoError(t, ioutil.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
|
require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
|
||||||
|
|
||||||
e := newTestVMCLI(t)
|
e := newTestVMCLI(t)
|
||||||
e.runProgWithTimeout(t, 10*time.Second,
|
e.runProgWithTimeout(t, 10*time.Second,
|
||||||
|
@ -244,7 +243,7 @@ go 1.16`)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
filename := filepath.Join(tmpDir, "vmtestcontract.go")
|
filename := filepath.Join(tmpDir, "vmtestcontract.go")
|
||||||
require.NoError(t, ioutil.WriteFile(filename, []byte(srcAllowNotify), os.ModePerm))
|
require.NoError(t, os.WriteFile(filename, []byte(srcAllowNotify), os.ModePerm))
|
||||||
filename = "'" + filename + "'"
|
filename = "'" + filename + "'"
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -254,7 +253,7 @@ require (
|
||||||
)
|
)
|
||||||
replace github.com/nspcc-dev/neo-go/pkg/interop => ` + filepath.Join(wd, "../../interop") + `
|
replace github.com/nspcc-dev/neo-go/pkg/interop => ` + filepath.Join(wd, "../../interop") + `
|
||||||
go 1.16`)
|
go 1.16`)
|
||||||
require.NoError(t, ioutil.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
|
require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
|
||||||
|
|
||||||
e := newTestVMCLI(t)
|
e := newTestVMCLI(t)
|
||||||
e.runProg(t,
|
e.runProg(t,
|
||||||
|
@ -271,15 +270,15 @@ go 1.16`)
|
||||||
filename := filepath.Join(tmpDir, "vmtestcontract.nef")
|
filename := filepath.Join(tmpDir, "vmtestcontract.nef")
|
||||||
rawNef, err := nefFile.Bytes()
|
rawNef, err := nefFile.Bytes()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, ioutil.WriteFile(filename, rawNef, os.ModePerm))
|
require.NoError(t, os.WriteFile(filename, rawNef, os.ModePerm))
|
||||||
m, err := di.ConvertToManifest(&compiler.Options{})
|
m, err := di.ConvertToManifest(&compiler.Options{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
manifestFile := filepath.Join(tmpDir, "vmtestcontract.manifest.json")
|
manifestFile := filepath.Join(tmpDir, "vmtestcontract.manifest.json")
|
||||||
rawManifest, err := json.Marshal(m)
|
rawManifest, err := json.Marshal(m)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, ioutil.WriteFile(manifestFile, rawManifest, os.ModePerm))
|
require.NoError(t, os.WriteFile(manifestFile, rawManifest, os.ModePerm))
|
||||||
filenameErr := filepath.Join(tmpDir, "vmtestcontract_err.nef")
|
filenameErr := filepath.Join(tmpDir, "vmtestcontract_err.nef")
|
||||||
require.NoError(t, ioutil.WriteFile(filenameErr, append([]byte{1, 2, 3, 4}, rawNef...), os.ModePerm))
|
require.NoError(t, os.WriteFile(filenameErr, append([]byte{1, 2, 3, 4}, rawNef...), os.ModePerm))
|
||||||
notExists := filepath.Join(tmpDir, "notexists.json")
|
notExists := filepath.Join(tmpDir, "notexists.json")
|
||||||
|
|
||||||
manifestFile = "'" + manifestFile + "'"
|
manifestFile = "'" + manifestFile + "'"
|
||||||
|
@ -325,7 +324,7 @@ func TestRunWithDifferentArguments(t *testing.T) {
|
||||||
|
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
filename := filepath.Join(tmpDir, "run_vmtestcontract.go")
|
filename := filepath.Join(tmpDir, "run_vmtestcontract.go")
|
||||||
require.NoError(t, ioutil.WriteFile(filename, []byte(src), os.ModePerm))
|
require.NoError(t, os.WriteFile(filename, []byte(src), os.ModePerm))
|
||||||
|
|
||||||
filename = "'" + filename + "'"
|
filename = "'" + filename + "'"
|
||||||
e := newTestVMCLI(t)
|
e := newTestVMCLI(t)
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -129,7 +129,7 @@ func testSyscallHandler(v *VM, id uint32) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testFile(t *testing.T, filename string) {
|
func testFile(t *testing.T, filename string) {
|
||||||
data, err := ioutil.ReadFile(filename)
|
data, err := os.ReadFile(filename)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// get rid of possible BOM
|
// get rid of possible BOM
|
||||||
|
@ -472,7 +472,7 @@ func decodeBytes(data []byte) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
r := base64.NewDecoder(base64.StdEncoding, bytes.NewReader(data))
|
r := base64.NewDecoder(base64.StdEncoding, bytes.NewReader(data))
|
||||||
return ioutil.ReadAll(r)
|
return io.ReadAll(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeHex(s string) ([]byte, error) {
|
func decodeHex(s string) ([]byte, error) {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
|
@ -234,7 +233,7 @@ func (v *VM) AddBreakPointRel(n int) {
|
||||||
|
|
||||||
// LoadFileWithFlags loads a program in NEF format from the given path, ready to execute it.
|
// LoadFileWithFlags loads a program in NEF format from the given path, ready to execute it.
|
||||||
func (v *VM) LoadFileWithFlags(path string, f callflag.CallFlag) error {
|
func (v *VM) LoadFileWithFlags(path string, f callflag.CallFlag) error {
|
||||||
b, err := ioutil.ReadFile(path)
|
b, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package wallet
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -227,11 +227,11 @@ func TestRegenerateCLIWallet1_solo(t *testing.T) {
|
||||||
require.NoError(t, acc3.ConvertMultisig(1, keys.PublicKeys{getKeys(t)[0]}))
|
require.NoError(t, acc3.ConvertMultisig(1, keys.PublicKeys{getKeys(t)[0]}))
|
||||||
|
|
||||||
acc4 := getAccountWithScrypt(t, verifyWIF, "pass", scrypt) // deployed verify.go contract
|
acc4 := getAccountWithScrypt(t, verifyWIF, "pass", scrypt) // deployed verify.go contract
|
||||||
f, err := ioutil.ReadFile(verifyNEFPath)
|
f, err := os.ReadFile(verifyNEFPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
nefFile, err := nef.FileFromBytes(f)
|
nefFile, err := nef.FileFromBytes(f)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
manifestBytes, err := ioutil.ReadFile(verifyManifestPath)
|
manifestBytes, err := os.ReadFile(verifyManifestPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
m := &manifest.Manifest{}
|
m := &manifest.Manifest{}
|
||||||
require.NoError(t, json.Unmarshal(manifestBytes, m))
|
require.NoError(t, json.Unmarshal(manifestBytes, m))
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
@ -161,7 +160,7 @@ func (w *Wallet) savePretty() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Wallet) writeRaw(data []byte) error {
|
func (w *Wallet) writeRaw(data []byte) error {
|
||||||
return ioutil.WriteFile(w.path, data, 0644)
|
return os.WriteFile(w.path, data, 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON outputs a pretty JSON representation of the wallet.
|
// JSON outputs a pretty JSON representation of the wallet.
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -32,7 +31,7 @@ type storageOp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readFile(path string) (dump, error) {
|
func readFile(path string) (dump, error) {
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue