diff --git a/config/tendermint_test/config.go b/config/tendermint_test/config.go index bb886a2b..b90fe254 100644 --- a/config/tendermint_test/config.go +++ b/config/tendermint_test/config.go @@ -12,21 +12,16 @@ import ( ) func init() { - // Creates ~/.tendermint_test/* - config := GetConfig("") - cfg.ApplyConfig(config) + // Creates ~/.tendermint_test + EnsureDir(os.Getenv("HOME")+"/.tendermint_test", 0700) } -func getTMRoot(rootDir string) string { - if rootDir == "" { - rootDir = os.Getenv("HOME") + "/.tendermint_test" - } - return rootDir +func ResetConfig(path string) { + rootDir := os.Getenv("HOME") + "/.tendermint_test/" + path + cfg.ApplyConfig(GetConfig(rootDir)) } func initTMRoot(rootDir string) { - rootDir = getTMRoot(rootDir) - // Remove ~/.tendermint_test_bak if FileExists(rootDir + "_bak") { err := os.RemoveAll(rootDir + "_bak") @@ -62,7 +57,6 @@ func initTMRoot(rootDir string) { } func GetConfig(rootDir string) cfg.Config { - rootDir = getTMRoot(rootDir) initTMRoot(rootDir) configFilePath := path.Join(rootDir, "config.toml") diff --git a/consensus/common_test.go b/consensus/common_test.go index 0629d51b..c5ae6b7b 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -11,7 +11,7 @@ import ( dbm "github.com/tendermint/go-db" "github.com/tendermint/go-events" bc "github.com/tendermint/tendermint/blockchain" - _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/config/tendermint_test" mempl "github.com/tendermint/tendermint/mempool" "github.com/tendermint/tendermint/proxy" sm "github.com/tendermint/tendermint/state" @@ -25,6 +25,7 @@ var chainID string var ensureTimeout = time.Duration(2) func init() { + tendermint_test.ResetConfig("consensus_common_test") chainID = config.GetString("chain_id") } diff --git a/consensus/height_vote_set_test.go b/consensus/height_vote_set_test.go index 19257282..ca4c6ce4 100644 --- a/consensus/height_vote_set_test.go +++ b/consensus/height_vote_set_test.go @@ -1,12 +1,16 @@ package consensus import ( - _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/config/tendermint_test" "github.com/tendermint/tendermint/types" "testing" ) +func init() { + tendermint_test.ResetConfig("consensus_height_vote_set_test") +} + func TestPeerCatchupRounds(t *testing.T) { valSet, privVals := types.RandValidatorSet(10, 1) diff --git a/consensus/replay_test.go b/consensus/replay_test.go index f18cc0cc..769bea1c 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -50,8 +50,6 @@ func TestReplayCatchup(t *testing.T) { t.Fatalf("Error on catchup replay %v", err) } - cs.enterNewRound(cs.Height, cs.Round) - after := time.After(time.Second * 2) select { case <-newBlockCh: diff --git a/consensus/state_test.go b/consensus/state_test.go index b6e55d6c..27747126 100644 --- a/consensus/state_test.go +++ b/consensus/state_test.go @@ -6,11 +6,15 @@ import ( "testing" "time" - _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/config/tendermint_test" //"github.com/tendermint/go-events" "github.com/tendermint/tendermint/types" ) +func init() { + tendermint_test.ResetConfig("consensus_state_test") +} + func (tp *TimeoutParams) ensureProposeTimeout() time.Duration { return time.Duration(tp.Propose0*2) * time.Millisecond } diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index 82738c18..3fd80bf5 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -5,13 +5,17 @@ import ( "sync" "testing" - _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/config/tendermint_test" "github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/types" "github.com/tendermint/tmsp/example/counter" tmsp "github.com/tendermint/tmsp/types" ) +func init() { + tendermint_test.ResetConfig("mempool_mempool_test") +} + func TestSerialReap(t *testing.T) { app := counter.NewCounterApplication(true) diff --git a/node/node_test.go b/node/node_test.go index 4619de5f..09801d50 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -5,10 +5,14 @@ import ( "time" "github.com/tendermint/go-p2p" - _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/config/tendermint_test" "github.com/tendermint/tendermint/types" ) +func init() { + tendermint_test.ResetConfig("node_node_test") +} + func TestNodeStartStop(t *testing.T) { // Get PrivValidator diff --git a/rpc/test/client_test.go b/rpc/test/client_test.go index 4b5b66db..ff6ea612 100644 --- a/rpc/test/client_test.go +++ b/rpc/test/client_test.go @@ -4,11 +4,16 @@ import ( "fmt" "testing" - _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/config/tendermint_test" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/types" ) +func init() { + tendermint_test.ResetConfig("rpc_test_client_test") + initGlobalVariables() +} + //-------------------------------------------------------------------------------- // Test the HTTP client //-------------------------------------------------------------------------------- diff --git a/rpc/test/helpers.go b/rpc/test/helpers.go index 628e485a..421fdbb8 100644 --- a/rpc/test/helpers.go +++ b/rpc/test/helpers.go @@ -9,7 +9,6 @@ import ( "github.com/tendermint/go-wire" client "github.com/tendermint/go-rpc/client" - _ "github.com/tendermint/tendermint/config/tendermint_test" nm "github.com/tendermint/tendermint/node" ctypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/tendermint/tendermint/types" @@ -17,20 +16,19 @@ import ( // global variables for use across all tests var ( - node *nm.Node - - mempoolCount = 0 - - chainID string - - rpcAddr, requestAddr, websocketAddr, websocketEndpoint string - - clientURI *client.ClientURI - clientJSON *client.ClientJSONRPC + node *nm.Node + mempoolCount = 0 + chainID string + rpcAddr string + requestAddr string + websocketAddr string + websocketEndpoint string + clientURI *client.ClientURI + clientJSON *client.ClientJSONRPC ) // initialize config and create new node -func init() { +func initGlobalVariables() { chainID = config.GetString("chain_id") rpcAddr = config.GetString("rpc_laddr") requestAddr = rpcAddr diff --git a/types/proposal_test.go b/types/proposal_test.go index 725d5584..15bf372a 100644 --- a/types/proposal_test.go +++ b/types/proposal_test.go @@ -4,9 +4,13 @@ import ( "testing" . "github.com/tendermint/go-common" - _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/config/tendermint_test" ) +func init() { + tendermint_test.ResetConfig("types_proposal_test") +} + func TestProposalSignable(t *testing.T) { proposal := &Proposal{ Height: 12345, diff --git a/types/vote_set_test.go b/types/vote_set_test.go index e4da1416..828ca98a 100644 --- a/types/vote_set_test.go +++ b/types/vote_set_test.go @@ -6,11 +6,15 @@ import ( . "github.com/tendermint/go-common" . "github.com/tendermint/go-common/test" "github.com/tendermint/go-crypto" - _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/config/tendermint_test" "testing" ) +func init() { + tendermint_test.ResetConfig("types_vote_set_test") +} + // Move it out? func randVoteSet(height int, round int, type_ byte, numValidators int, votingPower int64) (*VoteSet, *ValidatorSet, []*PrivValidator) { valSet, privValidators := RandValidatorSet(numValidators, votingPower)