From 0dc606f50e56832145f51acd8718e937e35e1230 Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Wed, 29 Jun 2022 15:09:11 +0300 Subject: [PATCH 1/2] cli/smartcontract: print proper error message on failed testinvoke Do not print info about `--force` flag if we don't send or save a transaction. Signed-off-by: Evgeniy Stratonikov --- cli/smartcontract/smart_contract.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index 097529b1c..956c105b8 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -665,6 +665,10 @@ func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet, } if resp.State != "HALT" { errText := fmt.Sprintf("Warning: %s VM state returned from the RPC node: %s\n", resp.State, resp.FaultException) + if out == "" && !signAndPush { + return sender, cli.NewExitError(errText, 1) + } + action := "save" process := "Saving" if signAndPush { From 5eaa34c75f2f8a9dbd5d34b1630b3956d504181f Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Wed, 29 Jun 2022 15:12:24 +0300 Subject: [PATCH 2/2] cli/smartcontract: do not print dot on a separate line Signed-off-by: Evgeniy Stratonikov --- cli/smartcontract/smart_contract.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index 956c105b8..48af5d57b 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -664,7 +664,7 @@ func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet, return sender, cli.NewExitError(err, 1) } if resp.State != "HALT" { - errText := fmt.Sprintf("Warning: %s VM state returned from the RPC node: %s\n", resp.State, resp.FaultException) + errText := fmt.Sprintf("Warning: %s VM state returned from the RPC node: %s", resp.State, resp.FaultException) if out == "" && !signAndPush { return sender, cli.NewExitError(errText, 1) } @@ -681,9 +681,9 @@ func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet, } } if !ctx.Bool("force") { - return sender, cli.NewExitError(errText+". Use --force flag to "+action+" the transaction anyway.", 1) + return sender, cli.NewExitError(errText+".\nUse --force flag to "+action+" the transaction anyway.", 1) } - fmt.Fprintln(ctx.App.Writer, errText+". "+process+" transaction...") + fmt.Fprintln(ctx.App.Writer, errText+".\n"+process+" transaction...") } if out != "" { tx, err := c.CreateTxFromScript(resp.Script, acc, resp.GasConsumed+int64(sysgas), int64(gas), cosignersAccounts)