From 4d6480aa46979088ef43f3988ab142763a3ce9c5 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Wed, 1 May 2019 17:58:20 +0100 Subject: [PATCH] Move lcd tests into gaia (#4245) Objective is to remove lcd -> gaia package dep. Code cleanup. --- client/lcd/codec.go | 12 ------------ client/lcd/root.go | 14 -------------- .../gaia/lcd_test/helpers_test.go | 14 +++++++++++--- {client/lcd => cmd/gaia/lcd_test}/lcd_test.go | 5 +---- 4 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 client/lcd/codec.go rename client/lcd/test_helpers.go => cmd/gaia/lcd_test/helpers_test.go (99%) rename {client/lcd => cmd/gaia/lcd_test}/lcd_test.go (99%) diff --git a/client/lcd/codec.go b/client/lcd/codec.go deleted file mode 100644 index f146e102ed00..000000000000 --- a/client/lcd/codec.go +++ /dev/null @@ -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) -} diff --git a/client/lcd/root.go b/client/lcd/root.go index 3a5144a2a3db..9325080e7002 100644 --- a/client/lcd/root.go +++ b/client/lcd/root.go @@ -1,7 +1,6 @@ package lcd import ( - "errors" "fmt" "net" "net/http" @@ -106,16 +105,3 @@ func (rs *RestServer) registerSwaggerUI() { staticServer := http.FileServer(statikFS) 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 -} diff --git a/client/lcd/test_helpers.go b/cmd/gaia/lcd_test/helpers_test.go similarity index 99% rename from client/lcd/test_helpers.go rename to cmd/gaia/lcd_test/helpers_test.go index 5d2e5931246a..132ec1b5d7e9 100644 --- a/client/lcd/test_helpers.go +++ b/cmd/gaia/lcd_test/helpers_test.go @@ -1,4 +1,4 @@ -package lcd +package lcd_test import ( "bytes" @@ -16,9 +16,11 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" + "github.com/tendermint/go-amino" "github.com/cosmos/cosmos-sdk/client" 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/crypto/keys" "github.com/cosmos/cosmos-sdk/x/params" @@ -67,6 +69,12 @@ import ( 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 // cannot get the current working directory. func makePathname() string { @@ -394,7 +402,7 @@ func startTM( // startLCD starts the LCD. 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) listener, err := tmrpc.Listen(listenAddr, tmrpc.DefaultConfig()) 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 -func registerRoutes(rs *RestServer) { +func registerRoutes(rs *lcd.RestServer) { rpc.RegisterRoutes(rs.CliCtx, rs.Mux) tx.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc) authrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, auth.StoreKey) diff --git a/client/lcd/lcd_test.go b/cmd/gaia/lcd_test/lcd_test.go similarity index 99% rename from client/lcd/lcd_test.go rename to cmd/gaia/lcd_test/lcd_test.go index ac86586f9589..7c7da1e74957 100644 --- a/client/lcd/lcd_test.go +++ b/cmd/gaia/lcd_test/lcd_test.go @@ -1,4 +1,4 @@ -package lcd +package lcd_test import ( "encoding/base64" @@ -36,11 +36,8 @@ import ( const ( name1 = "test1" - name2 = "test2" - name3 = "test3" memo = "LCD test tx" pw = client.DefaultKeyPass - altPw = "12345678901" ) var fees = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)}