mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-24 02:01:43 +00:00
types: remove Version from CanonicalXxx (#2666)
This commit is contained in:
@ -54,8 +54,7 @@ func TestVoteSignable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestVoteSignableTestVectors(t *testing.T) {
|
||||
voteWithVersion := CanonicalizeVote("", &Vote{Height: 1, Round: 1})
|
||||
voteWithVersion.Version = 123
|
||||
vote := CanonicalizeVote("", &Vote{Height: 1, Round: 1})
|
||||
|
||||
tests := []struct {
|
||||
canonicalVote CanonicalVote
|
||||
@ -64,20 +63,20 @@ func TestVoteSignableTestVectors(t *testing.T) {
|
||||
{
|
||||
CanonicalizeVote("", &Vote{}),
|
||||
// NOTE: Height and Round are skipped here. This case needs to be considered while parsing.
|
||||
[]byte{0xb, 0x2a, 0x9, 0x9, 0x0, 0x9, 0x6e, 0x88, 0xf1, 0xff, 0xff, 0xff},
|
||||
[]byte{0xb, 0x22, 0x9, 0x9, 0x0, 0x9, 0x6e, 0x88, 0xf1, 0xff, 0xff, 0xff},
|
||||
},
|
||||
// with proper (fixed size) height and round (PreCommit):
|
||||
{
|
||||
CanonicalizeVote("", &Vote{Height: 1, Round: 1, Type: PrecommitType}),
|
||||
[]byte{
|
||||
0x1f, // total length
|
||||
0x11, // (field_number << 3) | wire_type (version is missing)
|
||||
0x9, // (field_number << 3) | wire_type
|
||||
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // height
|
||||
0x19, // (field_number << 3) | wire_type
|
||||
0x11, // (field_number << 3) | wire_type
|
||||
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // round
|
||||
0x20, // (field_number << 3) | wire_type
|
||||
0x18, // (field_number << 3) | wire_type
|
||||
0x2, // PrecommitType
|
||||
0x2a, // (field_number << 3) | wire_type
|
||||
0x22, // (field_number << 3) | wire_type
|
||||
// remaining fields (timestamp):
|
||||
0x9, 0x9, 0x0, 0x9, 0x6e, 0x88, 0xf1, 0xff, 0xff, 0xff},
|
||||
},
|
||||
@ -86,29 +85,26 @@ func TestVoteSignableTestVectors(t *testing.T) {
|
||||
CanonicalizeVote("", &Vote{Height: 1, Round: 1, Type: PrevoteType}),
|
||||
[]byte{
|
||||
0x1f, // total length
|
||||
0x11, // (field_number << 3) | wire_type (version is missing)
|
||||
0x9, // (field_number << 3) | wire_type
|
||||
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // height
|
||||
0x19, // (field_number << 3) | wire_type
|
||||
0x11, // (field_number << 3) | wire_type
|
||||
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // round
|
||||
0x20, // (field_number << 3) | wire_type
|
||||
0x18, // (field_number << 3) | wire_type
|
||||
0x1, // PrevoteType
|
||||
0x2a, // (field_number << 3) | wire_type
|
||||
0x22, // (field_number << 3) | wire_type
|
||||
// remaining fields (timestamp):
|
||||
0x9, 0x9, 0x0, 0x9, 0x6e, 0x88, 0xf1, 0xff, 0xff, 0xff},
|
||||
},
|
||||
// containing version (empty type)
|
||||
{
|
||||
voteWithVersion,
|
||||
vote,
|
||||
[]byte{
|
||||
0x26, // total length
|
||||
0x9, // (field_number << 3) | wire_type
|
||||
0x7b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // version (123)
|
||||
0x11, // (field_number << 3) | wire_type
|
||||
0x1d, // total length
|
||||
0x9, // (field_number << 3) | wire_type
|
||||
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // height
|
||||
0x19, // (field_number << 3) | wire_type
|
||||
0x11, // (field_number << 3) | wire_type
|
||||
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // round
|
||||
// remaining fields (timestamp):
|
||||
0x2a,
|
||||
0x22,
|
||||
0x9, 0x9, 0x0, 0x9, 0x6e, 0x88, 0xf1, 0xff, 0xff, 0xff},
|
||||
},
|
||||
// containing non-empty chain_id:
|
||||
@ -116,14 +112,14 @@ func TestVoteSignableTestVectors(t *testing.T) {
|
||||
CanonicalizeVote("test_chain_id", &Vote{Height: 1, Round: 1}),
|
||||
[]byte{
|
||||
0x2c, // total length
|
||||
0x11, // (field_number << 3) | wire_type
|
||||
0x9, // (field_number << 3) | wire_type
|
||||
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // height
|
||||
0x19, // (field_number << 3) | wire_type
|
||||
0x11, // (field_number << 3) | wire_type
|
||||
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // round
|
||||
// remaining fields:
|
||||
0x2a, // (field_number << 3) | wire_type
|
||||
0x22, // (field_number << 3) | wire_type
|
||||
0x9, 0x9, 0x0, 0x9, 0x6e, 0x88, 0xf1, 0xff, 0xff, 0xff, // timestamp
|
||||
0x3a, // (field_number << 3) | wire_type
|
||||
0x32, // (field_number << 3) | wire_type
|
||||
0xd, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64}, // chainID
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user