aboutsummaryrefslogtreecommitdiffstats
path: root/core/crypto_test.go
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 /core/crypto_test.go
parent7b804a5950981324e683085cbbcfee5fa9162f6f (diff)
downloadtangerine-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar
tangerine-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.gz
tangerine-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.bz2
tangerine-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.lz
tangerine-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.xz
tangerine-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.tar.zst
tangerine-consensus-17bd3b26d85c1d31867427d76ee155fbb9eca860.zip
crypto test for vote (#78)
Diffstat (limited to 'core/crypto_test.go')
-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))
}