POL tests

This commit is contained in:
Jae Kwon
2014-10-17 16:48:27 -07:00
parent 5c69736994
commit ca1d8a54be
4 changed files with 227 additions and 21 deletions

27
consensus/test.go Normal file
View File

@ -0,0 +1,27 @@
package consensus
import (
. "github.com/tendermint/tendermint/blocks"
"github.com/tendermint/tendermint/state"
)
func makeValidator(id uint64, votingPower uint64) (*state.Validator, *state.PrivAccount) {
privAccount := state.GenPrivAccount()
privAccount.Id = id
return &state.Validator{
Account: privAccount.Account,
VotingPower: votingPower,
}, privAccount
}
func makeVoteSet(height uint32, round uint16, numValidators int, votingPower uint64) (*VoteSet, *state.ValidatorSet, []*state.PrivAccount) {
vals := make([]*state.Validator, numValidators)
privAccounts := make([]*state.PrivAccount, numValidators)
for i := 0; i < numValidators; i++ {
val, privAccount := makeValidator(uint64(i), votingPower)
vals[i] = val
privAccounts[i] = privAccount
}
valSet := state.NewValidatorSet(vals)
return NewVoteSet(height, round, VoteTypeBare, valSet), valSet, privAccounts
}