Merge pull request #2283 from nspcc-dev/fix-vm-tests

vm: fix cli tests
This commit is contained in:
Roman Khimov 2021-12-01 11:35:41 +03:00 committed by GitHub
commit a0473aca92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,6 +77,9 @@ func newTestVMCLIWithLogo(t *testing.T, printLogo bool) *executor {
Prompt: "",
Stdin: e.in,
Stdout: e.out,
FuncIsTerminal: func() bool {
return false
},
})
return e
}
@ -202,8 +205,10 @@ func TestLoad(t *testing.T) {
t.Run("loadgo", func(t *testing.T) {
filename := filepath.Join(tmpDir, "vmtestcontract.go")
require.NoError(t, ioutil.WriteFile(filename, []byte(src), os.ModePerm))
filename = "'" + filename + "'"
filenameErr := filepath.Join(tmpDir, "vmtestcontract_err.go")
require.NoError(t, ioutil.WriteFile(filenameErr, []byte(src+"invalid_token"), os.ModePerm))
filenameErr = "'" + filenameErr + "'"
e := newTestVMCLI(t)
e.runProg(t,
@ -227,6 +232,7 @@ func TestLoad(t *testing.T) {
`
filename := filepath.Join(tmpDir, "vmtestcontract.go")
require.NoError(t, ioutil.WriteFile(filename, []byte(srcAllowNotify), os.ModePerm))
filename = "'" + filename + "'"
e := newTestVMCLI(t)
e.runProg(t,
@ -256,6 +262,10 @@ func TestLoad(t *testing.T) {
require.NoError(t, ioutil.WriteFile(filenameErr, append([]byte{1, 2, 3, 4}, rawNef...), os.ModePerm))
notExists := filepath.Join(tmpDir, "notexists.json")
manifestFile = "'" + manifestFile + "'"
filename = "'" + filename + "'"
filenameErr = "'" + filenameErr + "'"
e := newTestVMCLI(t)
e.runProg(t,
"loadnef",
@ -297,6 +307,7 @@ func TestRunWithDifferentArguments(t *testing.T) {
filename := filepath.Join(tmpDir, "run_vmtestcontract.go")
require.NoError(t, ioutil.WriteFile(filename, []byte(src), os.ModePerm))
filename = "'" + filename + "'"
e := newTestVMCLI(t)
e.runProg(t,
"loadgo "+filename, "run notexists",