Files
tendermint/internal/test/factory/commit.go
Thane Thomson 656d2d01be Fix most tests except TestHandshake*
Signed-off-by: Thane Thomson <connect@thanethomson.com>
2022-05-03 10:59:37 -04:00

42 lines
1.1 KiB
Go

package factory
import (
"context"
"time"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/types"
)
func MakeExtendedCommit(ctx context.Context, blockID types.BlockID, height int64, round int32, voteSet *types.VoteSet, validators []types.PrivValidator, now time.Time) (*types.ExtendedCommit, error) {
// all sign
for i := 0; i < len(validators); i++ {
pubKey, err := validators[i].GetPubKey(ctx)
if err != nil {
return nil, err
}
vote := &types.Vote{
ValidatorAddress: pubKey.Address(),
ValidatorIndex: int32(i),
Height: height,
Round: round,
Type: tmproto.PrecommitType,
BlockID: blockID,
Timestamp: now,
}
v := vote.ToProto()
if err := validators[i].SignVote(ctx, voteSet.ChainID(), v); err != nil {
return nil, err
}
vote.Signature = v.Signature
vote.ExtensionSignature = v.ExtensionSignature
if _, err := voteSet.AddVote(vote); err != nil {
return nil, err
}
}
return voteSet.MakeExtendedCommit(), nil
}