github.com/number571/tendermint@v0.34.11-gost/internal/test/factory/vote.go (about)

     1  package factory
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	tmproto "github.com/number571/tendermint/proto/tendermint/types"
     8  	"github.com/number571/tendermint/types"
     9  )
    10  
    11  func MakeVote(
    12  	val types.PrivValidator,
    13  	chainID string,
    14  	valIndex int32,
    15  	height int64,
    16  	round int32,
    17  	step int,
    18  	blockID types.BlockID,
    19  	time time.Time,
    20  ) (*types.Vote, error) {
    21  	pubKey, err := val.GetPubKey(context.Background())
    22  	if err != nil {
    23  		return nil, err
    24  	}
    25  	v := &types.Vote{
    26  		ValidatorAddress: pubKey.Address(),
    27  		ValidatorIndex:   valIndex,
    28  		Height:           height,
    29  		Round:            round,
    30  		Type:             tmproto.SignedMsgType(step),
    31  		BlockID:          blockID,
    32  		Timestamp:        time,
    33  	}
    34  
    35  	vpb := v.ToProto()
    36  	err = val.SignVote(context.Background(), chainID, vpb)
    37  	if err != nil {
    38  		panic(err)
    39  	}
    40  	v.Signature = vpb.Signature
    41  	return v, nil
    42  }