From 36de70be10867da3737c8b3388d94e778cf7ceee Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Mon, 23 Oct 2017 19:35:02 -0400 Subject: [PATCH 1/2] console: fix output, closes #93 --- cmd/abci-cli/abci-cli.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/abci-cli/abci-cli.go b/cmd/abci-cli/abci-cli.go index 906520f0d..e098b9a38 100644 --- a/cmd/abci-cli/abci-cli.go +++ b/cmd/abci-cli/abci-cli.go @@ -259,7 +259,7 @@ func cmdBatch(cmd *cobra.Command, args []string) { func cmdConsole(cmd *cobra.Command, args []string) { for { - fmt.Printf("\n> ") + fmt.Printf("> ") bufReader := bufio.NewReader(os.Stdin) line, more, err := bufReader.ReadLine() if more { @@ -454,12 +454,16 @@ func printResponse(cmd *cobra.Command, args []string, rsp response) { fmt.Println(">", cmd.Use, strings.Join(args, " ")) } - if !rsp.Code.IsOK() { - fmt.Printf("-> code: %s\n", rsp.Code.String()) - } + // Always print the status code. + fmt.Printf("-> code: %s\n", rsp.Code.String()) + if len(rsp.Data) != 0 { - fmt.Printf("-> data: %s\n", rsp.Data) - fmt.Printf("-> data.hex: %X\n", rsp.Data) + // Do no print this line when using the commit command + // because the string comes out as gibberish + if cmd.Use != "commit" { + fmt.Printf("-> data: %s\n", rsp.Data) + } + fmt.Printf("-> data.hex: 0x%X\n", rsp.Data) } if rsp.Log != "" { fmt.Printf("-> log: %s\n", rsp.Log) From 4479e957095fb4616a86be325c6ee4e568ff624e Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Mon, 23 Oct 2017 19:54:38 -0400 Subject: [PATCH 2/2] console: fix tests --- tests/test_cli/ex1.abci.out | 22 +++++++++++++++------- tests/test_cli/ex2.abci.out | 8 +++++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tests/test_cli/ex1.abci.out b/tests/test_cli/ex1.abci.out index 21c778c71..6e3440712 100644 --- a/tests/test_cli/ex1.abci.out +++ b/tests/test_cli/ex1.abci.out @@ -1,36 +1,44 @@ > echo hello +-> code: OK -> data: hello --> data.hex: 68656C6C6F +-> data.hex: 0x68656C6C6F > info +-> code: OK -> data: {"size":0} --> data.hex: 7B2273697A65223A307D +-> data.hex: 0x7B2273697A65223A307D > commit +-> code: OK > deliver_tx "abc" +-> code: OK > info +-> code: OK -> data: {"size":1} --> data.hex: 7B2273697A65223A317D +-> data.hex: 0x7B2273697A65223A317D > commit --> data: IßÑ\ͬޮ—(ËûµèhŒ¥‹‘ --> data.hex: 49DFD15CCDACDEAE9728CB01FBB5E8688CA58B91 +-> code: OK +-> data.hex: 0x49DFD15CCDACDEAE9728CB01FBB5E8688CA58B91 > query "abc" +-> code: OK -> log: exists -> height: 0 -> value: abc -> value.hex: 616263 > deliver_tx "def=xyz" +-> code: OK > commit --> data: p-³"€7?¿?Ÿ‰Ú* Î,Ö+ --> data.hex: 70102DB32280373FBF3F9F89DA2A20CE2CD62B0B +-> code: OK +-> data.hex: 0x70102DB32280373FBF3F9F89DA2A20CE2CD62B0B > query "def" +-> code: OK -> log: exists -> height: 0 -> value: xyz diff --git a/tests/test_cli/ex2.abci.out b/tests/test_cli/ex2.abci.out index 202861cf4..40e10f83e 100644 --- a/tests/test_cli/ex2.abci.out +++ b/tests/test_cli/ex2.abci.out @@ -1,22 +1,28 @@ > set_option serial on +-> code: OK > check_tx 0x00 +-> code: OK > check_tx 0xff +-> code: OK > deliver_tx 0x00 +-> code: OK > check_tx 0x00 -> code: BadNonce -> log: Invalid nonce. Expected >= 1, got 0 > deliver_tx 0x01 +-> code: OK > deliver_tx 0x04 -> code: BadNonce -> log: Invalid nonce. Expected 2, got 4 > info +-> code: OK -> data: {"hashes":0,"txs":2} --> data.hex: 7B22686173686573223A302C22747873223A327D +-> data.hex: 0x7B22686173686573223A302C22747873223A327D