From 2324f5d76654a75cc1114b2bdf5bc0424e5ee333 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 12 May 2017 20:54:50 +0200 Subject: [PATCH] Fix all tests with new tendermint style --- cmd/basecli/main.go | 9 +++------ cmd/counter/main.go | 6 +++++- docs/guide/src/example-plugin/cmd.go | 2 -- docs/guide/src/example-plugin/main.go | 7 +++++-- tests/tendermint/main.go | 21 +++++++++++++-------- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/cmd/basecli/main.go b/cmd/basecli/main.go index 2ecb8c75e..22fb4d212 100644 --- a/cmd/basecli/main.go +++ b/cmd/basecli/main.go @@ -9,6 +9,7 @@ import ( "github.com/tendermint/light-client/commands/proofs" "github.com/tendermint/light-client/commands/seeds" "github.com/tendermint/light-client/commands/txs" + "github.com/tendermint/tmlibs/cli" ) // BaseCli represents the base command when called without any subcommands @@ -38,10 +39,6 @@ func init() { } func main() { - keycmd.PrepareMainCmd(BaseCli, "BC", os.ExpandEnv("$HOME/.basecli")) - BaseCli.Execute() - // err := BaseCli.Execute() - // if err != nil { - // fmt.Printf("%+v\n", err) - // } + cmd := cli.PrepareMainCmd(BaseCli, "BC", os.ExpandEnv("$HOME/.basecli")) + cmd.Execute() } diff --git a/cmd/counter/main.go b/cmd/counter/main.go index 8a96b50ed..2f6c5ca40 100644 --- a/cmd/counter/main.go +++ b/cmd/counter/main.go @@ -1,9 +1,12 @@ package main import ( + "os" + "github.com/spf13/cobra" "github.com/tendermint/basecoin/cmd/commands" + "github.com/tendermint/tmlibs/cli" ) func main() { @@ -24,5 +27,6 @@ func main() { commands.QuickVersionCmd("0.1.0"), ) - commands.ExecuteWithDebug(RootCmd) + cmd := cli.PrepareMainCmd(RootCmd, "BC", os.ExpandEnv("$HOME/.basecoin")) + cmd.Execute() } diff --git a/docs/guide/src/example-plugin/cmd.go b/docs/guide/src/example-plugin/cmd.go index 11a6f6bc0..b43917626 100644 --- a/docs/guide/src/example-plugin/cmd.go +++ b/docs/guide/src/example-plugin/cmd.go @@ -24,8 +24,6 @@ var ( //Called during CLI initialization func init() { - commands.DefaultHome = ".basecoin-example-plugin" - //Set the Plugin Flags ExamplePluginTxCmd.Flags().BoolVar(&validFlag, "valid", false, "Set this to make transaction valid") diff --git a/docs/guide/src/example-plugin/main.go b/docs/guide/src/example-plugin/main.go index e2892bd7d..328e22025 100644 --- a/docs/guide/src/example-plugin/main.go +++ b/docs/guide/src/example-plugin/main.go @@ -1,9 +1,12 @@ package main import ( + "os" + "github.com/spf13/cobra" "github.com/tendermint/basecoin/cmd/commands" + "github.com/tendermint/tmlibs/cli" ) func main() { @@ -27,6 +30,6 @@ func main() { commands.UnsafeResetAllCmd, ) - //Run the root command - commands.ExecuteWithDebug(RootCmd) + cmd := cli.PrepareMainCmd(RootCmd, "BC", os.ExpandEnv("$HOME/.basecoin-example-plugin")) + cmd.Execute() } diff --git a/tests/tendermint/main.go b/tests/tendermint/main.go index 1213cc4c5..04a39f9f6 100644 --- a/tests/tendermint/main.go +++ b/tests/tendermint/main.go @@ -6,11 +6,11 @@ import ( "github.com/gorilla/websocket" "github.com/tendermint/basecoin/types" - cmn "github.com/tendermint/tmlibs/common" - "github.com/tendermint/tendermint/rpc/lib/client" - "github.com/tendermint/tendermint/rpc/lib/types" wire "github.com/tendermint/go-wire" _ "github.com/tendermint/tendermint/rpc/core/types" // Register RPCResponse > Result types + "github.com/tendermint/tendermint/rpc/lib/client" + "github.com/tendermint/tendermint/rpc/lib/types" + cmn "github.com/tendermint/tmlibs/common" ) func main() { @@ -71,11 +71,13 @@ func main() { // Write request txBytes := wire.BinaryBytes(struct{ types.Tx }{tx}) - request := rpctypes.NewRPCRequest("fakeid", "broadcast_tx_sync", map[string]interface{}{"tx": txBytes}) - //request := rpctypes.NewRPCRequest("fakeid", "broadcast_tx_sync", map[string]interface{}{"tx": txBytes}) + request, err := rpctypes.MapToRequest("fakeid", "broadcast_tx_sync", map[string]interface{}{"tx": txBytes}) + if err != nil { + cmn.Exit("cannot encode request: " + err.Error()) + } reqBytes := wire.JSONBytes(request) //fmt.Print(".") - err := ws.WriteMessage(websocket.TextMessage, reqBytes) + err = ws.WriteMessage(websocket.TextMessage, reqBytes) if err != nil { cmn.Exit("writing websocket request: " + err.Error()) } @@ -122,10 +124,13 @@ func main() { // Write request txBytes := wire.BinaryBytes(struct{ types.Tx }{tx}) - request := rpctypes.NewRPCRequest("fakeid", "broadcast_tx_sync", map[string]interface{}{"tx": txBytes}) + request, err := rpctypes.MapToRequest("fakeid", "broadcast_tx_sync", map[string]interface{}{"tx": txBytes}) + if err != nil { + cmn.Exit("cannot encode request: " + err.Error()) + } reqBytes := wire.JSONBytes(request) //fmt.Print(".") - err := ws.WriteMessage(websocket.TextMessage, reqBytes) + err = ws.WriteMessage(websocket.TextMessage, reqBytes) if err != nil { cmn.Exit("writing websocket request: " + err.Error()) }