Skip to content

Commit

Permalink
fix review point
Browse files Browse the repository at this point in the history
  • Loading branch information
torao committed Aug 13, 2020
1 parent 6994d02 commit 70cead1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions abci/example/kvstore/helpers.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package kvstore

import (
"github.com/tendermint/tendermint/abci/tests"
"github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/composite"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmtypes "github.com/tendermint/tendermint/types"
)

// RandVal creates one random validator, with a key derived
// from the input value
func RandVal(i int) types.ValidatorUpdate {
pk := composite.GenPrivKey().PubKey()
pk := tests.GenDefaultPrivKey().PubKey()
pubkey := tmtypes.TM2PB.PubKey(pk)
power := tmrand.Uint16() + 1
v := types.NewValidatorUpdate(tmtypes.ABCIPubKeyTypeComposite, pubkey.Data, int64(power))
Expand Down
7 changes: 4 additions & 3 deletions abci/tests/server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"errors"
"fmt"

"github.com/tendermint/tendermint/crypto/composite"
"github.com/tendermint/tendermint/abci/tests"

tmtypes "github.com/tendermint/tendermint/types"

abcicli "github.com/tendermint/tendermint/abci/client"
Expand All @@ -17,10 +18,10 @@ func InitChain(client abcicli.Client) error {
total := 10
vals := make([]types.ValidatorUpdate, total)
for i := 0; i < total; i++ {
pk := composite.GenPrivKey().PubKey()
pk := tests.GenDefaultPrivKey().PubKey()
pubkey := tmtypes.TM2PB.PubKey(pk).Data
power := tmrand.Int()
vals[i] = types.NewValidatorUpdate("composite", pubkey, int64(power))
vals[i] = types.NewValidatorUpdate(tmtypes.ABCIPubKeyTypeComposite, pubkey, int64(power))
}
_, err := client.InitChainSync(types.RequestInitChain{
Validators: vals,
Expand Down
9 changes: 9 additions & 0 deletions abci/tests/tests.go
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
package tests

import (
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/composite"
)

func GenDefaultPrivKey() crypto.PrivKey {
return composite.GenPrivKey()
}
17 changes: 11 additions & 6 deletions crypto/encoding/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package encoding
import (
"testing"

"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"

"github.com/tendermint/tendermint/crypto/bls"
"github.com/tendermint/tendermint/crypto/composite"
"github.com/tendermint/tendermint/crypto/ed25519"
)

func TestPubKeyFromToProto(t *testing.T) {
vrf := ed25519.GenPrivKey()
signer := bls.GenPrivKey()
sk := composite.NewPrivKeyComposite(signer, vrf)
func testPubKeyFromToProto(t *testing.T, sk crypto.PrivKey) {
pk := sk.PubKey()
pbPubKey, err := PubKeyToProto(pk)
if err != nil {
Expand All @@ -26,6 +25,12 @@ func TestPubKeyFromToProto(t *testing.T) {
t.Fatalf("The retrieved public key was not composite key: %+v", pk2)
}
if !cpk.Equals(pk) {
t.Fatalf("The retrieved composite public key was not match: %+v != %+v", cpk, pk)
t.Fatalf("The retrieved public key was not match: %+v != %+v", cpk, pk)
}
}

func TestPubKeyFromToProto(t *testing.T) {
testPubKeyFromToProto(t, ed25519.GenPrivKey())
testPubKeyFromToProto(t, bls.GenPrivKey())
testPubKeyFromToProto(t, composite.NewPrivKeyComposite(bls.GenPrivKey(), ed25519.GenPrivKey()))
}
3 changes: 0 additions & 3 deletions types/priv_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ func NewMockPVWithParams(privKey crypto.PrivKey, breakProposalSigning, breakVote

// Implements PrivValidator.
func (pv MockPV) GetPubKey() (crypto.PubKey, error) {
//signKey := bls.GenPrivKey()
//vrfKey := ed25519.GenPrivKey()
//return composite.NewPrivKeyComposite(signKey, vrfKey).PubKey(), nil
return pv.PrivKey.PubKey(), nil
}

Expand Down

0 comments on commit 70cead1

Please sign in to comment.