types: Add test for IsVoteTypeValid

This commit is contained in:
Ricardo Domingos 2017-12-21 17:33:47 +01:00
parent 19eeef0aad
commit d5baa6601c
1 changed files with 21 additions and 0 deletions

View File

@ -99,3 +99,24 @@ func TestVoteVerifySignature(t *testing.T) {
valid = pubKey.VerifyBytes(newSignBytes, signature)
require.True(t, valid)
}
func TestIsVoteTypeValid(t *testing.T) {
tc := []struct {
name string
in byte
out bool
}{
{"Prevote", VoteTypePrevote, true},
{"Precommit", VoteTypePrecommit, true},
{"InvalidType", byte(3), false},
}
for _, tt := range tc {
tt := tt
t.Run(tt.name, func(st *testing.T) {
if rs := IsVoteTypeValid(tt.in); rs != tt.out {
t.Errorf("Got unexpected Vote type. Expected:\n%v\nGot:\n%v", rs, tt.out)
}
})
}
}