github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/internal/test/factory/vote.go (about)

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