|
|
@ -12,6 +12,7 @@ import ( |
|
|
|
. "github.com/tendermint/go-common" |
|
|
|
cfg "github.com/tendermint/go-config" |
|
|
|
dbm "github.com/tendermint/go-db" |
|
|
|
"github.com/tendermint/go-logger" |
|
|
|
"github.com/tendermint/go-p2p" |
|
|
|
bc "github.com/tendermint/tendermint/blockchain" |
|
|
|
"github.com/tendermint/tendermint/config/tendermint_test" |
|
|
@ -256,14 +257,15 @@ func randConsensusState(nValidators int) (*ConsensusState, []*validatorStub) { |
|
|
|
return cs, vss |
|
|
|
} |
|
|
|
|
|
|
|
func randConsensusNet(nValidators int) []*ConsensusState { |
|
|
|
func randConsensusNet(nValidators int, testName string, updateConfig func(cfg.Config)) []*ConsensusState { |
|
|
|
genDoc, privVals := randGenesisDoc(nValidators, false, 10) |
|
|
|
css := make([]*ConsensusState, nValidators) |
|
|
|
for i := 0; i < nValidators; i++ { |
|
|
|
db := dbm.NewMemDB() // each state needs its own db
|
|
|
|
state := sm.MakeGenesisState(db, genDoc) |
|
|
|
state.Save() |
|
|
|
thisConfig := tendermint_test.ResetConfig(Fmt("consensus_reactor_test_%d", i)) |
|
|
|
thisConfig := tendermint_test.ResetConfig(Fmt("%s_%d", testName, i)) |
|
|
|
updateConfig(thisConfig) |
|
|
|
EnsureDir(thisConfig.GetString("cs_wal_dir"), 0700) // dir for wal
|
|
|
|
css[i] = newConsensusStateWithConfig(thisConfig, state, privVals[i], counter.NewCounterApplication(true)) |
|
|
|
} |
|
|
@ -271,14 +273,15 @@ func randConsensusNet(nValidators int) []*ConsensusState { |
|
|
|
} |
|
|
|
|
|
|
|
// nPeers = nValidators + nNotValidator
|
|
|
|
func randConsensusNetWithPeers(nValidators int, nPeers int) []*ConsensusState { |
|
|
|
func randConsensusNetWithPeers(nValidators, nPeers int, testName string, updateConfig func(cfg.Config)) []*ConsensusState { |
|
|
|
genDoc, privVals := randGenesisDoc(nValidators, false, int64(testMinPower)) |
|
|
|
css := make([]*ConsensusState, nPeers) |
|
|
|
for i := 0; i < nPeers; i++ { |
|
|
|
db := dbm.NewMemDB() // each state needs its own db
|
|
|
|
state := sm.MakeGenesisState(db, genDoc) |
|
|
|
state.Save() |
|
|
|
thisConfig := tendermint_test.ResetConfig(Fmt("consensus_reactor_test_%d", i)) |
|
|
|
thisConfig := tendermint_test.ResetConfig(Fmt("%s_%d", testName, i)) |
|
|
|
updateConfig(thisConfig) |
|
|
|
EnsureDir(thisConfig.GetString("cs_wal_dir"), 0700) // dir for wal
|
|
|
|
var privVal *types.PrivValidator |
|
|
|
if i < nValidators { |
|
|
@ -367,3 +370,12 @@ func getSwitchIndex(switches []*p2p.Switch, peer *p2p.Peer) int { |
|
|
|
panic("didnt find peer in switches") |
|
|
|
return -1 |
|
|
|
} |
|
|
|
|
|
|
|
// so we dont violate synchrony assumptions
|
|
|
|
// TODO: make tests more robust to this instead (handle round changes)
|
|
|
|
// XXX: especially a problem when running the race detector on circle
|
|
|
|
func crankTimeoutPropose(config cfg.Config) { |
|
|
|
logger.SetLogLevel("info") |
|
|
|
config.Set("timeout_propose", 110000) // TODO: crank it to eleventy
|
|
|
|
config.Set("timeout_commit", 1000) |
|
|
|
} |