Browse Source

consensus: add test vector for hasvote (#6469)

## Description

adds a test vector for hasvote in order to extra sure https://github.com/tendermint/tendermint/pull/6287 isnt breaking
pull/6484/head
Marko 4 years ago
committed by GitHub
parent
commit
7b5a732644
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions
  1. +32
    -0
      proto/tendermint/consensus/message_test.go

+ 32
- 0
proto/tendermint/consensus/message_test.go View File

@ -0,0 +1,32 @@
package consensus_test
import (
"encoding/hex"
"math"
"testing"
"github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/require"
tmcons "github.com/tendermint/tendermint/proto/tendermint/consensus"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
func TestHasVoteVector(t *testing.T) {
testCases := []struct {
msg tmcons.HasVote
expBytes string
}{
{tmcons.HasVote{1, 3, tmproto.PrevoteType, 1}, "3a080801100318012001"},
{tmcons.HasVote{2, 2, tmproto.PrecommitType, 2}, "3a080802100218022002"},
{tmcons.HasVote{math.MaxInt64, math.MaxInt32, tmproto.ProposalType, math.MaxInt32},
"3a1808ffffffffffffffff7f10ffffffff07182020ffffffff07"},
}
for i, tc := range testCases {
msg := tmcons.Message{&tmcons.Message_HasVote{HasVote: &tc.msg}}
bz, err := proto.Marshal(&msg)
require.NoError(t, err)
require.Equal(t, tc.expBytes, hex.EncodeToString(bz), "test vector failed", i)
}
}

Loading…
Cancel
Save