types: Rename exampleVote to examplePrecommit on vote_test
exampleVote doesn't express the type of the vote.
This commit is contained in:
parent
e76392e330
commit
19eeef0aad
|
@ -9,30 +9,15 @@ import (
|
||||||
wire "github.com/tendermint/go-wire"
|
wire "github.com/tendermint/go-wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
func exampleVote() *Vote {
|
func examplePrevote() *Vote {
|
||||||
var stamp, err = time.Parse(timeFormat, "2017-12-25T03:00:01.234Z")
|
return exampleVote(VoteTypePrevote)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
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 examplePrevote() *Vote {
|
func examplePrecommit() *Vote {
|
||||||
|
return exampleVote(VoteTypePrecommit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func exampleVote(t byte) *Vote {
|
||||||
var stamp, err = time.Parse(timeFormat, "2017-12-25T03:00:01.234Z")
|
var stamp, err = time.Parse(timeFormat, "2017-12-25T03:00:01.234Z")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -44,7 +29,7 @@ func examplePrevote() *Vote {
|
||||||
Height: 12345,
|
Height: 12345,
|
||||||
Round: 2,
|
Round: 2,
|
||||||
Timestamp: stamp,
|
Timestamp: stamp,
|
||||||
Type: byte(1),
|
Type: t,
|
||||||
BlockID: BlockID{
|
BlockID: BlockID{
|
||||||
Hash: []byte("hash"),
|
Hash: []byte("hash"),
|
||||||
PartsHeader: PartSetHeader{
|
PartsHeader: PartSetHeader{
|
||||||
|
@ -56,7 +41,7 @@ func examplePrevote() *Vote {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVoteSignable(t *testing.T) {
|
func TestVoteSignable(t *testing.T) {
|
||||||
vote := exampleVote()
|
vote := examplePrecommit()
|
||||||
signBytes := SignBytes("test_chain_id", vote)
|
signBytes := SignBytes("test_chain_id", vote)
|
||||||
signStr := string(signBytes)
|
signStr := string(signBytes)
|
||||||
|
|
||||||
|
@ -73,7 +58,7 @@ func TestVoteString(t *testing.T) {
|
||||||
in string
|
in string
|
||||||
out 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}`},
|
{"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("")
|
privVal := GenPrivValidatorFS("")
|
||||||
pubKey := privVal.GetPubKey()
|
pubKey := privVal.GetPubKey()
|
||||||
|
|
||||||
vote := exampleVote()
|
vote := examplePrecommit()
|
||||||
signBytes := SignBytes("test_chain_id", vote)
|
signBytes := SignBytes("test_chain_id", vote)
|
||||||
|
|
||||||
// sign it
|
// sign it
|
||||||
|
|
Loading…
Reference in New Issue