You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. package consensus
  2. import (
  3. "sort"
  4. bc "github.com/tendermint/tendermint/blockchain"
  5. dbm "github.com/tendermint/tendermint/db"
  6. mempl "github.com/tendermint/tendermint/mempool"
  7. sm "github.com/tendermint/tendermint/state"
  8. )
  9. func randConsensusState() (*ConsensusState, []*sm.PrivValidator) {
  10. state, _, privValidators := sm.RandGenesisState(20, false, 1000, 10, false, 1000)
  11. blockStore := bc.NewBlockStore(dbm.NewMemDB())
  12. mempool := mempl.NewMempool(state)
  13. mempoolReactor := mempl.NewMempoolReactor(mempool)
  14. cs := NewConsensusState(state, blockStore, mempoolReactor)
  15. return cs, privValidators
  16. }
  17. func randVoteSet(height uint, round uint, type_ byte, numValidators int, votingPower uint64) (*VoteSet, *sm.ValidatorSet, []*sm.PrivValidator) {
  18. vals := make([]*sm.Validator, numValidators)
  19. privValidators := make([]*sm.PrivValidator, numValidators)
  20. for i := 0; i < numValidators; i++ {
  21. _, val, privValidator := sm.RandValidator(false, votingPower)
  22. vals[i] = val
  23. privValidators[i] = privValidator
  24. }
  25. valSet := sm.NewValidatorSet(vals)
  26. sort.Sort(sm.PrivValidatorsByAddress(privValidators))
  27. return NewVoteSet(height, round, type_, valSet), valSet, privValidators
  28. }