cli: add nep11 import command

This commit is contained in:
Anna Shaleva 2021-04-22 18:21:18 +03:00
parent 4b8d814ee8
commit a61a3d5ceb
5 changed files with 93 additions and 5 deletions

41
cli/nep11_test.go Normal file
View file

@ -0,0 +1,41 @@
package main
import (
"os"
"path"
"testing"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/stretchr/testify/require"
)
func TestNEP11Import(t *testing.T) {
e := newExecutor(t, true)
tmpDir := os.TempDir()
walletPath := path.Join(tmpDir, "walletForImport.json")
defer os.Remove(walletPath)
nnsContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.NameService)
require.NoError(t, err)
neoContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Neo)
require.NoError(t, err)
e.Run(t, "neo-go", "wallet", "init", "--wallet", walletPath)
args := []string{
"neo-go", "wallet", "nep11", "import",
"--rpc-endpoint", "http://" + e.RPC.Addr,
"--wallet", walletPath,
}
// missing token hash
e.RunWithError(t, args...)
// good
e.Run(t, append(args, "--token", nnsContractHash.StringLE())...)
// already exists
e.RunWithError(t, append(args, "--token", nnsContractHash.StringLE())...)
// not a NEP11 token
e.RunWithError(t, append(args, "--token", neoContractHash.StringLE())...)
}