Browse Source

Fix tests; Tests run in their own directory

pull/206/merge
Jae Kwon 9 years ago
parent
commit
03115cbf93
11 changed files with 53 additions and 33 deletions
  1. +5
    -11
      config/tendermint_test/config.go
  2. +2
    -1
      consensus/common_test.go
  3. +5
    -1
      consensus/height_vote_set_test.go
  4. +0
    -2
      consensus/replay_test.go
  5. +5
    -1
      consensus/state_test.go
  6. +5
    -1
      mempool/mempool_test.go
  7. +5
    -1
      node/node_test.go
  8. +6
    -1
      rpc/test/client_test.go
  9. +10
    -12
      rpc/test/helpers.go
  10. +5
    -1
      types/proposal_test.go
  11. +5
    -1
      types/vote_set_test.go

+ 5
- 11
config/tendermint_test/config.go View File

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


+ 2
- 1
consensus/common_test.go View File

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


+ 5
- 1
consensus/height_vote_set_test.go View File

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


+ 0
- 2
consensus/replay_test.go View File

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


+ 5
- 1
consensus/state_test.go View File

@ -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
- 1
mempool/mempool_test.go View File

@ -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
- 1
node/node_test.go View File

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


+ 6
- 1
rpc/test/client_test.go View File

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


+ 10
- 12
rpc/test/helpers.go View File

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


+ 5
- 1
types/proposal_test.go View File

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


+ 5
- 1
types/vote_set_test.go View File

@ -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…
Cancel
Save