mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 17:51:39 +00:00
Moved httpclient into subpackage
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
package client_test
|
package httpclient_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
@ -1,4 +1,4 @@
|
|||||||
package client
|
package httpclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
@ -1,4 +1,4 @@
|
|||||||
package client_test
|
package httpclient_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
@ -1,4 +1,4 @@
|
|||||||
package client_test
|
package httpclient_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
@ -8,13 +8,20 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
merkle "github.com/tendermint/go-merkle"
|
merkle "github.com/tendermint/go-merkle"
|
||||||
|
httpclient "github.com/tendermint/tendermint/rpc/client/http"
|
||||||
rpctest "github.com/tendermint/tendermint/rpc/test"
|
rpctest "github.com/tendermint/tendermint/rpc/test"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetClient gets a rpc client pointing to the test tendermint rpc
|
||||||
|
func GetClient() *httpclient.HTTPClient {
|
||||||
|
rpcAddr := rpctest.GetConfig().GetString("rpc_laddr")
|
||||||
|
return httpclient.New(rpcAddr, "/websocket")
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure status is correct (we connect properly)
|
// Make sure status is correct (we connect properly)
|
||||||
func TestStatus(t *testing.T) {
|
func TestStatus(t *testing.T) {
|
||||||
c := rpctest.GetClient()
|
c := GetClient()
|
||||||
chainID := rpctest.GetConfig().GetString("chain_id")
|
chainID := rpctest.GetConfig().GetString("chain_id")
|
||||||
status, err := c.Status()
|
status, err := c.Status()
|
||||||
require.Nil(t, err, "%+v", err)
|
require.Nil(t, err, "%+v", err)
|
||||||
@ -23,7 +30,7 @@ func TestStatus(t *testing.T) {
|
|||||||
|
|
||||||
// Make sure info is correct (we connect properly)
|
// Make sure info is correct (we connect properly)
|
||||||
func TestInfo(t *testing.T) {
|
func TestInfo(t *testing.T) {
|
||||||
c := rpctest.GetClient()
|
c := GetClient()
|
||||||
status, err := c.Status()
|
status, err := c.Status()
|
||||||
require.Nil(t, err, "%+v", err)
|
require.Nil(t, err, "%+v", err)
|
||||||
info, err := c.ABCIInfo()
|
info, err := c.ABCIInfo()
|
||||||
@ -33,7 +40,7 @@ func TestInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNetInfo(t *testing.T) {
|
func TestNetInfo(t *testing.T) {
|
||||||
c := rpctest.GetClient()
|
c := GetClient()
|
||||||
netinfo, err := c.NetInfo()
|
netinfo, err := c.NetInfo()
|
||||||
require.Nil(t, err, "%+v", err)
|
require.Nil(t, err, "%+v", err)
|
||||||
assert.True(t, netinfo.Listening)
|
assert.True(t, netinfo.Listening)
|
||||||
@ -41,14 +48,14 @@ func TestNetInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDialSeeds(t *testing.T) {
|
func TestDialSeeds(t *testing.T) {
|
||||||
c := rpctest.GetClient()
|
c := GetClient()
|
||||||
// FIXME: fix server so it doesn't panic on invalid input
|
// FIXME: fix server so it doesn't panic on invalid input
|
||||||
_, err := c.DialSeeds([]string{"12.34.56.78:12345"})
|
_, err := c.DialSeeds([]string{"12.34.56.78:12345"})
|
||||||
require.Nil(t, err, "%+v", err)
|
require.Nil(t, err, "%+v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenesisAndValidators(t *testing.T) {
|
func TestGenesisAndValidators(t *testing.T) {
|
||||||
c := rpctest.GetClient()
|
c := GetClient()
|
||||||
chainID := rpctest.GetConfig().GetString("chain_id")
|
chainID := rpctest.GetConfig().GetString("chain_id")
|
||||||
|
|
||||||
// make sure this is the right genesis file
|
// make sure this is the right genesis file
|
||||||
@ -73,7 +80,7 @@ func TestGenesisAndValidators(t *testing.T) {
|
|||||||
// Make some app checks
|
// Make some app checks
|
||||||
func TestAppCalls(t *testing.T) {
|
func TestAppCalls(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
assert, require := assert.New(t), require.New(t)
|
||||||
c := rpctest.GetClient()
|
c := GetClient()
|
||||||
_, err := c.Block(1)
|
_, err := c.Block(1)
|
||||||
assert.NotNil(err) // no block yet
|
assert.NotNil(err) // no block yet
|
||||||
k, v, tx := MakeTxKV()
|
k, v, tx := MakeTxKV()
|
||||||
@ -136,7 +143,7 @@ func TestAppCalls(t *testing.T) {
|
|||||||
|
|
||||||
func TestSubscriptions(t *testing.T) {
|
func TestSubscriptions(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
assert, require := assert.New(t), require.New(t)
|
||||||
c := rpctest.GetClient()
|
c := GetClient()
|
||||||
err := c.StartWebsocket()
|
err := c.StartWebsocket()
|
||||||
require.Nil(err)
|
require.Nil(err)
|
||||||
defer c.StopWebsocket()
|
defer c.StopWebsocket()
|
@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/tendermint/tendermint/config/tendermint_test"
|
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||||
nm "github.com/tendermint/tendermint/node"
|
nm "github.com/tendermint/tendermint/node"
|
||||||
"github.com/tendermint/tendermint/proxy"
|
"github.com/tendermint/tendermint/proxy"
|
||||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
core_grpc "github.com/tendermint/tendermint/rpc/grpc"
|
core_grpc "github.com/tendermint/tendermint/rpc/grpc"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
@ -38,12 +37,6 @@ func GetConfig() cfg.Config {
|
|||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetClient gets a rpc client pointing to the test tendermint rpc
|
|
||||||
func GetClient() *rpcclient.HTTPClient {
|
|
||||||
rpcAddr := GetConfig().GetString("rpc_laddr")
|
|
||||||
return rpcclient.New(rpcAddr, "/websocket")
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetURIClient gets a uri client pointing to the test tendermint rpc
|
// GetURIClient gets a uri client pointing to the test tendermint rpc
|
||||||
func GetURIClient() *client.ClientURI {
|
func GetURIClient() *client.ClientURI {
|
||||||
rpcAddr := GetConfig().GetString("rpc_laddr")
|
rpcAddr := GetConfig().GetString("rpc_laddr")
|
||||||
|
Reference in New Issue
Block a user