server: remove broken start test

This commit is contained in:
Ethan Buchman 2018-07-01 15:10:45 -04:00
parent dbabc2e79f
commit 0845d8126e
3 changed files with 8 additions and 60 deletions

View File

@ -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
}

View File

@ -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))
}

View File

@ -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
}