github.com/adoriasoft/tendermint@v0.34.0-dev1.0.20200722151356-96d84601a75a/rpc/grpc/grpc_test.go (about) 1 package coregrpc_test 2 3 import ( 4 "context" 5 "os" 6 "testing" 7 8 "github.com/stretchr/testify/require" 9 10 "github.com/tendermint/tendermint/abci/example/kvstore" 11 core_grpc "github.com/tendermint/tendermint/rpc/grpc" 12 rpctest "github.com/tendermint/tendermint/rpc/test" 13 ) 14 15 func TestMain(m *testing.M) { 16 // start a tendermint node in the background to test against 17 app := kvstore.NewApplication() 18 node := rpctest.StartTendermint(app) 19 20 code := m.Run() 21 22 // and shut down proper at the end 23 rpctest.StopTendermint(node) 24 os.Exit(code) 25 } 26 27 func TestBroadcastTx(t *testing.T) { 28 res, err := rpctest.GetGRPCClient().BroadcastTx( 29 context.Background(), 30 &core_grpc.RequestBroadcastTx{Tx: []byte("this is a tx")}, 31 ) 32 require.NoError(t, err) 33 require.EqualValues(t, 0, res.CheckTx.Code) 34 require.EqualValues(t, 0, res.DeliverTx.Code) 35 }