You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.1 KiB

package coregrpc_test
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/abci/example/kvstore"
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/service"
core_grpc "github.com/tendermint/tendermint/rpc/grpc"
rpctest "github.com/tendermint/tendermint/rpc/test"
)
func NodeSuite(t *testing.T) (service.Service, *config.Config) {
t.Helper()
ctx, cancel := context.WithCancel(context.Background())
conf := rpctest.CreateConfig(t.Name())
// start a tendermint node in the background to test against
app := kvstore.NewApplication()
node, closer, err := rpctest.StartTendermint(ctx, conf, app)
require.NoError(t, err)
t.Cleanup(func() {
_ = closer(ctx)
cancel()
})
return node, conf
}
func TestBroadcastTx(t *testing.T) {
_, conf := NodeSuite(t)
res, err := rpctest.GetGRPCClient(conf).BroadcastTx(
context.Background(),
&core_grpc.RequestBroadcastTx{Tx: []byte("this is a tx")},
)
require.NoError(t, err)
require.EqualValues(t, 0, res.CheckTx.Code)
require.EqualValues(t, 0, res.DeliverTx.Code)
}