mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
parent
df3eb76aa2
commit
2096ad6e81
32 changed files with 134 additions and 159 deletions
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
@ -29,7 +28,7 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
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`
|
||||
const inDump = "./testdata/chain50x2.acc"
|
||||
|
@ -61,14 +60,14 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
t.Run("bad logger config", func(t *testing.T) {
|
||||
badConfigDir := t.TempDir()
|
||||
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.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
||||
out, err = yaml.Marshal(cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
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",
|
||||
"--config-path", badConfigDir, "--out", dumpPath)
|
||||
|
@ -76,14 +75,14 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
t.Run("bad storage config", func(t *testing.T) {
|
||||
badConfigDir := t.TempDir()
|
||||
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.ApplicationConfiguration.DBConfiguration.Type = ""
|
||||
out, err = yaml.Marshal(cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
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",
|
||||
"--config-path", badConfigDir, "--out", dumpPath)
|
||||
|
@ -98,9 +97,9 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
|
||||
e.Run(t, baseCmd...)
|
||||
|
||||
d1, err := ioutil.ReadFile(inDump)
|
||||
d1, err := os.ReadFile(inDump)
|
||||
require.NoError(t, err)
|
||||
d2, err := ioutil.ReadFile(dumpPath)
|
||||
d2, err := os.ReadFile(dumpPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, d1, d2, "dumps differ")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue