github.com/okex/exchain@v1.8.0/libs/tendermint/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/okex/exchain/libs/tendermint/abci/example/kvstore" 11 cfg "github.com/okex/exchain/libs/tendermint/config" 12 core_grpc "github.com/okex/exchain/libs/tendermint/rpc/grpc" 13 rpctest "github.com/okex/exchain/libs/tendermint/rpc/test" 14 ) 15 16 func TestMain(m *testing.M) { 17 // start a tendermint node in the background to test against 18 app := kvstore.NewApplication() 19 node := rpctest.StartTendermint(app) 20 21 code := m.Run() 22 23 // and shut down proper at the end 24 rpctest.StopTendermint(node) 25 os.Exit(code) 26 } 27 28 func TestBroadcastTx(t *testing.T) { 29 setMocConfig(100) 30 res, err := rpctest.GetGRPCClient().BroadcastTx( 31 context.Background(), 32 &core_grpc.RequestBroadcastTx{Tx: []byte("this is a tx")}, 33 ) 34 require.NoError(t, err) 35 require.EqualValues(t, 0, res.CheckTx.Code) 36 require.EqualValues(t, 0, res.DeliverTx.Code) 37 } 38 39 func setMocConfig(clientNum int) { 40 moc := cfg.MockDynamicConfig{} 41 moc.SetMaxSubscriptionClients(100) 42 43 cfg.SetDynamicConfig(moc) 44 }