*: fix tests failing due to path.Join usage
Solution: Use `file/filepath` package to construct expected path. This package is OS-aware, see https://github.com/golang/go/issues/30616.
This commit is contained in:
parent
6cdb701a9d
commit
aefb6f9fee
21 changed files with 118 additions and 116 deletions
|
@ -5,7 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -60,7 +60,7 @@ func TestCalcHash(t *testing.T) {
|
||||||
"--in", "./testdata/verify.nef123", "--manifest", manifestPath)...)
|
"--in", "./testdata/verify.nef123", "--manifest", manifestPath)...)
|
||||||
})
|
})
|
||||||
t.Run("invalid file", func(t *testing.T) {
|
t.Run("invalid file", func(t *testing.T) {
|
||||||
p := path.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, ioutil.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)...)
|
||||||
})
|
})
|
||||||
|
@ -92,7 +92,7 @@ func TestContractInitAndCompile(t *testing.T) {
|
||||||
e.RunWithError(t, "neo-go", "contract", "init", "--name", "\x00")
|
e.RunWithError(t, "neo-go", "contract", "init", "--name", "\x00")
|
||||||
})
|
})
|
||||||
|
|
||||||
ctrPath := path.Join(tmpDir, "testcontract")
|
ctrPath := filepath.Join(tmpDir, "testcontract")
|
||||||
e.Run(t, "neo-go", "contract", "init", "--name", ctrPath)
|
e.Run(t, "neo-go", "contract", "init", "--name", ctrPath)
|
||||||
|
|
||||||
t.Run("don't rewrite existing directory", func(t *testing.T) {
|
t.Run("don't rewrite existing directory", func(t *testing.T) {
|
||||||
|
@ -102,10 +102,10 @@ func TestContractInitAndCompile(t *testing.T) {
|
||||||
// For proper nef generation.
|
// For proper nef generation.
|
||||||
config.Version = "0.90.0-test"
|
config.Version = "0.90.0-test"
|
||||||
|
|
||||||
srcPath := path.Join(ctrPath, "main.go")
|
srcPath := filepath.Join(ctrPath, "main.go")
|
||||||
cfgPath := path.Join(ctrPath, "neo-go.yml")
|
cfgPath := filepath.Join(ctrPath, "neo-go.yml")
|
||||||
nefPath := path.Join(tmpDir, "testcontract.nef")
|
nefPath := filepath.Join(tmpDir, "testcontract.nef")
|
||||||
manifestPath := path.Join(tmpDir, "testcontract.manifest.json")
|
manifestPath := filepath.Join(tmpDir, "testcontract.manifest.json")
|
||||||
cmd := []string{"neo-go", "contract", "compile"}
|
cmd := []string{"neo-go", "contract", "compile"}
|
||||||
t.Run("missing source", func(t *testing.T) {
|
t.Run("missing source", func(t *testing.T) {
|
||||||
e.RunWithError(t, cmd...)
|
e.RunWithError(t, cmd...)
|
||||||
|
@ -116,7 +116,7 @@ func TestContractInitAndCompile(t *testing.T) {
|
||||||
e.RunWithError(t, cmd...)
|
e.RunWithError(t, cmd...)
|
||||||
})
|
})
|
||||||
t.Run("provided non-existent config", func(t *testing.T) {
|
t.Run("provided non-existent config", func(t *testing.T) {
|
||||||
cfgName := path.Join(ctrPath, "notexists.yml")
|
cfgName := filepath.Join(ctrPath, "notexists.yml")
|
||||||
e.RunWithError(t, append(cmd, "--config", cfgName)...)
|
e.RunWithError(t, append(cmd, "--config", cfgName)...)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -143,8 +143,8 @@ func TestDeployBigContract(t *testing.T) {
|
||||||
config.Version = "0.90.0-test"
|
config.Version = "0.90.0-test"
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
nefName := path.Join(tmpDir, "deploy.nef")
|
nefName := filepath.Join(tmpDir, "deploy.nef")
|
||||||
manifestName := path.Join(tmpDir, "deploy.manifest.json")
|
manifestName := filepath.Join(tmpDir, "deploy.manifest.json")
|
||||||
e.Run(t, "neo-go", "contract", "compile",
|
e.Run(t, "neo-go", "contract", "compile",
|
||||||
"--in", "testdata/deploy/main.go", // compile single file
|
"--in", "testdata/deploy/main.go", // compile single file
|
||||||
"--config", "testdata/deploy/neo-go.yml",
|
"--config", "testdata/deploy/neo-go.yml",
|
||||||
|
@ -164,8 +164,8 @@ func TestContractDeployWithData(t *testing.T) {
|
||||||
config.Version = "0.90.0-test"
|
config.Version = "0.90.0-test"
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
nefName := path.Join(tmpDir, "deploy.nef")
|
nefName := filepath.Join(tmpDir, "deploy.nef")
|
||||||
manifestName := path.Join(tmpDir, "deploy.manifest.json")
|
manifestName := filepath.Join(tmpDir, "deploy.manifest.json")
|
||||||
eCompile.Run(t, "neo-go", "contract", "compile",
|
eCompile.Run(t, "neo-go", "contract", "compile",
|
||||||
"--in", "testdata/deploy/main.go", // compile single file
|
"--in", "testdata/deploy/main.go", // compile single file
|
||||||
"--config", "testdata/deploy/neo-go.yml",
|
"--config", "testdata/deploy/neo-go.yml",
|
||||||
|
@ -241,8 +241,8 @@ func TestDeployWithSigners(t *testing.T) {
|
||||||
config.Version = "0.90.0-test"
|
config.Version = "0.90.0-test"
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
nefName := path.Join(tmpDir, "deploy.nef")
|
nefName := filepath.Join(tmpDir, "deploy.nef")
|
||||||
manifestName := path.Join(tmpDir, "deploy.manifest.json")
|
manifestName := filepath.Join(tmpDir, "deploy.manifest.json")
|
||||||
e.Run(t, "neo-go", "contract", "compile",
|
e.Run(t, "neo-go", "contract", "compile",
|
||||||
"--in", "testdata/deploy/main.go",
|
"--in", "testdata/deploy/main.go",
|
||||||
"--config", "testdata/deploy/neo-go.yml",
|
"--config", "testdata/deploy/neo-go.yml",
|
||||||
|
@ -270,8 +270,8 @@ func TestContractManifestGroups(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer w.Close()
|
defer w.Close()
|
||||||
|
|
||||||
nefName := path.Join(tmpDir, "deploy.nef")
|
nefName := filepath.Join(tmpDir, "deploy.nef")
|
||||||
manifestName := path.Join(tmpDir, "deploy.manifest.json")
|
manifestName := filepath.Join(tmpDir, "deploy.manifest.json")
|
||||||
e.Run(t, "neo-go", "contract", "compile",
|
e.Run(t, "neo-go", "contract", "compile",
|
||||||
"--in", "testdata/deploy/main.go", // compile single file
|
"--in", "testdata/deploy/main.go", // compile single file
|
||||||
"--config", "testdata/deploy/neo-go.yml",
|
"--config", "testdata/deploy/neo-go.yml",
|
||||||
|
@ -302,8 +302,8 @@ func deployVerifyContract(t *testing.T, e *executor) util.Uint160 {
|
||||||
|
|
||||||
func deployContract(t *testing.T, e *executor, inPath, configPath, wallet, address, pass string) util.Uint160 {
|
func deployContract(t *testing.T, e *executor, inPath, configPath, wallet, address, pass string) util.Uint160 {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
nefName := path.Join(tmpDir, "contract.nef")
|
nefName := filepath.Join(tmpDir, "contract.nef")
|
||||||
manifestName := path.Join(tmpDir, "contract.manifest.json")
|
manifestName := filepath.Join(tmpDir, "contract.manifest.json")
|
||||||
e.Run(t, "neo-go", "contract", "compile",
|
e.Run(t, "neo-go", "contract", "compile",
|
||||||
"--in", inPath,
|
"--in", inPath,
|
||||||
"--config", configPath,
|
"--config", configPath,
|
||||||
|
@ -330,8 +330,8 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
||||||
config.Version = "0.90.0-test"
|
config.Version = "0.90.0-test"
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
nefName := path.Join(tmpDir, "deploy.nef")
|
nefName := filepath.Join(tmpDir, "deploy.nef")
|
||||||
manifestName := path.Join(tmpDir, "deploy.manifest.json")
|
manifestName := filepath.Join(tmpDir, "deploy.manifest.json")
|
||||||
e.Run(t, "neo-go", "contract", "compile",
|
e.Run(t, "neo-go", "contract", "compile",
|
||||||
"--in", "testdata/deploy/main.go", // compile single file
|
"--in", "testdata/deploy/main.go", // compile single file
|
||||||
"--config", "testdata/deploy/neo-go.yml",
|
"--config", "testdata/deploy/neo-go.yml",
|
||||||
|
@ -417,7 +417,7 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
||||||
e.RunWithError(t, cmd...)
|
e.RunWithError(t, cmd...)
|
||||||
})
|
})
|
||||||
t.Run("non-existent wallet", func(t *testing.T) {
|
t.Run("non-existent wallet", func(t *testing.T) {
|
||||||
cmd := append(cmd, "--wallet", path.Join(tmpDir, "not.exists"),
|
cmd := append(cmd, "--wallet", filepath.Join(tmpDir, "not.exists"),
|
||||||
h.StringLE(), "getValue")
|
h.StringLE(), "getValue")
|
||||||
e.RunWithError(t, cmd...)
|
e.RunWithError(t, cmd...)
|
||||||
})
|
})
|
||||||
|
@ -452,7 +452,7 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("real invoke and save tx", func(t *testing.T) {
|
t.Run("real invoke and save tx", func(t *testing.T) {
|
||||||
txout := path.Join(tmpDir, "test_contract_tx.json")
|
txout := filepath.Join(tmpDir, "test_contract_tx.json")
|
||||||
|
|
||||||
cmd = []string{"neo-go", "contract", "invokefunction",
|
cmd = []string{"neo-go", "contract", "invokefunction",
|
||||||
"--rpc-endpoint", "http://" + e.RPC.Addr,
|
"--rpc-endpoint", "http://" + e.RPC.Addr,
|
||||||
|
@ -540,8 +540,8 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Update", func(t *testing.T) {
|
t.Run("Update", func(t *testing.T) {
|
||||||
nefName := path.Join(tmpDir, "updated.nef")
|
nefName := filepath.Join(tmpDir, "updated.nef")
|
||||||
manifestName := path.Join(tmpDir, "updated.manifest.json")
|
manifestName := filepath.Join(tmpDir, "updated.manifest.json")
|
||||||
e.Run(t, "neo-go", "contract", "compile",
|
e.Run(t, "neo-go", "contract", "compile",
|
||||||
"--config", "testdata/deploy/neo-go.yml",
|
"--config", "testdata/deploy/neo-go.yml",
|
||||||
"--in", "testdata/deploy/", // compile all files in dir
|
"--in", "testdata/deploy/", // compile all files in dir
|
||||||
|
@ -589,8 +589,8 @@ func TestContractInspect(t *testing.T) {
|
||||||
const srcPath = "testdata/deploy/main.go"
|
const srcPath = "testdata/deploy/main.go"
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
nefName := path.Join(tmpDir, "deploy.nef")
|
nefName := filepath.Join(tmpDir, "deploy.nef")
|
||||||
manifestName := path.Join(tmpDir, "deploy.manifest.json")
|
manifestName := filepath.Join(tmpDir, "deploy.manifest.json")
|
||||||
e.Run(t, "neo-go", "contract", "compile",
|
e.Run(t, "neo-go", "contract", "compile",
|
||||||
"--in", srcPath,
|
"--in", srcPath,
|
||||||
"--config", "testdata/deploy/neo-go.yml",
|
"--config", "testdata/deploy/neo-go.yml",
|
||||||
|
@ -607,7 +607,7 @@ func TestContractInspect(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("with nef", func(t *testing.T) {
|
t.Run("with nef", func(t *testing.T) {
|
||||||
e.RunWithError(t, append(cmd, "--in", nefName, "--compile")...)
|
e.RunWithError(t, append(cmd, "--in", nefName, "--compile")...)
|
||||||
e.RunWithError(t, append(cmd, "--in", path.Join(tmpDir, "not.exists"))...)
|
e.RunWithError(t, append(cmd, "--in", filepath.Join(tmpDir, "not.exists"))...)
|
||||||
e.Run(t, append(cmd, "--in", nefName)...)
|
e.Run(t, append(cmd, "--in", nefName)...)
|
||||||
require.True(t, strings.Contains(e.Out.String(), "SYSCALL"))
|
require.True(t, strings.Contains(e.Out.String(), "SYSCALL"))
|
||||||
})
|
})
|
||||||
|
@ -631,20 +631,20 @@ 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(path.Join(examplePath, info.Name()))
|
infos, err := ioutil.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")
|
||||||
|
|
||||||
outF := path.Join(tmpDir, info.Name()+".nef")
|
outF := filepath.Join(tmpDir, info.Name()+".nef")
|
||||||
manifestF := path.Join(tmpDir, info.Name()+".manifest.json")
|
manifestF := filepath.Join(tmpDir, info.Name()+".manifest.json")
|
||||||
|
|
||||||
cfgName := filterFilename(infos, ".yml")
|
cfgName := filterFilename(infos, ".yml")
|
||||||
opts := []string{
|
opts := []string{
|
||||||
"neo-go", "contract", "compile",
|
"neo-go", "contract", "compile",
|
||||||
"--in", path.Join(examplePath, info.Name()),
|
"--in", filepath.Join(examplePath, info.Name()),
|
||||||
"--out", outF,
|
"--out", outF,
|
||||||
"--manifest", manifestF,
|
"--manifest", manifestF,
|
||||||
"--config", path.Join(examplePath, info.Name(), cfgName),
|
"--config", filepath.Join(examplePath, info.Name(), cfgName),
|
||||||
}
|
}
|
||||||
e.Run(t, opts...)
|
e.Run(t, opts...)
|
||||||
|
|
||||||
|
@ -669,13 +669,13 @@ func TestCompileExamples(t *testing.T) {
|
||||||
t.Run("invalid manifest", func(t *testing.T) {
|
t.Run("invalid manifest", func(t *testing.T) {
|
||||||
const dir = "./testdata/"
|
const dir = "./testdata/"
|
||||||
for _, name := range []string{"invalid1", "invalid2", "invalid3", "invalid4"} {
|
for _, name := range []string{"invalid1", "invalid2", "invalid3", "invalid4"} {
|
||||||
outF := path.Join(tmpDir, name+".nef")
|
outF := filepath.Join(tmpDir, name+".nef")
|
||||||
manifestF := path.Join(tmpDir, name+".manifest.json")
|
manifestF := filepath.Join(tmpDir, name+".manifest.json")
|
||||||
e.RunWithError(t, "neo-go", "contract", "compile",
|
e.RunWithError(t, "neo-go", "contract", "compile",
|
||||||
"--in", path.Join(dir, name),
|
"--in", filepath.Join(dir, name),
|
||||||
"--out", outF,
|
"--out", outF,
|
||||||
"--manifest", manifestF,
|
"--manifest", manifestF,
|
||||||
"--config", path.Join(dir, name, "invalid.yml"),
|
"--config", filepath.Join(dir, name, "invalid.yml"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||||
|
@ -14,8 +14,8 @@ import (
|
||||||
func TestDBRestore(t *testing.T) {
|
func TestDBRestore(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
chainPath := path.Join(tmpDir, "neogotestchain")
|
chainPath := filepath.Join(tmpDir, "neogotestchain")
|
||||||
cfg, err := config.LoadFile("../config/protocol.unit_testnet.yml")
|
cfg, err := config.LoadFile(filepath.Join("..", "config", "protocol.unit_testnet.yml"))
|
||||||
require.NoError(t, err, "could not load config")
|
require.NoError(t, err, "could not load config")
|
||||||
cfg.ApplicationConfiguration.DBConfiguration.Type = "leveldb"
|
cfg.ApplicationConfiguration.DBConfiguration.Type = "leveldb"
|
||||||
cfg.ApplicationConfiguration.DBConfiguration.LevelDBOptions.DataDirectoryPath = chainPath
|
cfg.ApplicationConfiguration.DBConfiguration.LevelDBOptions.DataDirectoryPath = chainPath
|
||||||
|
@ -23,13 +23,13 @@ func TestDBRestore(t *testing.T) {
|
||||||
out, err := yaml.Marshal(cfg)
|
out, err := yaml.Marshal(cfg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cfgPath := path.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, ioutil.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"
|
||||||
e := newExecutor(t, false)
|
e := newExecutor(t, false)
|
||||||
stateDump := path.Join(tmpDir, "neogo.teststate")
|
stateDump := filepath.Join(tmpDir, "neogo.teststate")
|
||||||
baseArgs := []string{"neo-go", "db", "restore", "--unittest",
|
baseArgs := []string{"neo-go", "db", "restore", "--unittest",
|
||||||
"--config-path", tmpDir, "--in", inDump, "--dump", stateDump}
|
"--config-path", tmpDir, "--in", inDump, "--dump", stateDump}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func TestDBRestore(t *testing.T) {
|
||||||
e.Run(t, baseArgs...)
|
e.Run(t, baseArgs...)
|
||||||
|
|
||||||
// Dump and compare.
|
// Dump and compare.
|
||||||
dumpPath := path.Join(tmpDir, "testdump.acc")
|
dumpPath := filepath.Join(tmpDir, "testdump.acc")
|
||||||
e.Run(t, "neo-go", "db", "dump", "--unittest",
|
e.Run(t, "neo-go", "db", "dump", "--unittest",
|
||||||
"--config-path", tmpDir, "--out", dumpPath)
|
"--config-path", tmpDir, "--out", dumpPath)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||||
|
@ -32,8 +32,8 @@ func TestSignMultisigTx(t *testing.T) {
|
||||||
|
|
||||||
// Create 2 wallets participating in multisig.
|
// Create 2 wallets participating in multisig.
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
wallet1Path := path.Join(tmpDir, "multiWallet1.json")
|
wallet1Path := filepath.Join(tmpDir, "multiWallet1.json")
|
||||||
wallet2Path := path.Join(tmpDir, "multiWallet2.json")
|
wallet2Path := filepath.Join(tmpDir, "multiWallet2.json")
|
||||||
|
|
||||||
addAccount := func(w string, wif string) {
|
addAccount := func(w string, wif string) {
|
||||||
e.Run(t, "neo-go", "wallet", "init", "--wallet", w)
|
e.Run(t, "neo-go", "wallet", "init", "--wallet", w)
|
||||||
|
@ -64,7 +64,7 @@ func TestSignMultisigTx(t *testing.T) {
|
||||||
priv, err := keys.NewPrivateKey()
|
priv, err := keys.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
txPath := path.Join(tmpDir, "multisigtx.json")
|
txPath := filepath.Join(tmpDir, "multisigtx.json")
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
os.Remove(txPath)
|
os.Remove(txPath)
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ func TestNEP11Import(t *testing.T) {
|
||||||
e := newExecutor(t, true)
|
e := newExecutor(t, true)
|
||||||
|
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
walletPath := path.Join(tmpDir, "walletForImport.json")
|
walletPath := filepath.Join(tmpDir, "walletForImport.json")
|
||||||
|
|
||||||
// deploy NFT NeoNameService contract
|
// deploy NFT NeoNameService contract
|
||||||
nnsContractHash := deployNNSContract(t, e)
|
nnsContractHash := deployNNSContract(t, e)
|
||||||
|
@ -95,7 +95,7 @@ func TestNEP11_OwnerOf_BalanceOf_Transfer(t *testing.T) {
|
||||||
// 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 := ioutil.ReadFile(nftOwnerWallet)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
wall := path.Join(tmpDir, "my_wallet.json")
|
wall := filepath.Join(tmpDir, "my_wallet.json")
|
||||||
err = ioutil.WriteFile(wall, bytesRead, 0755)
|
err = ioutil.WriteFile(wall, bytesRead, 0755)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -298,7 +298,7 @@ func TestNEP17MultiTransfer(t *testing.T) {
|
||||||
func TestNEP17ImportToken(t *testing.T) {
|
func TestNEP17ImportToken(t *testing.T) {
|
||||||
e := newExecutor(t, true)
|
e := newExecutor(t, true)
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
walletPath := path.Join(tmpDir, "walletForImport.json")
|
walletPath := filepath.Join(tmpDir, "walletForImport.json")
|
||||||
|
|
||||||
neoContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Neo)
|
neoContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Neo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -11,13 +11,13 @@ func TestGetPath(t *testing.T) {
|
||||||
testPath := t.TempDir()
|
testPath := t.TempDir()
|
||||||
actual, err := getPath(testPath, 123)
|
actual, err := getPath(testPath, 123)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, path.Join(testPath, "/BlockStorage_100000/dump-block-1000.json"), actual)
|
require.Equal(t, filepath.Join(testPath, "BlockStorage_100000", "dump-block-1000.json"), actual)
|
||||||
|
|
||||||
actual, err = getPath(testPath, 1230)
|
actual, err = getPath(testPath, 1230)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, path.Join(testPath, "/BlockStorage_100000/dump-block-2000.json"), actual)
|
require.Equal(t, filepath.Join(testPath, "BlockStorage_100000", "dump-block-2000.json"), actual)
|
||||||
|
|
||||||
actual, err = getPath(testPath, 123000)
|
actual, err = getPath(testPath, 123000)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, path.Join(testPath, "/BlockStorage_200000/dump-block-123000.json"), actual)
|
require.Equal(t, filepath.Join(testPath, "BlockStorage_200000", "dump-block-123000.json"), actual)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package server
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||||
|
@ -40,7 +40,7 @@ func TestGetConfigFromContext(t *testing.T) {
|
||||||
func TestHandleLoggingParams(t *testing.T) {
|
func TestHandleLoggingParams(t *testing.T) {
|
||||||
// This test is failing on Windows, see https://github.com/nspcc-dev/neo-go/issues/2269
|
// This test is failing on Windows, see https://github.com/nspcc-dev/neo-go/issues/2269
|
||||||
d := t.TempDir()
|
d := t.TempDir()
|
||||||
testLog := path.Join(d, "file.log")
|
testLog := filepath.Join(d, "file.log")
|
||||||
|
|
||||||
t.Run("default", func(t *testing.T) {
|
t.Run("default", func(t *testing.T) {
|
||||||
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
||||||
|
@ -75,7 +75,7 @@ func TestInitBCWithMetrics(t *testing.T) {
|
||||||
t.Cleanup(func() { require.NoError(t, os.Chdir(serverTestWD)) })
|
t.Cleanup(func() { require.NoError(t, os.Chdir(serverTestWD)) })
|
||||||
|
|
||||||
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
||||||
set.String("config-path", path.Join(serverTestWD, "../../config"), "")
|
set.String("config-path", filepath.Join(serverTestWD, "..", "..", "config"), "")
|
||||||
set.Bool("testnet", true, "")
|
set.Bool("testnet", true, "")
|
||||||
set.Bool("debug", true, "")
|
set.Bool("debug", true, "")
|
||||||
ctx := cli.NewContext(cli.NewApp(), set, nil)
|
ctx := cli.NewContext(cli.NewApp(), set, nil)
|
||||||
|
@ -102,7 +102,7 @@ func TestDumpDB(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
t.Cleanup(func() { require.NoError(t, os.Chdir(serverTestWD)) })
|
t.Cleanup(func() { require.NoError(t, os.Chdir(serverTestWD)) })
|
||||||
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
||||||
set.String("config-path", path.Join(serverTestWD, "../../config"), "")
|
set.String("config-path", filepath.Join(serverTestWD, "..", "..", "config"), "")
|
||||||
set.Bool("privnet", true, "")
|
set.Bool("privnet", true, "")
|
||||||
set.Bool("debug", true, "")
|
set.Bool("debug", true, "")
|
||||||
set.Int("start", 0, "")
|
set.Int("start", 0, "")
|
||||||
|
@ -119,7 +119,7 @@ func TestDumpDB(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
t.Cleanup(func() { require.NoError(t, os.Chdir(serverTestWD)) })
|
t.Cleanup(func() { require.NoError(t, os.Chdir(serverTestWD)) })
|
||||||
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
||||||
set.String("config-path", path.Join(serverTestWD, "../../config"), "")
|
set.String("config-path", filepath.Join(serverTestWD, "..", "..", "config"), "")
|
||||||
set.Bool("privnet", true, "")
|
set.Bool("privnet", true, "")
|
||||||
set.Bool("debug", true, "")
|
set.Bool("debug", true, "")
|
||||||
set.Int("start", 0, "")
|
set.Int("start", 0, "")
|
||||||
|
@ -141,7 +141,7 @@ func TestRestoreDB(t *testing.T) {
|
||||||
|
|
||||||
//dump first
|
//dump first
|
||||||
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
set := flag.NewFlagSet("flagSet", flag.ExitOnError)
|
||||||
set.String("config-path", path.Join(serverTestWD, "../../config"), "")
|
set.String("config-path", filepath.Join(serverTestWD, "..", "..", "config"), "")
|
||||||
set.Bool("privnet", true, "")
|
set.Bool("privnet", true, "")
|
||||||
set.Bool("debug", true, "")
|
set.Bool("debug", true, "")
|
||||||
set.Int("start", 0, "")
|
set.Int("start", 0, "")
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -417,7 +416,7 @@ func initSmartContract(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
basePath := contractName
|
basePath := contractName
|
||||||
contractName = path.Base(contractName)
|
contractName = filepath.Base(contractName)
|
||||||
fileName := "main.go"
|
fileName := "main.go"
|
||||||
|
|
||||||
// create base directory
|
// create base directory
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/big"
|
"math/big"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ func TestWalletAccountRemove(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
e := newExecutor(t, false)
|
e := newExecutor(t, false)
|
||||||
|
|
||||||
walletPath := path.Join(tmpDir, "wallet.json")
|
walletPath := filepath.Join(tmpDir, "wallet.json")
|
||||||
e.In.WriteString("acc1\r")
|
e.In.WriteString("acc1\r")
|
||||||
e.In.WriteString("pass\r")
|
e.In.WriteString("pass\r")
|
||||||
e.In.WriteString("pass\r")
|
e.In.WriteString("pass\r")
|
||||||
|
@ -49,11 +49,11 @@ func TestWalletInit(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
e := newExecutor(t, false)
|
e := newExecutor(t, false)
|
||||||
|
|
||||||
walletPath := path.Join(tmpDir, "wallet.json")
|
walletPath := filepath.Join(tmpDir, "wallet.json")
|
||||||
e.Run(t, "neo-go", "wallet", "init", "--wallet", walletPath)
|
e.Run(t, "neo-go", "wallet", "init", "--wallet", walletPath)
|
||||||
|
|
||||||
t.Run("terminal escape codes", func(t *testing.T) {
|
t.Run("terminal escape codes", func(t *testing.T) {
|
||||||
walletPath := path.Join(tmpDir, "walletrussian.json")
|
walletPath := filepath.Join(tmpDir, "walletrussian.json")
|
||||||
bksp := string([]byte{
|
bksp := string([]byte{
|
||||||
byte(readline.CharBackward),
|
byte(readline.CharBackward),
|
||||||
byte(readline.CharDelete),
|
byte(readline.CharDelete),
|
||||||
|
@ -261,7 +261,7 @@ func TestImportDeployed(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
e := newExecutor(t, true)
|
e := newExecutor(t, true)
|
||||||
h := deployVerifyContract(t, e)
|
h := deployVerifyContract(t, e)
|
||||||
walletPath := path.Join(tmpDir, "wallet.json")
|
walletPath := filepath.Join(tmpDir, "wallet.json")
|
||||||
|
|
||||||
e.Run(t, "neo-go", "wallet", "init", "--wallet", walletPath)
|
e.Run(t, "neo-go", "wallet", "init", "--wallet", walletPath)
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ func TestWalletConvert(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
e := newExecutor(t, false)
|
e := newExecutor(t, false)
|
||||||
|
|
||||||
outPath := path.Join(tmpDir, "wallet.json")
|
outPath := filepath.Join(tmpDir, "wallet.json")
|
||||||
cmd := []string{"neo-go", "wallet", "convert"}
|
cmd := []string{"neo-go", "wallet", "convert"}
|
||||||
t.Run("missing wallet", func(t *testing.T) {
|
t.Run("missing wallet", func(t *testing.T) {
|
||||||
e.RunWithError(t, cmd...)
|
e.RunWithError(t, cmd...)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
|
@ -135,7 +135,7 @@ func getBuildInfo(name string, src interface{}) (*buildInfo, error) {
|
||||||
}
|
}
|
||||||
for i := range ds {
|
for i := range ds {
|
||||||
if !ds[i].IsDir() && strings.HasSuffix(ds[i].Name(), ".go") {
|
if !ds[i].IsDir() && strings.HasSuffix(ds[i].Name(), ".go") {
|
||||||
names = append(names, path.Join(name, ds[i].Name()))
|
names = append(names, filepath.Join(name, ds[i].Name()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ func TestCompiler(t *testing.T) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
targetPath := path.Join(examplePath, info.Name())
|
targetPath := filepath.Join(examplePath, info.Name())
|
||||||
require.NoError(t, compileFile(targetPath))
|
require.NoError(t, compileFile(targetPath))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1707,9 +1707,9 @@ func TestMPTDeleteNoKey(t *testing.T) {
|
||||||
// native contract is disabled. It's easy to forget about config while adding new
|
// native contract is disabled. It's easy to forget about config while adding new
|
||||||
// native contract.
|
// native contract.
|
||||||
func TestConfigNativeUpdateHistory(t *testing.T) {
|
func TestConfigNativeUpdateHistory(t *testing.T) {
|
||||||
const prefixPath = "../../config"
|
var prefixPath = filepath.Join("..", "..", "config")
|
||||||
check := func(t *testing.T, cfgFileSuffix interface{}) {
|
check := func(t *testing.T, cfgFileSuffix interface{}) {
|
||||||
cfgPath := path.Join(prefixPath, fmt.Sprintf("protocol.%s.yml", cfgFileSuffix))
|
cfgPath := filepath.Join(prefixPath, fmt.Sprintf("protocol.%s.yml", cfgFileSuffix))
|
||||||
cfg, err := config.LoadFile(cfgPath)
|
cfg, err := config.LoadFile(cfgPath)
|
||||||
require.NoError(t, err, fmt.Errorf("failed to load %s", cfgPath))
|
require.NoError(t, err, fmt.Errorf("failed to load %s", cfgPath))
|
||||||
natives := native.NewContracts(cfg.ProtocolConfiguration)
|
natives := native.NewContracts(cfg.ProtocolConfiguration)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -30,13 +31,13 @@ import (
|
||||||
"go.uber.org/zap/zaptest"
|
"go.uber.org/zap/zaptest"
|
||||||
)
|
)
|
||||||
|
|
||||||
const notaryModulePath = "../services/notary/"
|
var notaryModulePath = filepath.Join("..", "services", "notary")
|
||||||
|
|
||||||
func getTestNotary(t *testing.T, bc *Blockchain, walletPath, pass string, onTx func(tx *transaction.Transaction) error) (*wallet.Account, *notary.Notary, *mempool.Pool) {
|
func getTestNotary(t *testing.T, bc *Blockchain, walletPath, pass string, onTx func(tx *transaction.Transaction) error) (*wallet.Account, *notary.Notary, *mempool.Pool) {
|
||||||
mainCfg := config.P2PNotary{
|
mainCfg := config.P2PNotary{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
UnlockWallet: config.Wallet{
|
UnlockWallet: config.Wallet{
|
||||||
Path: path.Join(notaryModulePath, walletPath),
|
Path: filepath.Join(notaryModulePath, walletPath),
|
||||||
Password: pass,
|
Password: pass,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -28,7 +29,7 @@ import (
|
||||||
"go.uber.org/zap/zaptest"
|
"go.uber.org/zap/zaptest"
|
||||||
)
|
)
|
||||||
|
|
||||||
const oracleModulePath = "../services/oracle/"
|
var oracleModulePath = filepath.Join("..", "services", "oracle")
|
||||||
|
|
||||||
func getOracleConfig(t *testing.T, bc *Blockchain, w, pass string) oracle.Config {
|
func getOracleConfig(t *testing.T, bc *Blockchain, w, pass string) oracle.Config {
|
||||||
return oracle.Config{
|
return oracle.Config{
|
||||||
|
@ -38,7 +39,7 @@ func getOracleConfig(t *testing.T, bc *Blockchain, w, pass string) oracle.Config
|
||||||
RefreshInterval: time.Second,
|
RefreshInterval: time.Second,
|
||||||
AllowedContentTypes: []string{"application/json"},
|
AllowedContentTypes: []string{"application/json"},
|
||||||
UnlockWallet: config.Wallet{
|
UnlockWallet: config.Wallet{
|
||||||
Path: path.Join(oracleModulePath, w),
|
Path: filepath.Join(oracleModulePath, w),
|
||||||
Password: pass,
|
Password: pass,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,7 @@ package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"path"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -78,7 +78,7 @@ func TestStateRoot(t *testing.T) {
|
||||||
transferTokenFromMultisigAccount(t, bc, h, bc.contracts.GAS.Hash, 1_0000_0000)
|
transferTokenFromMultisigAccount(t, bc, h, bc.contracts.GAS.Hash, 1_0000_0000)
|
||||||
|
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
w := createAndWriteWallet(t, accs[0], path.Join(tmpDir, "w"), "pass")
|
w := createAndWriteWallet(t, accs[0], filepath.Join(tmpDir, "w"), "pass")
|
||||||
cfg := createStateRootConfig(w.Path(), "pass")
|
cfg := createStateRootConfig(w.Path(), "pass")
|
||||||
srv, err := stateroot.New(cfg, zaptest.NewLogger(t), bc, nil)
|
srv, err := stateroot.New(cfg, zaptest.NewLogger(t), bc, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -146,7 +146,7 @@ func TestStateRootInitNonZeroHeight(t *testing.T) {
|
||||||
_, err := persistBlock(bc)
|
_, err := persistBlock(bc)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
w := createAndWriteWallet(t, accs[0], path.Join(tmpDir, "w"), "pass")
|
w := createAndWriteWallet(t, accs[0], filepath.Join(tmpDir, "w"), "pass")
|
||||||
cfg := createStateRootConfig(w.Path(), "pass")
|
cfg := createStateRootConfig(w.Path(), "pass")
|
||||||
srv, err := stateroot.New(cfg, zaptest.NewLogger(t), bc, nil)
|
srv, err := stateroot.New(cfg, zaptest.NewLogger(t), bc, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -189,7 +189,7 @@ func TestStateRootFull(t *testing.T) {
|
||||||
bc := newTestChain(t)
|
bc := newTestChain(t)
|
||||||
|
|
||||||
h, pubs, accs := newMajorityMultisigWithGAS(t, 2)
|
h, pubs, accs := newMajorityMultisigWithGAS(t, 2)
|
||||||
w := createAndWriteWallet(t, accs[1], path.Join(tmpDir, "wallet2"), "two")
|
w := createAndWriteWallet(t, accs[1], filepath.Join(tmpDir, "wallet2"), "two")
|
||||||
cfg := createStateRootConfig(w.Path(), "two")
|
cfg := createStateRootConfig(w.Path(), "two")
|
||||||
|
|
||||||
var lastValidated atomic.Value
|
var lastValidated atomic.Value
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
func newBoltStoreForTesting(t testing.TB) Store {
|
func newBoltStoreForTesting(t testing.TB) Store {
|
||||||
d := t.TempDir()
|
d := t.TempDir()
|
||||||
testFileName := path.Join(d, "test_bolt_db")
|
testFileName := filepath.Join(d, "test_bolt_db")
|
||||||
boltDBStore, err := NewBoltDBStore(BoltDBOptions{FilePath: testFileName})
|
boltDBStore, err := NewBoltDBStore(BoltDBOptions{FilePath: testFileName})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return boltDBStore
|
return boltDBStore
|
||||||
|
|
|
@ -3,13 +3,13 @@ package io
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MakeDirForFile creates directory provided in filePath.
|
// MakeDirForFile creates directory provided in filePath.
|
||||||
func MakeDirForFile(filePath string, creator string) error {
|
func MakeDirForFile(filePath string, creator string) error {
|
||||||
fileName := filePath
|
fileName := filePath
|
||||||
dir := path.Dir(fileName)
|
dir := filepath.Dir(fileName)
|
||||||
err := os.MkdirAll(dir, os.ModePerm)
|
err := os.MkdirAll(dir, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not create dir for %s: %w", creator, err)
|
return fmt.Errorf("could not create dir for %s: %w", creator, err)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package io
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
func TestMakeDirForFile_HappyPath(t *testing.T) {
|
func TestMakeDirForFile_HappyPath(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
filePath := path.Join(tempDir, "testDir", "testFile.test")
|
filePath := filepath.Join(tempDir, "testDir", "testFile.test")
|
||||||
err := MakeDirForFile(filePath, "test")
|
err := MakeDirForFile(filePath, "test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -21,12 +21,12 @@ func TestMakeDirForFile_HappyPath(t *testing.T) {
|
||||||
|
|
||||||
func TestMakeDirForFile_Negative(t *testing.T) {
|
func TestMakeDirForFile_Negative(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
filePath := path.Join(tempDir, "testFile.test")
|
filePath := filepath.Join(tempDir, "testFile.test")
|
||||||
f, err := os.Create(filePath)
|
f, err := os.Create(filePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NoError(t, f.Close())
|
require.NoError(t, f.Close())
|
||||||
|
|
||||||
filePath = path.Join(filePath, "error")
|
filePath = filepath.Join(filePath, "error")
|
||||||
err = MakeDirForFile(filePath, "test")
|
err = MakeDirForFile(filePath, "test")
|
||||||
require.Errorf(t, err, "could not create dir for test: mkdir %s : not a directory", filePath)
|
require.Errorf(t, err, "could not create dir for test: mkdir %s : not a directory", filePath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
gio "io"
|
gio "io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -200,9 +200,9 @@ func TestLoad(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
t.Run("loadgo", func(t *testing.T) {
|
t.Run("loadgo", func(t *testing.T) {
|
||||||
filename := path.Join(tmpDir, "vmtestcontract.go")
|
filename := filepath.Join(tmpDir, "vmtestcontract.go")
|
||||||
require.NoError(t, ioutil.WriteFile(filename, []byte(src), os.ModePerm))
|
require.NoError(t, ioutil.WriteFile(filename, []byte(src), os.ModePerm))
|
||||||
filenameErr := path.Join(tmpDir, "vmtestcontract_err.go")
|
filenameErr := filepath.Join(tmpDir, "vmtestcontract_err.go")
|
||||||
require.NoError(t, ioutil.WriteFile(filenameErr, []byte(src+"invalid_token"), os.ModePerm))
|
require.NoError(t, ioutil.WriteFile(filenameErr, []byte(src+"invalid_token"), os.ModePerm))
|
||||||
|
|
||||||
e := newTestVMCLI(t)
|
e := newTestVMCLI(t)
|
||||||
|
@ -225,7 +225,7 @@ func TestLoad(t *testing.T) {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
filename := path.Join(tmpDir, "vmtestcontract.go")
|
filename := filepath.Join(tmpDir, "vmtestcontract.go")
|
||||||
require.NoError(t, ioutil.WriteFile(filename, []byte(srcAllowNotify), os.ModePerm))
|
require.NoError(t, ioutil.WriteFile(filename, []byte(srcAllowNotify), os.ModePerm))
|
||||||
|
|
||||||
e := newTestVMCLI(t)
|
e := newTestVMCLI(t)
|
||||||
|
@ -242,19 +242,19 @@ func TestLoad(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
nefFile, err := nef.NewFile(script)
|
nefFile, err := nef.NewFile(script)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
filename := path.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, ioutil.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 := path.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, ioutil.WriteFile(manifestFile, rawManifest, os.ModePerm))
|
||||||
filenameErr := path.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, ioutil.WriteFile(filenameErr, append([]byte{1, 2, 3, 4}, rawNef...), os.ModePerm))
|
||||||
notExists := path.Join(tmpDir, "notexists.json")
|
notExists := filepath.Join(tmpDir, "notexists.json")
|
||||||
|
|
||||||
e := newTestVMCLI(t)
|
e := newTestVMCLI(t)
|
||||||
e.runProg(t,
|
e.runProg(t,
|
||||||
|
@ -294,7 +294,7 @@ func TestRunWithDifferentArguments(t *testing.T) {
|
||||||
}`
|
}`
|
||||||
|
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
filename := path.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, ioutil.WriteFile(filename, []byte(src), os.ModePerm))
|
||||||
|
|
||||||
e := newTestVMCLI(t)
|
e := newTestVMCLI(t)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
|
@ -57,7 +57,7 @@ func TestRegenerateSoloWallet(t *testing.T) {
|
||||||
if !regenerate {
|
if !regenerate {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
walletPath := path.Join(dockerWalletDir, "wallet1_solo.json")
|
walletPath := filepath.Join(dockerWalletDir, "wallet1_solo.json")
|
||||||
wif := privnetWIFs[0]
|
wif := privnetWIFs[0]
|
||||||
acc1 := getAccount(t, wif, "one")
|
acc1 := getAccount(t, wif, "one")
|
||||||
acc2 := getAccount(t, wif, "one")
|
acc2 := getAccount(t, wif, "one")
|
||||||
|
@ -76,7 +76,7 @@ func regenerateWallets(t *testing.T, dir string) {
|
||||||
acc2 := getAccount(t, privnetWIFs[i], passwords[i])
|
acc2 := getAccount(t, privnetWIFs[i], passwords[i])
|
||||||
require.NoError(t, acc2.ConvertMultisig(3, pubs))
|
require.NoError(t, acc2.ConvertMultisig(3, pubs))
|
||||||
|
|
||||||
createWallet(t, path.Join(dir, fmt.Sprintf("wallet%d.json", i+1)), acc1, acc2)
|
createWallet(t, filepath.Join(dir, fmt.Sprintf("wallet%d.json", i+1)), acc1, acc2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,9 +107,9 @@ func TestRegenerateWalletTestdata(t *testing.T) {
|
||||||
acc3 := getAccount(t, privnetWIFs[1], "two")
|
acc3 := getAccount(t, privnetWIFs[1], "two")
|
||||||
acc3.Default = true
|
acc3.Default = true
|
||||||
|
|
||||||
createWallet(t, path.Join(walletDir, "wallet1.json"), acc1, acc2)
|
createWallet(t, filepath.Join(walletDir, "wallet1.json"), acc1, acc2)
|
||||||
|
|
||||||
createWallet(t, path.Join(walletDir, "wallet2.json"), acc1, acc2, acc3)
|
createWallet(t, filepath.Join(walletDir, "wallet2.json"), acc1, acc2, acc3)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegenerateNotaryWallets(t *testing.T) {
|
func TestRegenerateNotaryWallets(t *testing.T) {
|
||||||
|
@ -117,21 +117,21 @@ func TestRegenerateNotaryWallets(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const (
|
const (
|
||||||
walletDir = "../services/notary/testdata/"
|
acc1WIF = "L1MstxuD8SvS9HuFcV5oYzcdA1xX8D9bD9qPwg8fU5SSywYBecg3"
|
||||||
acc1WIF = "L1MstxuD8SvS9HuFcV5oYzcdA1xX8D9bD9qPwg8fU5SSywYBecg3"
|
acc2WIF = "L2iGxPvxbyWpYEbCZk2L3PgT7sCQaSDAbBC4MRLAjhs1s2JZ1xs5"
|
||||||
acc2WIF = "L2iGxPvxbyWpYEbCZk2L3PgT7sCQaSDAbBC4MRLAjhs1s2JZ1xs5"
|
acc3WIF = "L1xD2yiUyARX8DAkWa8qGpWpwjqW2u717VzUJyByk6s7HinhRVZv"
|
||||||
acc3WIF = "L1xD2yiUyARX8DAkWa8qGpWpwjqW2u717VzUJyByk6s7HinhRVZv"
|
acc4WIF = "L1ioz93TNt6Nu1aoMpZQ4zgdtgC8ZvJMC6pyHFkrovdR3SFwbn6n"
|
||||||
acc4WIF = "L1ioz93TNt6Nu1aoMpZQ4zgdtgC8ZvJMC6pyHFkrovdR3SFwbn6n"
|
|
||||||
)
|
)
|
||||||
|
var walletDir = filepath.Join("..", "services", "notary", "testdata")
|
||||||
|
|
||||||
scryptParams := keys.ScryptParams{N: 2, R: 1, P: 1}
|
scryptParams := keys.ScryptParams{N: 2, R: 1, P: 1}
|
||||||
acc1 := getAccountWithScrypt(t, acc1WIF, "one", scryptParams)
|
acc1 := getAccountWithScrypt(t, acc1WIF, "one", scryptParams)
|
||||||
acc2 := getAccountWithScrypt(t, acc2WIF, "one", scryptParams)
|
acc2 := getAccountWithScrypt(t, acc2WIF, "one", scryptParams)
|
||||||
acc3 := getAccountWithScrypt(t, acc3WIF, "four", scryptParams)
|
acc3 := getAccountWithScrypt(t, acc3WIF, "four", scryptParams)
|
||||||
createWallet(t, path.Join(walletDir, "notary1.json"), acc1, acc2, acc3)
|
createWallet(t, filepath.Join(walletDir, "notary1.json"), acc1, acc2, acc3)
|
||||||
|
|
||||||
acc4 := getAccountWithScrypt(t, acc4WIF, "two", scryptParams)
|
acc4 := getAccountWithScrypt(t, acc4WIF, "two", scryptParams)
|
||||||
createWallet(t, path.Join(walletDir, "notary2.json"), acc4)
|
createWallet(t, filepath.Join(walletDir, "notary2.json"), acc4)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegenerateOracleWallets(t *testing.T) {
|
func TestRegenerateOracleWallets(t *testing.T) {
|
||||||
|
@ -145,10 +145,10 @@ func TestRegenerateOracleWallets(t *testing.T) {
|
||||||
)
|
)
|
||||||
|
|
||||||
acc1 := getAccount(t, acc1WIF, "one")
|
acc1 := getAccount(t, acc1WIF, "one")
|
||||||
createWallet(t, path.Join(walletDir, "oracle1.json"), acc1)
|
createWallet(t, filepath.Join(walletDir, "oracle1.json"), acc1)
|
||||||
|
|
||||||
acc2 := getAccount(t, acc2WIF, "two")
|
acc2 := getAccount(t, acc2WIF, "two")
|
||||||
createWallet(t, path.Join(walletDir, "oracle2.json"), acc2)
|
createWallet(t, filepath.Join(walletDir, "oracle2.json"), acc2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegenerateExamplesWallet(t *testing.T) {
|
func TestRegenerateExamplesWallet(t *testing.T) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package wallet
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
|
@ -124,7 +125,7 @@ func TestJSONMarshallUnmarshal(t *testing.T) {
|
||||||
|
|
||||||
func checkWalletConstructor(t *testing.T) *Wallet {
|
func checkWalletConstructor(t *testing.T) *Wallet {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
file := path.Join(tmpDir, walletTemplate)
|
file := filepath.Join(tmpDir, walletTemplate)
|
||||||
wallet, err := NewWallet(file)
|
wallet, err := NewWallet(file)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return wallet
|
return wallet
|
||||||
|
|
Loading…
Reference in a new issue