github.com/number571/tendermint@v0.34.11-gost/proto/tendermint/consensus/message_test.go (about)

     1  package consensus_test
     2  
     3  import (
     4  	"encoding/hex"
     5  	"math"
     6  	"testing"
     7  
     8  	"github.com/gogo/protobuf/proto"
     9  	"github.com/stretchr/testify/require"
    10  
    11  	tmcons "github.com/number571/tendermint/proto/tendermint/consensus"
    12  	tmproto "github.com/number571/tendermint/proto/tendermint/types"
    13  )
    14  
    15  func TestHasVoteVector(t *testing.T) {
    16  	testCases := []struct {
    17  		msg      tmcons.HasVote
    18  		expBytes string
    19  	}{
    20  		{tmcons.HasVote{1, 3, tmproto.PrevoteType, 1}, "3a080801100318012001"},
    21  		{tmcons.HasVote{2, 2, tmproto.PrecommitType, 2}, "3a080802100218022002"},
    22  		{tmcons.HasVote{math.MaxInt64, math.MaxInt32, tmproto.ProposalType, math.MaxInt32},
    23  			"3a1808ffffffffffffffff7f10ffffffff07182020ffffffff07"},
    24  	}
    25  
    26  	for i, tc := range testCases {
    27  		msg := tmcons.Message{&tmcons.Message_HasVote{HasVote: &tc.msg}}
    28  		bz, err := proto.Marshal(&msg)
    29  		require.NoError(t, err)
    30  		require.Equal(t, tc.expBytes, hex.EncodeToString(bz), "test vector failed", i)
    31  	}
    32  }