mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
rpc: move grpc_test from test/ to grpc/
This commit is contained in:
parent
525fc0ae5b
commit
d8ca0580a8
33
rpc/grpc/grpc_test.go
Normal file
33
rpc/grpc/grpc_test.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package core_grpc_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
|
||||||
|
"github.com/tendermint/abci/example/dummy"
|
||||||
|
"github.com/tendermint/tendermint/rpc/grpc"
|
||||||
|
"github.com/tendermint/tendermint/rpc/test"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
// start a tendermint node (and merkleeyes) in the background to test against
|
||||||
|
app := dummy.NewDummyApplication()
|
||||||
|
node := rpctest.StartTendermint(app)
|
||||||
|
code := m.Run()
|
||||||
|
|
||||||
|
// and shut down proper at the end
|
||||||
|
node.Stop()
|
||||||
|
node.Wait()
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBroadcastTx(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
res, err := rpctest.GetGRPCClient().BroadcastTx(context.Background(), &core_grpc.RequestBroadcastTx{[]byte("this is a tx")})
|
||||||
|
require.Nil(err, "%+v", err)
|
||||||
|
require.EqualValues(0, res.CheckTx.Code)
|
||||||
|
require.EqualValues(0, res.DeliverTx.Code)
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
package rpctest
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
core_grpc "github.com/tendermint/tendermint/rpc/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestBroadcastTx(t *testing.T) {
|
|
||||||
require := require.New(t)
|
|
||||||
res, err := GetGRPCClient().BroadcastTx(context.Background(), &core_grpc.RequestBroadcastTx{[]byte("this is a tx")})
|
|
||||||
require.Nil(err, "%+v", err)
|
|
||||||
require.EqualValues(0, res.CheckTx.Code)
|
|
||||||
require.EqualValues(0, res.DeliverTx.Code)
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
package tests contain integration tests and helper functions for testing
|
|
||||||
the RPC interface
|
|
||||||
|
|
||||||
In particular, it allows us to spin up a tendermint node in process, with
|
|
||||||
a live RPC server, which we can use to verify our rpc calls. It provides
|
|
||||||
all data structures, enabling us to do more complex tests (like node_test.go)
|
|
||||||
that introspect the blocks themselves to validate signatures and the like.
|
|
||||||
|
|
||||||
It currently only spins up one node, it would be interesting to expand it
|
|
||||||
to multiple nodes to see the real effects of validating partially signed
|
|
||||||
blocks.
|
|
||||||
*/
|
|
||||||
package rpctest
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/tendermint/abci/example/dummy"
|
|
||||||
nm "github.com/tendermint/tendermint/node"
|
|
||||||
)
|
|
||||||
|
|
||||||
var node *nm.Node
|
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
|
||||||
// start a tendermint node (and merkleeyes) in the background to test against
|
|
||||||
app := dummy.NewDummyApplication()
|
|
||||||
node = StartTendermint(app)
|
|
||||||
code := m.Run()
|
|
||||||
|
|
||||||
// and shut down proper at the end
|
|
||||||
node.Stop()
|
|
||||||
node.Wait()
|
|
||||||
os.Exit(code)
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user