mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-10 05:50:19 +00:00
user arg struct
This commit is contained in:
@@ -466,7 +466,9 @@ func loadPrivValidator(t *testing.T, config *cfg.Config) *privval.FilePV {
|
||||
|
||||
func makeState(config *cfg.Config, nValidators int) (*State, []*validatorStub) {
|
||||
// Get State
|
||||
state, privVals := makeGenesisState(config, nValidators, 10, types.DefaultConsensusParams())
|
||||
state, privVals := makeGenesisState(config, genesisStateArgs{
|
||||
Validators: nValidators,
|
||||
})
|
||||
|
||||
vss := make([]*validatorStub, nValidators)
|
||||
|
||||
@@ -850,24 +852,28 @@ func randConsensusNetWithPeers(
|
||||
}
|
||||
}
|
||||
|
||||
func makeGenesisState(
|
||||
config *cfg.Config,
|
||||
numValidators int,
|
||||
votingPower int64,
|
||||
consensusParams *types.ConsensusParams) (sm.State, []types.PrivValidator) {
|
||||
return makeGenesisStateWithGenesisTime(config, numValidators, votingPower, consensusParams, time.Now())
|
||||
type genesisStateArgs struct {
|
||||
Validators int
|
||||
Power int64
|
||||
Params *types.ConsensusParams
|
||||
Time time.Time
|
||||
}
|
||||
|
||||
func makeGenesisStateWithGenesisTime(
|
||||
config *cfg.Config,
|
||||
numValidators int,
|
||||
votingPower int64,
|
||||
consensusParams *types.ConsensusParams,
|
||||
genesisTime time.Time,
|
||||
) (sm.State, []types.PrivValidator) {
|
||||
|
||||
valSet, privValidators := factory.ValidatorSet(numValidators, votingPower)
|
||||
genDoc := factory.GenesisDoc(config, genesisTime, valSet.Validators, consensusParams)
|
||||
func makeGenesisState(config *cfg.Config, args genesisStateArgs) (sm.State, []types.PrivValidator) {
|
||||
if args.Power == 0 {
|
||||
args.Power = 1
|
||||
}
|
||||
if args.Validators == 0 {
|
||||
args.Power = 4
|
||||
}
|
||||
valSet, privValidators := factory.ValidatorSet(args.Validators, args.Power)
|
||||
if args.Params == nil {
|
||||
args.Params = types.DefaultConsensusParams()
|
||||
}
|
||||
if args.Time.IsZero() {
|
||||
args.Time = time.Now()
|
||||
}
|
||||
genDoc := factory.GenesisDoc(config, args.Time, valSet.Validators, args.Params)
|
||||
s0, _ := sm.MakeGenesisState(genDoc)
|
||||
return s0, privValidators
|
||||
}
|
||||
|
||||
@@ -33,7 +33,9 @@ func TestMempoolNoProgressUntilTxsAvailable(t *testing.T) {
|
||||
t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) })
|
||||
|
||||
config.Consensus.CreateEmptyBlocks = false
|
||||
state, privVals := makeGenesisState(baseConfig, 1, 10, nil)
|
||||
state, privVals := makeGenesisState(baseConfig, genesisStateArgs{
|
||||
Validators: 1,
|
||||
Power: 10})
|
||||
cs := newStateWithConfig(config, state, privVals[0], NewCounterApplication())
|
||||
assertMempool(cs.txNotifier).EnableTxsAvailable()
|
||||
height, round := cs.Height, cs.Round
|
||||
@@ -55,7 +57,9 @@ func TestMempoolProgressAfterCreateEmptyBlocksInterval(t *testing.T) {
|
||||
t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) })
|
||||
|
||||
config.Consensus.CreateEmptyBlocksInterval = ensureTimeout
|
||||
state, privVals := makeGenesisState(baseConfig, 1, 10, nil)
|
||||
state, privVals := makeGenesisState(baseConfig, genesisStateArgs{
|
||||
Validators: 1,
|
||||
Power: 10})
|
||||
cs := newStateWithConfig(config, state, privVals[0], NewCounterApplication())
|
||||
|
||||
assertMempool(cs.txNotifier).EnableTxsAvailable()
|
||||
@@ -75,7 +79,9 @@ func TestMempoolProgressInHigherRound(t *testing.T) {
|
||||
t.Cleanup(func() { _ = os.RemoveAll(config.RootDir) })
|
||||
|
||||
config.Consensus.CreateEmptyBlocks = false
|
||||
state, privVals := makeGenesisState(baseConfig, 1, 10, nil)
|
||||
state, privVals := makeGenesisState(baseConfig, genesisStateArgs{
|
||||
Validators: 1,
|
||||
Power: 10})
|
||||
cs := newStateWithConfig(config, state, privVals[0], NewCounterApplication())
|
||||
assertMempool(cs.txNotifier).EnableTxsAvailable()
|
||||
height, round := cs.Height, cs.Round
|
||||
@@ -123,7 +129,9 @@ func deliverTxsRange(cs *State, start, end int) {
|
||||
func TestMempoolTxConcurrentWithCommit(t *testing.T) {
|
||||
config := configSetup(t)
|
||||
|
||||
state, privVals := makeGenesisState(config, 1, 10, nil)
|
||||
state, privVals := makeGenesisState(config, genesisStateArgs{
|
||||
Validators: 1,
|
||||
Power: 10})
|
||||
stateStore := sm.NewStore(dbm.NewMemDB())
|
||||
blockStore := store.NewBlockStore(dbm.NewMemDB())
|
||||
cs := newStateWithConfigAndBlockStore(config, state, privVals[0], NewCounterApplication(), blockStore)
|
||||
@@ -149,7 +157,9 @@ func TestMempoolTxConcurrentWithCommit(t *testing.T) {
|
||||
func TestMempoolRmBadTx(t *testing.T) {
|
||||
config := configSetup(t)
|
||||
|
||||
state, privVals := makeGenesisState(config, 1, 10, nil)
|
||||
state, privVals := makeGenesisState(config, genesisStateArgs{
|
||||
Validators: 1,
|
||||
Power: 10})
|
||||
app := NewCounterApplication()
|
||||
stateStore := sm.NewStore(dbm.NewMemDB())
|
||||
blockStore := store.NewBlockStore(dbm.NewMemDB())
|
||||
|
||||
Reference in New Issue
Block a user