mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 04:01:55 +00:00
test bondTx
This commit is contained in:
@@ -9,34 +9,6 @@ import (
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
)
|
||||
|
||||
// Common test methods
|
||||
|
||||
func makeValidator(valInfo *sm.ValidatorInfo) *sm.Validator {
|
||||
return &sm.Validator{
|
||||
Address: valInfo.Address,
|
||||
PubKey: valInfo.PubKey,
|
||||
BondHeight: 0,
|
||||
UnbondHeight: 0,
|
||||
LastCommitHeight: 0,
|
||||
VotingPower: valInfo.FirstBondAmount,
|
||||
Accum: 0,
|
||||
}
|
||||
}
|
||||
|
||||
func randVoteSet(height uint, round uint, type_ byte, numValidators int, votingPower uint64) (*VoteSet, *sm.ValidatorSet, []*sm.PrivValidator) {
|
||||
vals := make([]*sm.Validator, numValidators)
|
||||
privValidators := make([]*sm.PrivValidator, numValidators)
|
||||
for i := 0; i < numValidators; i++ {
|
||||
valInfo, privValidator := sm.RandValidator(false, votingPower)
|
||||
val := makeValidator(valInfo)
|
||||
vals[i] = val
|
||||
privValidators[i] = privValidator
|
||||
}
|
||||
valSet := sm.NewValidatorSet(vals)
|
||||
sort.Sort(sm.PrivValidatorsByAddress(privValidators))
|
||||
return NewVoteSet(height, round, type_, valSet), valSet, privValidators
|
||||
}
|
||||
|
||||
func randConsensusState() (*ConsensusState, []*sm.PrivValidator) {
|
||||
state, _, privValidators := sm.RandGenesisState(20, false, 1000, 10, false, 1000)
|
||||
blockStore := blk.NewBlockStore(dbm.NewMemDB())
|
||||
@@ -45,3 +17,16 @@ func randConsensusState() (*ConsensusState, []*sm.PrivValidator) {
|
||||
cs := NewConsensusState(state, blockStore, mempoolReactor)
|
||||
return cs, privValidators
|
||||
}
|
||||
|
||||
func randVoteSet(height uint, round uint, type_ byte, numValidators int, votingPower uint64) (*VoteSet, *sm.ValidatorSet, []*sm.PrivValidator) {
|
||||
vals := make([]*sm.Validator, numValidators)
|
||||
privValidators := make([]*sm.PrivValidator, numValidators)
|
||||
for i := 0; i < numValidators; i++ {
|
||||
_, val, privValidator := sm.RandValidator(false, votingPower)
|
||||
vals[i] = val
|
||||
privValidators[i] = privValidator
|
||||
}
|
||||
valSet := sm.NewValidatorSet(vals)
|
||||
sort.Sort(sm.PrivValidatorsByAddress(privValidators))
|
||||
return NewVoteSet(height, round, type_, valSet), valSet, privValidators
|
||||
}
|
||||
|
Reference in New Issue
Block a user