mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-05 03:06:16 +00:00
cli: allow to specify wallet via configuration file
This commit is contained in:
parent
5108d1c2c7
commit
213bfe6bbf
10 changed files with 367 additions and 148 deletions
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func TestCalcHash(t *testing.T) {
|
||||
|
@ -464,30 +465,26 @@ func TestContractManifestGroups(t *testing.T) {
|
|||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||
"--wallet", t.TempDir())
|
||||
})
|
||||
t.Run("invalid account", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||
"--wallet", testWalletPath, "--account", "not-an-acc")
|
||||
})
|
||||
t.Run("invalid sender", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||
"--wallet", testWalletPath, "--account", testWalletAccount,
|
||||
"--wallet", testWalletPath, "--address", testWalletAccount,
|
||||
"--sender", "not-a-sender")
|
||||
})
|
||||
t.Run("invalid NEF file", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||
"--wallet", testWalletPath, "--account", testWalletAccount,
|
||||
"--wallet", testWalletPath, "--address", testWalletAccount,
|
||||
"--sender", testWalletAccount, "--nef", tmpDir)
|
||||
})
|
||||
t.Run("corrupted NEF file", func(t *testing.T) {
|
||||
f := filepath.Join(tmpDir, "invalid.nef")
|
||||
require.NoError(t, os.WriteFile(f, []byte{1, 2, 3}, os.ModePerm))
|
||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||
"--wallet", testWalletPath, "--account", testWalletAccount,
|
||||
"--wallet", testWalletPath, "--address", testWalletAccount,
|
||||
"--sender", testWalletAccount, "--nef", f)
|
||||
})
|
||||
t.Run("invalid manifest file", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||
"--wallet", testWalletPath, "--account", testWalletAccount,
|
||||
"--wallet", testWalletPath, "--address", testWalletAccount,
|
||||
"--sender", testWalletAccount, "--nef", nefName,
|
||||
"--manifest", tmpDir)
|
||||
})
|
||||
|
@ -495,13 +492,13 @@ func TestContractManifestGroups(t *testing.T) {
|
|||
f := filepath.Join(tmpDir, "invalid.manifest.json")
|
||||
require.NoError(t, os.WriteFile(f, []byte{1, 2, 3}, os.ModePerm))
|
||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||
"--wallet", testWalletPath, "--account", testWalletAccount,
|
||||
"--wallet", testWalletPath, "--address", testWalletAccount,
|
||||
"--sender", testWalletAccount, "--nef", nefName,
|
||||
"--manifest", f)
|
||||
})
|
||||
t.Run("unknown account", func(t *testing.T) {
|
||||
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
|
||||
"--wallet", testWalletPath, "--account", util.Uint160{}.StringLE(),
|
||||
"--wallet", testWalletPath, "--address", util.Uint160{}.StringLE(),
|
||||
"--sender", testWalletAccount, "--nef", nefName,
|
||||
"--manifest", manifestName)
|
||||
})
|
||||
|
@ -510,11 +507,11 @@ func TestContractManifestGroups(t *testing.T) {
|
|||
|
||||
e.In.WriteString("testpass\r")
|
||||
e.Run(t, append(cmd, "--wallet", testWalletPath,
|
||||
"--sender", testWalletAccount, "--account", testWalletAccount)...)
|
||||
"--sender", testWalletAccount, "--address", testWalletAccount)...)
|
||||
|
||||
e.In.WriteString("testpass\r") // should override signature with the previous sender
|
||||
e.Run(t, append(cmd, "--wallet", testWalletPath,
|
||||
"--sender", validatorAddr, "--account", testWalletAccount)...)
|
||||
"--sender", validatorAddr, "--address", testWalletAccount)...)
|
||||
|
||||
e.In.WriteString("one\r")
|
||||
e.Run(t, "neo-go", "contract", "deploy",
|
||||
|
@ -613,10 +610,18 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
|||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--in", nefName, "--", address.Uint160ToString(util.Uint160{1, 2, 3}))
|
||||
|
||||
e.In.WriteString("one\r")
|
||||
tmp := t.TempDir()
|
||||
configPath := filepath.Join(tmp, "config.yaml")
|
||||
cfg := config.Wallet{
|
||||
Path: validatorWallet,
|
||||
Password: "one",
|
||||
}
|
||||
yml, err := yaml.Marshal(cfg)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, os.WriteFile(configPath, yml, 0666))
|
||||
e.Run(t, "neo-go", "contract", "deploy",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr, "--force",
|
||||
"--wallet", validatorWallet, "--address", validatorAddr,
|
||||
"--wallet-config", configPath, "--address", validatorAddr,
|
||||
"--in", nefName, "--manifest", manifestName)
|
||||
|
||||
e.checkTxPersisted(t, "Sent invocation transaction ")
|
||||
|
@ -713,6 +718,10 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
|||
e.In.WriteString("y\r")
|
||||
e.Run(t, append(cmd, "--wallet", validatorWallet, h.StringLE(), "getValue")...)
|
||||
})
|
||||
t.Run("good: from wallet config", func(t *testing.T) {
|
||||
e.In.WriteString("y\r")
|
||||
e.Run(t, append(cmd, "--wallet-config", configPath, h.StringLE(), "getValue")...)
|
||||
})
|
||||
|
||||
cmd = append(cmd, "--wallet", validatorWallet, "--address", validatorAddr)
|
||||
t.Run("cancelled", func(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue