Skip to content

Commit

Permalink
Move lcd tests into gaia (#4245)
Browse files Browse the repository at this point in the history
Objective is to remove lcd -> gaia package dep.

Code cleanup.
  • Loading branch information
Alessio Treglia authored May 1, 2019
1 parent 466e46b commit 4d6480a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 33 deletions.
12 changes: 0 additions & 12 deletions client/lcd/codec.go

This file was deleted.

14 changes: 0 additions & 14 deletions client/lcd/root.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package lcd

import (
"errors"
"fmt"
"net"
"net/http"
Expand Down Expand Up @@ -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
}
14 changes: 11 additions & 3 deletions client/lcd/test_helpers.go → cmd/gaia/lcd_test/helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lcd
package lcd_test

import (
"bytes"
Expand All @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions client/lcd/lcd_test.go → cmd/gaia/lcd_test/lcd_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lcd
package lcd_test

import (
"encoding/base64"
Expand Down Expand Up @@ -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)}
Expand Down

0 comments on commit 4d6480a

Please sign in to comment.