mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-13 03:25:20 +00:00
63 lines
1.7 KiB
Go
63 lines
1.7 KiB
Go
package query_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/0glabs/0g-chain/client/grpc/query"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewQueryClient_InvalidGprc(t *testing.T) {
|
|
t.Run("valid connection", func(t *testing.T) {
|
|
conn, err := query.NewQueryClient("http://localhost:1234")
|
|
require.NoError(t, err)
|
|
require.NotNil(t, conn)
|
|
})
|
|
|
|
t.Run("non-empty url", func(t *testing.T) {
|
|
_, err := query.NewQueryClient("")
|
|
require.ErrorContains(t, err, "unknown grpc url scheme")
|
|
})
|
|
|
|
t.Run("invalid url scheme", func(t *testing.T) {
|
|
_, err := query.NewQueryClient("ftp://localhost:1234")
|
|
require.ErrorContains(t, err, "unknown grpc url scheme")
|
|
})
|
|
}
|
|
|
|
func TestNewQueryClient_ValidClient(t *testing.T) {
|
|
t.Run("all clients are created", func(t *testing.T) {
|
|
client, err := query.NewQueryClient("http://localhost:1234")
|
|
require.NoError(t, err)
|
|
require.NotNil(t, client)
|
|
|
|
// validate cosmos clients
|
|
require.NotNil(t, client.Tm)
|
|
require.NotNil(t, client.Tx)
|
|
require.NotNil(t, client.Auth)
|
|
require.NotNil(t, client.Authz)
|
|
require.NotNil(t, client.Bank)
|
|
require.NotNil(t, client.Distribution)
|
|
require.NotNil(t, client.Evidence)
|
|
require.NotNil(t, client.Gov)
|
|
require.NotNil(t, client.GovBeta)
|
|
require.NotNil(t, client.Mint)
|
|
require.NotNil(t, client.Params)
|
|
require.NotNil(t, client.Slashing)
|
|
require.NotNil(t, client.Staking)
|
|
require.NotNil(t, client.Upgrade)
|
|
require.NotNil(t, client.Consensus)
|
|
|
|
// validate 3rd party clients
|
|
require.NotNil(t, client.Evm)
|
|
require.NotNil(t, client.Feemarket)
|
|
require.NotNil(t, client.IbcClient)
|
|
require.NotNil(t, client.IbcTransfer)
|
|
|
|
// validate 0gChain clients
|
|
require.NotNil(t, client.Evmutil)
|
|
require.NotNil(t, client.Council)
|
|
require.NotNil(t, client.Das)
|
|
})
|
|
}
|