mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
Fix tests; Tests run in their own directory
This commit is contained in:
parent
fd85d0ef35
commit
03115cbf93
@ -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")
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
//--------------------------------------------------------------------------------
|
||||
|
@ -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"
|
||||
@ -18,19 +17,18 @@ import (
|
||||
// global variables for use across all tests
|
||||
var (
|
||||
node *nm.Node
|
||||
|
||||
mempoolCount = 0
|
||||
|
||||
chainID string
|
||||
|
||||
rpcAddr, requestAddr, websocketAddr, websocketEndpoint 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
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user