From 14c2d7d25a1739a925636d5ba4776f18d96dec22 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 21 Apr 2021 15:01:42 +0300 Subject: [PATCH] cli: allow to provide cosigners for 'wallet nep17 multitransfer' --- cli/nep17_test.go | 39 ++++++++++++++++++++++++++++++--------- cli/wallet/nep17.go | 22 +++++++++++++++++++--- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/cli/nep17_test.go b/cli/nep17_test.go index 8226b8bb6..b614682d5 100644 --- a/cli/nep17_test.go +++ b/cli/nep17_test.go @@ -211,17 +211,38 @@ func TestNEP17MultiTransfer(t *testing.T) { "GAS:" + privs[1].Address() + ":7", neoContractHash.StringLE() + ":" + privs[2].Address() + ":13", } + hVerify := deployVerifyContract(t, e) - e.In.WriteString("one\r") - e.Run(t, args...) - e.checkTxPersisted(t) + t.Run("no cosigners", func(t *testing.T) { + e.In.WriteString("one\r") + e.Run(t, args...) + e.checkTxPersisted(t) - 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(fixedn.Fixed8FromInt64(7))), b) - b, _ = e.Chain.GetGoverningTokenBalance(privs[2].GetScriptHash()) - require.Equal(t, big.NewInt(13), b) + 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(fixedn.Fixed8FromInt64(7))), b) + b, _ = e.Chain.GetGoverningTokenBalance(privs[2].GetScriptHash()) + require.Equal(t, big.NewInt(13), b) + }) + + t.Run("invalid sender scope", func(t *testing.T) { + e.In.WriteString("one\r") + e.RunWithError(t, append(args, + "--", validatorAddr+":None")...) // invalid sender scope + }) + t.Run("Global sender scope", func(t *testing.T) { + e.In.WriteString("one\r") + e.Run(t, append(args, + "--", validatorAddr+":Global")...) + e.checkTxPersisted(t) + }) + t.Run("Several cosigners", func(t *testing.T) { + e.In.WriteString("one\r") + e.Run(t, append(args, + "--", validatorAddr, hVerify.StringLE())...) + e.checkTxPersisted(t) + }) } func TestNEP17ImportToken(t *testing.T) { diff --git a/cli/wallet/nep17.go b/cli/wallet/nep17.go index 88f90c108..4c01dbf14 100644 --- a/cli/wallet/nep17.go +++ b/cli/wallet/nep17.go @@ -126,7 +126,7 @@ func newNEP17Commands() []cli.Command { Name: "multitransfer", Usage: "transfer NEP17 tokens to multiple recipients", UsageText: `multitransfer --wallet --rpc-endpoint --timeout