From 0845d8126e4b53745fc3a10cfe7d5bb38c138c3b Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sun, 1 Jul 2018 15:10:45 -0400 Subject: [PATCH] server: remove broken start test --- server/start.go | 13 +++++++------ server/start_test.go | 31 +------------------------------ server/test_helpers.go | 24 ------------------------ 3 files changed, 8 insertions(+), 60 deletions(-) diff --git a/server/start.go b/server/start.go index a2cd57f929..c848c9e6ee 100644 --- a/server/start.go +++ b/server/start.go @@ -31,7 +31,8 @@ func StartCmd(ctx *Context, appCreator AppCreator) *cobra.Command { return startStandAlone(ctx, appCreator) } ctx.Logger.Info("Starting ABCI with Tendermint") - return startInProcess(ctx, appCreator) + _, err := startInProcess(ctx, appCreator) + return err }, } @@ -74,12 +75,12 @@ func startStandAlone(ctx *Context, appCreator AppCreator) error { return nil } -func startInProcess(ctx *Context, appCreator AppCreator) error { +func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) { cfg := ctx.Config home := cfg.RootDir app, err := appCreator(home, ctx.Logger) if err != nil { - return err + return nil, err } // Create & start tendermint node @@ -91,15 +92,15 @@ func startInProcess(ctx *Context, appCreator AppCreator) error { node.DefaultMetricsProvider, ctx.Logger.With("module", "node")) if err != nil { - return err + return nil, err } err = n.Start() if err != nil { - return err + return nil, err } // Trap signal, run forever. n.RunForever() - return nil + return n, nil } diff --git a/server/start_test.go b/server/start_test.go index 278c793cbd..3817e1ee89 100644 --- a/server/start_test.go +++ b/server/start_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/server/mock" @@ -45,37 +44,9 @@ func TestStartStandAlone(t *testing.T) { svr.SetLogger(logger.With("module", "abci-server")) svr.Start() - timer := time.NewTimer(time.Duration(5) * time.Second) + timer := time.NewTimer(time.Duration(2) * time.Second) select { case <-timer.C: svr.Stop() } } - -func TestStartWithTendermint(t *testing.T) { - defer setupViper(t)() - - logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)). - With("module", "mock-cmd") - cfg, err := tcmd.ParseConfig() - require.Nil(t, err) - ctx := NewContext(cfg, logger) - cdc := wire.NewCodec() - appInit := AppInit{ - AppGenState: mock.AppGenState, - AppGenTx: mock.AppGenTx, - } - initCmd := InitCmd(ctx, cdc, appInit) - err = initCmd.RunE(nil, nil) - require.NoError(t, err) - - // set up app and start up - viper.Set(flagWithTendermint, true) - startCmd := StartCmd(ctx, mock.NewApp) - svrAddr, _, err := FreeTCPAddr() - require.NoError(t, err) - startCmd.Flags().Set(flagAddress, svrAddr) // set to a new free address - timeout := time.Duration(5) * time.Second - - close(RunOrTimeout(startCmd, timeout, t)) -} diff --git a/server/test_helpers.go b/server/test_helpers.go index 5abf57c17c..8de4672e33 100644 --- a/server/test_helpers.go +++ b/server/test_helpers.go @@ -6,9 +6,7 @@ import ( "net" "os" "testing" - "time" - "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/tendermint/tmlibs/cli" @@ -52,25 +50,3 @@ func setupViper(t *testing.T) func() { } } } - -// Run or Timout RunE of command passed in -func RunOrTimeout(cmd *cobra.Command, timeout time.Duration, t *testing.T) chan error { - done := make(chan error) - go func(out chan<- error) { - // this should NOT exit - err := cmd.RunE(nil, nil) - if err != nil { - out <- err - } - out <- fmt.Errorf("start died for unknown reasons") - }(done) - timer := time.NewTimer(timeout) - - select { - case err := <-done: - require.NoError(t, err) - case <-timer.C: - return done - } - return done -}