From 2d036c59fef9a2e34eb6e4747574bf9011ca3357 Mon Sep 17 00:00:00 2001 From: JayT106 Date: Wed, 23 Nov 2022 10:59:58 -0500 Subject: [PATCH] cli: fix abci help (#9717) * fix abci-cli help * add test * fix script * debugging CI * revert the changes for verifying CI * update pending log Co-authored-by: Sergio Mena --- CHANGELOG_PENDING.md | 1 + abci/cmd/abci-cli/abci-cli.go | 2 +- abci/tests/test_cli/test.sh | 26 ++++++++++++++++++++++++++ abci/tests/test_cli/testHelp.out | 30 ++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 abci/tests/test_cli/testHelp.out diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 11696ed3b..59b303e2e 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -38,6 +38,7 @@ ### BUG FIXES - [docker] \#9462 ensure Docker image uses consistent version of Go +- [abci-cli] \#9717 fix broken abci-cli help command ## v0.37.0 diff --git a/abci/cmd/abci-cli/abci-cli.go b/abci/cmd/abci-cli/abci-cli.go index e8de62d10..4a4201943 100644 --- a/abci/cmd/abci-cli/abci-cli.go +++ b/abci/cmd/abci-cli/abci-cli.go @@ -54,7 +54,7 @@ var RootCmd = &cobra.Command{ PersistentPreRunE: func(cmd *cobra.Command, args []string) error { switch cmd.Use { - case "kvstore", "version": + case "kvstore", "version", "help [command]": return nil } diff --git a/abci/tests/test_cli/test.sh b/abci/tests/test_cli/test.sh index 078d645af..e8c454263 100755 --- a/abci/tests/test_cli/test.sh +++ b/abci/tests/test_cli/test.sh @@ -38,8 +38,34 @@ function testExample() { rm "${INPUT}".out.new } +function testHelp() { + INPUT=$1 + APP="$2 $3" + + echo "Test: $APP" + $APP &> "${INPUT}.new" & + sleep 2 + + pre=$(shasum < "${INPUT}") + post=$(shasum < "${INPUT}.new") + + if [[ "$pre" != "$post" ]]; then + echo "You broke the tutorial" + echo "Got:" + cat "${INPUT}.new" + echo "Expected:" + cat "${INPUT}" + echo "Diff:" + diff "${INPUT}" "${INPUT}.new" + exit 1 + fi + + rm "${INPUT}".new +} + testExample 1 tests/test_cli/ex1.abci abci-cli kvstore testExample 2 tests/test_cli/ex2.abci abci-cli kvstore +testHelp tests/test_cli/testHelp.out abci-cli help echo "" echo "PASS" diff --git a/abci/tests/test_cli/testHelp.out b/abci/tests/test_cli/testHelp.out new file mode 100644 index 000000000..021549927 --- /dev/null +++ b/abci/tests/test_cli/testHelp.out @@ -0,0 +1,30 @@ +the ABCI CLI tool wraps an ABCI client and is used for testing ABCI servers + +Usage: + abci-cli [command] + +Available Commands: + batch run a batch of abci commands against an application + check_tx validate a transaction + commit commit the application state and return the Merkle root hash + completion Generate the autocompletion script for the specified shell + console start an interactive ABCI console for multiple commands + deliver_tx deliver a new transaction to the application + echo have the application echo a message + help Help about any command + info get some info about the application + kvstore ABCI demo example + prepare_proposal prepare proposal + process_proposal process proposal + query query the application state + test run integration tests + version print ABCI console version + +Flags: + --abci string either socket or grpc (default "socket") + --address string address of application socket (default "tcp://0.0.0.0:26658") + -h, --help help for abci-cli + --log_level string set the logger level (default "debug") + -v, --verbose print the command and results as if it were a console session + +Use "abci-cli [command] --help" for more information about a command.