Browse Source

types: Add test for IsVoteTypeValid

pull/996/head
Ricardo Domingos 7 years ago
parent
commit
d5baa6601c
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      types/vote_test.go

+ 21
- 0
types/vote_test.go 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)
}
})
}
}

Loading…
Cancel
Save