Move lcd tests into gaia (#4245)
Objective is to remove lcd -> gaia package dep. Code cleanup.
This commit is contained in:
parent
466e46ba0a
commit
4d6480aa46
|
@ -1,12 +0,0 @@
|
||||||
package lcd
|
|
||||||
|
|
||||||
import (
|
|
||||||
amino "github.com/tendermint/go-amino"
|
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
var cdc = amino.NewCodec()
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
ctypes.RegisterAmino(cdc)
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package lcd
|
package lcd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -106,16 +105,3 @@ func (rs *RestServer) registerSwaggerUI() {
|
||||||
staticServer := http.FileServer(statikFS)
|
staticServer := http.FileServer(statikFS)
|
||||||
rs.Mux.PathPrefix("/swagger-ui/").Handler(http.StripPrefix("/swagger-ui/", staticServer))
|
rs.Mux.PathPrefix("/swagger-ui/").Handler(http.StripPrefix("/swagger-ui/", staticServer))
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateCertKeyFiles(certFile, keyFile string) error {
|
|
||||||
if keyFile == "" {
|
|
||||||
return errors.New("a key file is required")
|
|
||||||
}
|
|
||||||
if _, err := os.Stat(certFile); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if _, err := os.Stat(keyFile); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package lcd
|
package lcd_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -16,9 +16,11 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/tendermint/go-amino"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/lcd"
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||||
"github.com/cosmos/cosmos-sdk/x/params"
|
"github.com/cosmos/cosmos-sdk/x/params"
|
||||||
|
@ -67,6 +69,12 @@ import (
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var cdc = amino.NewCodec()
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
ctypes.RegisterAmino(cdc)
|
||||||
|
}
|
||||||
|
|
||||||
// makePathname creates a unique pathname for each test. It will panic if it
|
// makePathname creates a unique pathname for each test. It will panic if it
|
||||||
// cannot get the current working directory.
|
// cannot get the current working directory.
|
||||||
func makePathname() string {
|
func makePathname() string {
|
||||||
|
@ -394,7 +402,7 @@ func startTM(
|
||||||
|
|
||||||
// startLCD starts the LCD.
|
// startLCD starts the LCD.
|
||||||
func startLCD(logger log.Logger, listenAddr string, cdc *codec.Codec, t *testing.T) (net.Listener, error) {
|
func startLCD(logger log.Logger, listenAddr string, cdc *codec.Codec, t *testing.T) (net.Listener, error) {
|
||||||
rs := NewRestServer(cdc)
|
rs := lcd.NewRestServer(cdc)
|
||||||
registerRoutes(rs)
|
registerRoutes(rs)
|
||||||
listener, err := tmrpc.Listen(listenAddr, tmrpc.DefaultConfig())
|
listener, err := tmrpc.Listen(listenAddr, tmrpc.DefaultConfig())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -405,7 +413,7 @@ func startLCD(logger log.Logger, listenAddr string, cdc *codec.Codec, t *testing
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: If making updates here also update cmd/gaia/cmd/gaiacli/main.go
|
// NOTE: If making updates here also update cmd/gaia/cmd/gaiacli/main.go
|
||||||
func registerRoutes(rs *RestServer) {
|
func registerRoutes(rs *lcd.RestServer) {
|
||||||
rpc.RegisterRoutes(rs.CliCtx, rs.Mux)
|
rpc.RegisterRoutes(rs.CliCtx, rs.Mux)
|
||||||
tx.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc)
|
tx.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc)
|
||||||
authrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, auth.StoreKey)
|
authrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, auth.StoreKey)
|
|
@ -1,4 +1,4 @@
|
||||||
package lcd
|
package lcd_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
@ -36,11 +36,8 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
name1 = "test1"
|
name1 = "test1"
|
||||||
name2 = "test2"
|
|
||||||
name3 = "test3"
|
|
||||||
memo = "LCD test tx"
|
memo = "LCD test tx"
|
||||||
pw = client.DefaultKeyPass
|
pw = client.DefaultKeyPass
|
||||||
altPw = "12345678901"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var fees = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)}
|
var fees = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)}
|
Loading…
Reference in New Issue