2017-07-13 13:40:19 -04:00
|
|
|
package core_grpc_test
|
|
|
|
|
|
|
|
import (
|
2017-11-14 22:30:00 +00:00
|
|
|
"context"
|
2017-07-13 13:40:19 -04:00
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2018-06-22 06:59:02 +02:00
|
|
|
"github.com/tendermint/tendermint/abci/example/kvstore"
|
2019-01-28 14:13:17 +02:00
|
|
|
core_grpc "github.com/tendermint/tendermint/rpc/grpc"
|
|
|
|
rpctest "github.com/tendermint/tendermint/rpc/test"
|
2017-07-13 13:40:19 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
2017-09-05 17:10:11 -04:00
|
|
|
// start a tendermint node in the background to test against
|
2018-02-27 14:01:10 +00:00
|
|
|
app := kvstore.NewKVStoreApplication()
|
2019-02-18 08:45:27 +01:00
|
|
|
node, cleanup := rpctest.StartTendermint(app)
|
2017-07-13 13:40:19 -04:00
|
|
|
code := m.Run()
|
|
|
|
|
|
|
|
// and shut down proper at the end
|
|
|
|
node.Stop()
|
|
|
|
node.Wait()
|
2019-02-18 08:45:27 +01:00
|
|
|
cleanup()
|
2017-07-13 13:40:19 -04:00
|
|
|
os.Exit(code)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBroadcastTx(t *testing.T) {
|
|
|
|
require := require.New(t)
|
2018-08-10 09:14:17 +04:00
|
|
|
res, err := rpctest.GetGRPCClient().BroadcastTx(context.Background(), &core_grpc.RequestBroadcastTx{Tx: []byte("this is a tx")})
|
2017-07-13 13:40:19 -04:00
|
|
|
require.Nil(err, "%+v", err)
|
|
|
|
require.EqualValues(0, res.CheckTx.Code)
|
|
|
|
require.EqualValues(0, res.DeliverTx.Code)
|
|
|
|
}
|