aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/crypto_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/crypto_test.go b/core/crypto_test.go
index 0690a32..ccfcebb 100644
--- a/core/crypto_test.go
+++ b/core/crypto_test.go
@@ -191,6 +191,24 @@ func (s *CryptoTestSuite) TestBlockSignature() {
}
}
+func (s *CryptoTestSuite) TestVoteSignature() {
+ prv, err := eth.NewPrivateKey()
+ s.Require().Nil(err)
+ pub := prv.PublicKey()
+ vID := types.NewValidatorID(pub)
+ vote := &types.Vote{
+ ProposerID: vID,
+ Type: types.VoteAck,
+ BlockHash: common.NewRandomHash(),
+ Period: 1,
+ }
+ vote.Signature, err = prv.Sign(hashVote(vote))
+ s.Require().Nil(err)
+ s.True(verifyVoteSignature(vote, eth.SigToPub))
+ vote.Type = types.VoteConfirm
+ s.False(verifyVoteSignature(vote, eth.SigToPub))
+}
+
func TestCrypto(t *testing.T) {
suite.Run(t, new(CryptoTestSuite))
}