mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
forgot file
This commit is contained in:
parent
3ad055ef3a
commit
b5857da877
37
types/test_util.go
Normal file
37
types/test_util.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
func MakeCommit(blockID BlockID, height int64, round int,
|
||||||
|
voteSet *VoteSet,
|
||||||
|
validators []*PrivValidatorFS) (*Commit, error) {
|
||||||
|
|
||||||
|
// all sign
|
||||||
|
for i := 0; i < len(validators); i++ {
|
||||||
|
|
||||||
|
vote := &Vote{
|
||||||
|
ValidatorAddress: validators[i].GetAddress(),
|
||||||
|
ValidatorIndex: i,
|
||||||
|
Height: height,
|
||||||
|
Round: round,
|
||||||
|
Type: VoteTypePrecommit,
|
||||||
|
BlockID: blockID,
|
||||||
|
Timestamp: time.Now().UTC(),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := signAddVote(validators[i], vote, voteSet)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return voteSet.MakeCommit(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func signAddVote(privVal *PrivValidatorFS, vote *Vote, voteSet *VoteSet) (signed bool, err error) {
|
||||||
|
vote.Signature, err = privVal.Signer.Sign(SignBytes(voteSet.ChainID(), vote))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return voteSet.AddVote(vote)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user