tendermint/test/app/grpc_client.go
Anton Kaliaev fc7c298cc0
Remove gogoproto from Makefile's TOOLS (#2198)
* remove gogoproto from tools

because it's not a binary

* update protobuf version to 3.6.1 in `make get_protoc`

* update libs/common/types.pb.go and rpc/grpc/types.pb.go

* fix app tests
2018-08-10 09:14:17 +04:00

43 lines
779 B
Go

package main
import (
"encoding/hex"
"fmt"
"os"
"context"
amino "github.com/tendermint/go-amino"
core_grpc "github.com/tendermint/tendermint/rpc/grpc"
)
var grpcAddr = "tcp://localhost:36656"
func main() {
args := os.Args
if len(args) == 1 {
fmt.Println("Must enter a transaction to send (hex)")
os.Exit(1)
}
tx := args[1]
txBytes, err := hex.DecodeString(tx)
if err != nil {
fmt.Println("Invalid hex", err)
os.Exit(1)
}
clientGRPC := core_grpc.StartGRPCClient(grpcAddr)
res, err := clientGRPC.BroadcastTx(context.Background(), &core_grpc.RequestBroadcastTx{Tx: txBytes})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
bz, err := amino.NewCodec().MarshalJSON(res)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(string(bz))
}