privval: return error on getpubkey (#4534)

closes #3602

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
This commit is contained in:
Marko
2020-03-12 08:10:36 +01:00
committed by GitHub
parent 038aff1fdb
commit 48f073d796
30 changed files with 501 additions and 216 deletions

View File

@@ -190,9 +190,17 @@ func (th *TestHarness) Run() {
// local Tendermint version.
func (th *TestHarness) TestPublicKey() error {
th.logger.Info("TEST: Public key of remote signer")
th.logger.Info("Local", "pubKey", th.fpv.GetPubKey())
th.logger.Info("Remote", "pubKey", th.signerClient.GetPubKey())
if th.fpv.GetPubKey() != th.signerClient.GetPubKey() {
fpvk, err := th.fpv.GetPubKey()
if err != nil {
return err
}
th.logger.Info("Local", "pubKey", fpvk)
sck, err := th.signerClient.GetPubKey()
if err != nil {
return err
}
th.logger.Info("Remote", "pubKey", sck)
if fpvk != sck {
th.logger.Error("FAILED: Local and remote public keys do not match")
return newTestHarnessError(ErrTestPublicKeyFailed, nil, "")
}
@@ -230,8 +238,12 @@ func (th *TestHarness) TestSignProposal() error {
th.logger.Error("FAILED: Signed proposal is invalid", "err", err)
return newTestHarnessError(ErrTestSignProposalFailed, err, "")
}
sck, err := th.signerClient.GetPubKey()
if err != nil {
return err
}
// now validate the signature on the proposal
if th.signerClient.GetPubKey().VerifyBytes(propBytes, prop.Signature) {
if sck.VerifyBytes(propBytes, prop.Signature) {
th.logger.Info("Successfully validated proposal signature")
} else {
th.logger.Error("FAILED: Proposal signature validation failed")
@@ -274,8 +286,13 @@ func (th *TestHarness) TestSignVote() error {
th.logger.Error("FAILED: Signed vote is invalid", "err", err)
return newTestHarnessError(ErrTestSignVoteFailed, err, fmt.Sprintf("voteType=%d", voteType))
}
sck, err := th.signerClient.GetPubKey()
if err != nil {
return err
}
// now validate the signature on the proposal
if th.signerClient.GetPubKey().VerifyBytes(voteBytes, vote.Signature) {
if sck.VerifyBytes(voteBytes, vote.Signature) {
th.logger.Info("Successfully validated vote signature", "type", voteType)
} else {
th.logger.Error("FAILED: Vote signature validation failed", "type", voteType)