mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-26 15:22:15 +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() {
|
func init() {
|
||||||
// Creates ~/.tendermint_test/*
|
// Creates ~/.tendermint_test
|
||||||
config := GetConfig("")
|
EnsureDir(os.Getenv("HOME")+"/.tendermint_test", 0700)
|
||||||
cfg.ApplyConfig(config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTMRoot(rootDir string) string {
|
func ResetConfig(path string) {
|
||||||
if rootDir == "" {
|
rootDir := os.Getenv("HOME") + "/.tendermint_test/" + path
|
||||||
rootDir = os.Getenv("HOME") + "/.tendermint_test"
|
cfg.ApplyConfig(GetConfig(rootDir))
|
||||||
}
|
|
||||||
return rootDir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initTMRoot(rootDir string) {
|
func initTMRoot(rootDir string) {
|
||||||
rootDir = getTMRoot(rootDir)
|
|
||||||
|
|
||||||
// Remove ~/.tendermint_test_bak
|
// Remove ~/.tendermint_test_bak
|
||||||
if FileExists(rootDir + "_bak") {
|
if FileExists(rootDir + "_bak") {
|
||||||
err := os.RemoveAll(rootDir + "_bak")
|
err := os.RemoveAll(rootDir + "_bak")
|
||||||
@ -62,7 +57,6 @@ func initTMRoot(rootDir string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetConfig(rootDir string) cfg.Config {
|
func GetConfig(rootDir string) cfg.Config {
|
||||||
rootDir = getTMRoot(rootDir)
|
|
||||||
initTMRoot(rootDir)
|
initTMRoot(rootDir)
|
||||||
|
|
||||||
configFilePath := path.Join(rootDir, "config.toml")
|
configFilePath := path.Join(rootDir, "config.toml")
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
dbm "github.com/tendermint/go-db"
|
dbm "github.com/tendermint/go-db"
|
||||||
"github.com/tendermint/go-events"
|
"github.com/tendermint/go-events"
|
||||||
bc "github.com/tendermint/tendermint/blockchain"
|
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"
|
mempl "github.com/tendermint/tendermint/mempool"
|
||||||
"github.com/tendermint/tendermint/proxy"
|
"github.com/tendermint/tendermint/proxy"
|
||||||
sm "github.com/tendermint/tendermint/state"
|
sm "github.com/tendermint/tendermint/state"
|
||||||
@ -25,6 +25,7 @@ var chainID string
|
|||||||
var ensureTimeout = time.Duration(2)
|
var ensureTimeout = time.Duration(2)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
tendermint_test.ResetConfig("consensus_common_test")
|
||||||
chainID = config.GetString("chain_id")
|
chainID = config.GetString("chain_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package consensus
|
package consensus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
tendermint_test.ResetConfig("consensus_height_vote_set_test")
|
||||||
|
}
|
||||||
|
|
||||||
func TestPeerCatchupRounds(t *testing.T) {
|
func TestPeerCatchupRounds(t *testing.T) {
|
||||||
valSet, privVals := types.RandValidatorSet(10, 1)
|
valSet, privVals := types.RandValidatorSet(10, 1)
|
||||||
|
|
||||||
|
@ -50,8 +50,6 @@ func TestReplayCatchup(t *testing.T) {
|
|||||||
t.Fatalf("Error on catchup replay %v", err)
|
t.Fatalf("Error on catchup replay %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cs.enterNewRound(cs.Height, cs.Round)
|
|
||||||
|
|
||||||
after := time.After(time.Second * 2)
|
after := time.After(time.Second * 2)
|
||||||
select {
|
select {
|
||||||
case <-newBlockCh:
|
case <-newBlockCh:
|
||||||
|
@ -6,11 +6,15 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||||
//"github.com/tendermint/go-events"
|
//"github.com/tendermint/go-events"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
tendermint_test.ResetConfig("consensus_state_test")
|
||||||
|
}
|
||||||
|
|
||||||
func (tp *TimeoutParams) ensureProposeTimeout() time.Duration {
|
func (tp *TimeoutParams) ensureProposeTimeout() time.Duration {
|
||||||
return time.Duration(tp.Propose0*2) * time.Millisecond
|
return time.Duration(tp.Propose0*2) * time.Millisecond
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,17 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||||
"github.com/tendermint/tendermint/proxy"
|
"github.com/tendermint/tendermint/proxy"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
"github.com/tendermint/tmsp/example/counter"
|
"github.com/tendermint/tmsp/example/counter"
|
||||||
tmsp "github.com/tendermint/tmsp/types"
|
tmsp "github.com/tendermint/tmsp/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
tendermint_test.ResetConfig("mempool_mempool_test")
|
||||||
|
}
|
||||||
|
|
||||||
func TestSerialReap(t *testing.T) {
|
func TestSerialReap(t *testing.T) {
|
||||||
|
|
||||||
app := counter.NewCounterApplication(true)
|
app := counter.NewCounterApplication(true)
|
||||||
|
@ -5,10 +5,14 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tendermint/go-p2p"
|
"github.com/tendermint/go-p2p"
|
||||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
tendermint_test.ResetConfig("node_node_test")
|
||||||
|
}
|
||||||
|
|
||||||
func TestNodeStartStop(t *testing.T) {
|
func TestNodeStartStop(t *testing.T) {
|
||||||
|
|
||||||
// Get PrivValidator
|
// Get PrivValidator
|
||||||
|
@ -4,11 +4,16 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
tendermint_test.ResetConfig("rpc_test_client_test")
|
||||||
|
initGlobalVariables()
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
// Test the HTTP client
|
// Test the HTTP client
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
|
|
||||||
client "github.com/tendermint/go-rpc/client"
|
client "github.com/tendermint/go-rpc/client"
|
||||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
|
||||||
nm "github.com/tendermint/tendermint/node"
|
nm "github.com/tendermint/tendermint/node"
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
@ -18,19 +17,18 @@ import (
|
|||||||
// global variables for use across all tests
|
// global variables for use across all tests
|
||||||
var (
|
var (
|
||||||
node *nm.Node
|
node *nm.Node
|
||||||
|
|
||||||
mempoolCount = 0
|
mempoolCount = 0
|
||||||
|
|
||||||
chainID string
|
chainID string
|
||||||
|
rpcAddr string
|
||||||
rpcAddr, requestAddr, websocketAddr, websocketEndpoint string
|
requestAddr string
|
||||||
|
websocketAddr string
|
||||||
|
websocketEndpoint string
|
||||||
clientURI *client.ClientURI
|
clientURI *client.ClientURI
|
||||||
clientJSON *client.ClientJSONRPC
|
clientJSON *client.ClientJSONRPC
|
||||||
)
|
)
|
||||||
|
|
||||||
// initialize config and create new node
|
// initialize config and create new node
|
||||||
func init() {
|
func initGlobalVariables() {
|
||||||
chainID = config.GetString("chain_id")
|
chainID = config.GetString("chain_id")
|
||||||
rpcAddr = config.GetString("rpc_laddr")
|
rpcAddr = config.GetString("rpc_laddr")
|
||||||
requestAddr = rpcAddr
|
requestAddr = rpcAddr
|
||||||
|
@ -4,9 +4,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/tendermint/go-common"
|
. "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) {
|
func TestProposalSignable(t *testing.T) {
|
||||||
proposal := &Proposal{
|
proposal := &Proposal{
|
||||||
Height: 12345,
|
Height: 12345,
|
||||||
|
@ -6,11 +6,15 @@ import (
|
|||||||
. "github.com/tendermint/go-common"
|
. "github.com/tendermint/go-common"
|
||||||
. "github.com/tendermint/go-common/test"
|
. "github.com/tendermint/go-common/test"
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||||
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
tendermint_test.ResetConfig("types_vote_set_test")
|
||||||
|
}
|
||||||
|
|
||||||
// Move it out?
|
// Move it out?
|
||||||
func randVoteSet(height int, round int, type_ byte, numValidators int, votingPower int64) (*VoteSet, *ValidatorSet, []*PrivValidator) {
|
func randVoteSet(height int, round int, type_ byte, numValidators int, votingPower int64) (*VoteSet, *ValidatorSet, []*PrivValidator) {
|
||||||
valSet, privValidators := RandValidatorSet(numValidators, votingPower)
|
valSet, privValidators := RandValidatorSet(numValidators, votingPower)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user