mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 09:02:28 +00:00
cli/smartcontract: set correct version for pkg/interop
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
492db89576
commit
945b56e350
3 changed files with 30 additions and 10 deletions
|
@ -5,12 +5,12 @@ import (
|
|||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/internal/random"
|
||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/storage"
|
||||
|
@ -83,6 +83,12 @@ func TestCalcHash(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestContractInitAndCompile(t *testing.T) {
|
||||
// For proper nef generation.
|
||||
config.Version = "v0.98.1-test"
|
||||
|
||||
// For proper contract init. The actual version as it will be replaced.
|
||||
smartcontract.ModVersion = "v0.0.0"
|
||||
|
||||
tmpDir := t.TempDir()
|
||||
e := newExecutor(t, false)
|
||||
|
||||
|
@ -100,9 +106,6 @@ func TestContractInitAndCompile(t *testing.T) {
|
|||
e.RunWithError(t, "neo-go", "contract", "init", "--name", ctrPath)
|
||||
})
|
||||
|
||||
// For proper nef generation.
|
||||
config.Version = "0.90.0-test"
|
||||
|
||||
srcPath := filepath.Join(ctrPath, "main.go")
|
||||
cfgPath := filepath.Join(ctrPath, "neo-go.yml")
|
||||
nefPath := filepath.Join(tmpDir, "testcontract.nef")
|
||||
|
@ -121,10 +124,16 @@ func TestContractInitAndCompile(t *testing.T) {
|
|||
e.RunWithError(t, append(cmd, "--config", cfgName)...)
|
||||
})
|
||||
|
||||
// FIXME too bad
|
||||
c := exec.Command("go", "mod", "tidy")
|
||||
c.Dir = ctrPath
|
||||
require.NoError(t, c.Run())
|
||||
// Replace `pkg/interop` in go.mod to avoid getting an actual module version.
|
||||
goMod := filepath.Join(ctrPath, "go.mod")
|
||||
data, err := ioutil.ReadFile(goMod)
|
||||
require.NoError(t, err)
|
||||
|
||||
wd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
data = append(data, "\nreplace github.com/nspcc-dev/neo-go/pkg/interop => "...)
|
||||
data = append(data, filepath.Join(wd, "../pkg/interop")...)
|
||||
require.NoError(t, ioutil.WriteFile(goMod, data, os.ModePerm))
|
||||
|
||||
cmd = append(cmd, "--config", cfgPath)
|
||||
e.Run(t, cmd...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue