Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-kosu: make faster integration tests #175

Merged
merged 2 commits into from Jul 23, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

go-kosu: make faster integration tests

  • Loading branch information
gchaincl committed Jul 23, 2019
commit c1164a4d1d8bfa12adf06b8c4ea5b1811a8b3474
@@ -18,6 +18,9 @@ import (

var chainIDPrefix = "kosu-chain-%v"

// DefaultConfig returns the default Tendermint config for a Kosu node
var DefaultConfig = cfg.DefaultConfig()

// InitTendermint creates an initial tendermint file structure.
func InitTendermint(homedir string) error {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "main")
@@ -35,7 +38,7 @@ func InitTendermintWithLogger(homedir string, logger log.Logger) error {

// Code from tendermint init...
func createConfig(homedir string, logger log.Logger) error {
config := cfg.DefaultConfig()
config := DefaultConfig
if homedir == "" {
config.SetRoot(DefaultHomeDir)
} else {
@@ -4,6 +4,7 @@ import (
"io/ioutil"
"os"
"testing"
"time"

. "github.com/smartystreets/goconvey/convey" //nolint
"github.com/stretchr/testify/require"
@@ -18,7 +19,7 @@ import (
// GivenABCIServer a ABCI Server inside a Convey block
func GivenABCIServer(t *testing.T, suite *Suite, fn func(*testing.T)) {
Convey("Given an ABCI Server", t, func() {
app, closer := startServer(t, db.NewMemDB())
app, closer := StartServer(t, db.NewMemDB())
defer closer()
suite.app = app

@@ -30,11 +31,14 @@ func GivenABCIServer(t *testing.T, suite *Suite, fn func(*testing.T)) {
})
}

func startServer(t *testing.T, db db.DB) (*abci.App, func()) {
// StartServer starts a kosud test server
func StartServer(t *testing.T, db db.DB) (*abci.App, func()) {
// Create a temp dir and initialize tendermint there
dir, err := ioutil.TempDir("/tmp", "/go-kosu-go-tests_")
require.NoError(t, err)

// Update block generation time to 100ms to make tests run fast
abci.DefaultConfig.Consensus.TimeoutCommit = time.Duration(100 * time.Millisecond)
err = abci.InitTendermintWithLogger(dir, log.NewNopLogger())
require.NoError(t, err)

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.