Browse Source

types: Rename exampleVote to examplePrecommit on vote_test

exampleVote doesn't express the type of the vote.
pull/996/head
Ricardo Domingos 7 years ago
parent
commit
19eeef0aad
1 changed files with 10 additions and 25 deletions
  1. +10
    -25
      types/vote_test.go

+ 10
- 25
types/vote_test.go View File

@ -9,30 +9,15 @@ import (
wire "github.com/tendermint/go-wire"
)
func exampleVote() *Vote {
var stamp, err = time.Parse(timeFormat, "2017-12-25T03:00:01.234Z")
if err != nil {
panic(err)
}
func examplePrevote() *Vote {
return exampleVote(VoteTypePrevote)
}
return &Vote{
ValidatorAddress: []byte("addr"),
ValidatorIndex: 56789,
Height: 12345,
Round: 2,
Timestamp: stamp,
Type: byte(2),
BlockID: BlockID{
Hash: []byte("hash"),
PartsHeader: PartSetHeader{
Total: 1000000,
Hash: []byte("parts_hash"),
},
},
}
func examplePrecommit() *Vote {
return exampleVote(VoteTypePrecommit)
}
func examplePrevote() *Vote {
func exampleVote(t byte) *Vote {
var stamp, err = time.Parse(timeFormat, "2017-12-25T03:00:01.234Z")
if err != nil {
panic(err)
@ -44,7 +29,7 @@ func examplePrevote() *Vote {
Height: 12345,
Round: 2,
Timestamp: stamp,
Type: byte(1),
Type: t,
BlockID: BlockID{
Hash: []byte("hash"),
PartsHeader: PartSetHeader{
@ -56,7 +41,7 @@ func examplePrevote() *Vote {
}
func TestVoteSignable(t *testing.T) {
vote := exampleVote()
vote := examplePrecommit()
signBytes := SignBytes("test_chain_id", vote)
signStr := string(signBytes)
@ -73,7 +58,7 @@ func TestVoteString(t *testing.T) {
in string
out string
}{
{"Precommit", exampleVote().String(), `Vote{56789:616464720000 12345/02/2(Precommit) 686173680000 {<nil>} @ 2017-12-25T03:00:01.234Z}`},
{"Precommit", examplePrecommit().String(), `Vote{56789:616464720000 12345/02/2(Precommit) 686173680000 {<nil>} @ 2017-12-25T03:00:01.234Z}`},
{"Prevote", examplePrevote().String(), `Vote{56789:616464720000 12345/02/1(Prevote) 686173680000 {<nil>} @ 2017-12-25T03:00:01.234Z}`},
}
@ -91,7 +76,7 @@ func TestVoteVerifySignature(t *testing.T) {
privVal := GenPrivValidatorFS("")
pubKey := privVal.GetPubKey()
vote := exampleVote()
vote := examplePrecommit()
signBytes := SignBytes("test_chain_id", vote)
// sign it


Loading…
Cancel
Save