aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-08-29 11:26:36 +0800
committerGitHub <noreply@github.com>2018-08-29 11:26:36 +0800
commit17bd3b26d85c1d31867427d76ee155fbb9eca860 (patch)
tree92355908b8bbc75af802edae18cf8a64f42dbe8c
parent7b804a5950981324e683085cbbcfee5fa9162f6f (diff)
downloaddexon-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar
dexon-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.gz
dexon-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.bz2
dexon-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.lz
dexon-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.xz
dexon-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.zst
dexon-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.zip
crypto test for vote (#78)
-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))
}