|
|
@ -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) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |