Skip to content

Commit

Permalink
print error of test
Browse files Browse the repository at this point in the history
  • Loading branch information
Junlin Gao committed Dec 12, 2019
1 parent 8f7eabb commit 81b11e1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions crypto/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package crypto

import (
"bytes"
"go.uber.org/zap"
"testing"

ledgerPb "github.com/tron-us/go-btfs-common/protos/ledger"
Expand Down Expand Up @@ -61,45 +60,45 @@ func TestEncryptDecrypt(t *testing.T) {
func TestSerializeDeserializeKey(t *testing.T) {
privKey, err := ToPrivKey(KeyString)
if err != nil {
t.Error("ToPrivKey failed", zap.Error(err))
t.Error("ToPrivKey failed", err)
return
}
privKeyString, err := FromPrivKey(privKey)
if err != nil {
t.Error("FromPrivKey failed", zap.Error(err))
t.Error("FromPrivKey failed", err)
return
}
if privKeyString != KeyString {
t.Error("serialize and deserialize private key fail", zap.Error(err))
t.Error("serialize and deserialize private key fail", err)
return
}

pubKey := privKey.GetPublic()
pubKeyString, err := FromPubKey(pubKey)
if err != nil {
t.Error("FromPubKey failed", zap.Error(err))
t.Error("FromPubKey failed", err)
return
}

nPubKey, err := ToPubKey(pubKeyString)
if err != nil {
t.Error("ToPubKey failed", zap.Error(err))
t.Error("ToPubKey failed", err)
return
}

pubkeyRaw, err := pubKey.Raw()
if err != nil {
t.Error("get pubkey raw failed", zap.Error(err))
t.Error("get pubkey raw failed", err)
return
}
nPubkeyRaw, err := nPubKey.Raw()
if err != nil {
t.Error("get PubKey raw failed", zap.Error(err))
t.Error("get PubKey raw failed", err)
return
}

if bytes.Compare(pubkeyRaw, nPubkeyRaw) != 0 {
t.Error("serialize and deserialize pub key fail", zap.Error(err))
t.Error("serialize and deserialize pub key fail", err)
return
}

Expand Down

0 comments on commit 81b11e1

Please sign in to comment.