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.

29 lines
922 B

10 years ago
10 years ago
10 years ago
  1. package consensus
  2. import (
  3. . "github.com/tendermint/tendermint/blocks"
  4. "github.com/tendermint/tendermint/state"
  5. )
  6. // Common test methods
  7. func makeValidator(id uint64, votingPower uint64) (*state.Validator, *state.PrivAccount) {
  8. privAccount := state.GenPrivAccount()
  9. privAccount.Id = id
  10. return &state.Validator{
  11. Account: privAccount.Account,
  12. VotingPower: votingPower,
  13. }, privAccount
  14. }
  15. func makeVoteSet(height uint32, round uint16, numValidators int, votingPower uint64) (*VoteSet, *state.ValidatorSet, []*state.PrivAccount) {
  16. vals := make([]*state.Validator, numValidators)
  17. privAccounts := make([]*state.PrivAccount, numValidators)
  18. for i := 0; i < numValidators; i++ {
  19. val, privAccount := makeValidator(uint64(i), votingPower)
  20. vals[i] = val
  21. privAccounts[i] = privAccount
  22. }
  23. valSet := state.NewValidatorSet(vals)
  24. return NewVoteSet(height, round, VoteTypePrevote, valSet), valSet, privAccounts
  25. }