diff --git a/cli/nep5_test.go b/cli/nep5_test.go index f9a639cde..0a9013fa8 100644 --- a/cli/nep5_test.go +++ b/cli/nep5_test.go @@ -6,7 +6,9 @@ import ( "strings" "testing" + "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/address" + "github.com/nspcc-dev/neo-go/pkg/rpc/client" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/wallet" @@ -92,3 +94,43 @@ func TestNEP5Transfer(t *testing.T) { b, _ := e.Chain.GetGoverningTokenBalance(sh) require.Equal(t, big.NewInt(1), b) } + +func TestNEP5MultiTransfer(t *testing.T) { + privs := make([]*keys.PrivateKey, 3) + for i := range privs { + var err error + privs[i], err = keys.NewPrivateKey() + require.NoError(t, err) + } + + e := newExecutor(t, true) + defer e.Close(t) + args := []string{ + "neo-go", "wallet", "nep5", "multitransfer", + "--unittest", "--rpc-endpoint", "http://" + e.RPC.Addr, + "--wallet", validatorWallet, + "--from", validatorAddr, + "neo:" + privs[0].Address() + ":42", + "GAS:" + privs[1].Address() + ":7", + client.NeoContractHash.StringLE() + ":" + privs[2].Address() + ":13", + } + + e.In.WriteString("one\r") + e.Run(t, args...) + line, err := e.Out.ReadString('\n') + require.NoError(t, err) + h, err := util.Uint256DecodeStringLE(strings.TrimSpace(line)) + require.NoError(t, err, "can't decode tx hash: %s", line) + + tx := e.GetTransaction(t, h) + aer, err := e.Chain.GetAppExecResult(tx.Hash()) + require.NoError(t, err) + require.Equal(t, vm.HaltState, aer.VMState) + + b, _ := e.Chain.GetGoverningTokenBalance(privs[0].GetScriptHash()) + require.Equal(t, big.NewInt(42), b) + b = e.Chain.GetUtilityTokenBalance(privs[1].GetScriptHash()) + require.Equal(t, big.NewInt(int64(util.Fixed8FromInt64(7))), b) + b, _ = e.Chain.GetGoverningTokenBalance(privs[2].GetScriptHash()) + require.Equal(t, big.NewInt(13), b) +} diff --git a/cli/wallet/nep5.go b/cli/wallet/nep5.go index 2f7397f2f..0fa1d6350 100644 --- a/cli/wallet/nep5.go +++ b/cli/wallet/nep5.go @@ -373,7 +373,7 @@ func multiTransferNEP5(ctx *cli.Context) error { token, err = getMatchingToken(ctx, wall, ss[0]) if err != nil { fmt.Fprintln(ctx.App.ErrWriter, "Can't find matching token in the wallet. Querying RPC-node for balances.") - token, err = getMatchingTokenRPC(ctx, c, from, ctx.String("token")) + token, err = getMatchingTokenRPC(ctx, c, from, ss[0]) if err != nil { return cli.NewExitError(err, 1) }