From 0415e6dc10de037021f7135987183f28ea95349c Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 21 Jul 2021 18:25:10 +0300 Subject: [PATCH 1/3] cli/query: use application log for vm state C# node doesn't return VMState data, so it leads to "false" being printed for successful transactions. --- cli/query/query.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/query/query.go b/cli/query/query.go index d77850591..2f5c9945b 100644 --- a/cli/query/query.go +++ b/cli/query/query.go @@ -86,7 +86,11 @@ func dumpApplicationLog(ctx *cli.Context, res *result.ApplicationLog, tx *result _, _ = tw.Write([]byte("ValidUntil:\t" + strconv.FormatUint(uint64(tx.ValidUntilBlock), 10) + "\n")) } else { _, _ = tw.Write([]byte("BlockHash:\t" + tx.Blockhash.StringLE() + "\n")) - _, _ = tw.Write([]byte(fmt.Sprintf("Success:\t%t\n", tx.VMState == vm.HaltState.String()))) + if len(res.Executions) != 1 { + _, _ = tw.Write([]byte("Success:\tunknown (no execution data)\n")) + } else { + _, _ = tw.Write([]byte(fmt.Sprintf("Success:\t%t\n", res.Executions[0].VMState == vm.HaltState))) + } } if verbose { for _, sig := range tx.Signers { From 7fc3689b48efd3ee3f887294b729c60f82e67612 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 21 Jul 2021 18:26:58 +0300 Subject: [PATCH 2/3] cli/query: provide better help messages --- cli/query/query.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/query/query.go b/cli/query/query.go index 2f5c9945b..2ab483b77 100644 --- a/cli/query/query.go +++ b/cli/query/query.go @@ -26,11 +26,11 @@ func NewCommands() []cli.Command { }, options.RPC...) return []cli.Command{{ Name: "query", - Usage: "query", + Usage: "Query data from RPC node", Subcommands: []cli.Command{ { Name: "tx", - Usage: "query tx status", + Usage: "Query transaction status", Action: queryTx, Flags: queryTxFlags, }, From b7bfaa6d094d92bc32cc7eff1b22213b263594ad Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 21 Jul 2021 18:27:09 +0300 Subject: [PATCH 3/3] cli/query: print addresses instead of script hashes They're more familiar to users. --- cli/query/query.go | 3 ++- cli/query_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/query/query.go b/cli/query/query.go index 2ab483b77..9ee5b560d 100644 --- a/cli/query/query.go +++ b/cli/query/query.go @@ -9,6 +9,7 @@ import ( "text/tabwriter" "github.com/nspcc-dev/neo-go/cli/options" + "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/util" @@ -95,7 +96,7 @@ func dumpApplicationLog(ctx *cli.Context, res *result.ApplicationLog, tx *result if verbose { for _, sig := range tx.Signers { _, _ = tw.Write([]byte(fmt.Sprintf("Signer:\t%s (%s)", - sig.Account.StringLE(), + address.Uint160ToString(sig.Account), sig.Scopes) + "\n")) } _, _ = tw.Write([]byte("SystemFee:\t" + fixedn.Fixed8(tx.SystemFee).String() + " GAS\n")) diff --git a/cli/query_test.go b/cli/query_test.go index d267b4903..0e6f8e9d2 100644 --- a/cli/query_test.go +++ b/cli/query_test.go @@ -11,6 +11,7 @@ import ( "github.com/nspcc-dev/neo-go/internal/random" "github.com/nspcc-dev/neo-go/pkg/core/transaction" + "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" @@ -118,7 +119,7 @@ func (e *executor) compareQueryTxVerbose(t *testing.T, tx *transaction.Transacti res, _ := e.Chain.GetAppExecResults(tx.Hash(), trigger.Application) e.checkNextLine(t, fmt.Sprintf(`Success:\s+%t`, res[0].Execution.VMState == vm.HaltState)) for _, s := range tx.Signers { - e.checkNextLine(t, fmt.Sprintf(`Signer:\s+%s\s*\(%s\)`, s.Account.StringLE(), s.Scopes.String())) + e.checkNextLine(t, fmt.Sprintf(`Signer:\s+%s\s*\(%s\)`, address.Uint160ToString(s.Account), s.Scopes.String())) } e.checkNextLine(t, `SystemFee:\s+`+fixedn.Fixed8(tx.SystemFee).String()+" GAS$") e.checkNextLine(t, `NetworkFee:\s+`+fixedn.Fixed8(tx.NetworkFee).String()+" GAS$")