Skip to content

Commit

Permalink
Merge pull request #149 from kokeshiM0chi/develop
Browse files Browse the repository at this point in the history
fix: typo about variable names that select the type of private key
  • Loading branch information
Kynea0b authored Dec 18, 2020
2 parents 112f943 + 3f72183 commit 034541a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ jobs:
# Build Tendermint
make build-linux
# Build contract-tests
docker run --rm -v "$PWD":/go/src/github.com/tendermint/tendermint -w /go/src/github.com/tendermint/tendermint ubuntu:19.10 ./scripts/prepare_dredd_test.sh
docker run --rm -v "$PWD":/go/src/github.com/tendermint/tendermint -w /go/src/github.com/tendermint/tendermint ubuntu:20.04 ./scripts/prepare_dredd_test.sh
# This docker image works with go 1.7, we can install here the hook handler that contract-tests is going to use
go get github.com/snikch/goodman/cmd/goodman
make contract-tests
Expand Down
2 changes: 1 addition & 1 deletion cmd/tendermint/commands/gen_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var GenValidatorCmd = &cobra.Command{
}

func genValidator(cmd *cobra.Command, args []string) {
pv, _ := privval.GenFilePV("", "", privval.PrevKeyTypeEd25519)
pv, _ := privval.GenFilePV("", "", privval.PrivKeyTypeEd25519)
jsbz, err := cdc.MarshalJSON(pv)
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/tendermint/commands/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func init() {
"P2P Port")
TestnetFilesCmd.Flags().BoolVar(&randomMonikers, "random-monikers", false,
"Randomize the moniker for each generated node")
TestnetFilesCmd.Flags().StringVar(&privKeyType, "priv_key_type", privval.PrevKeyTypeEd25519,
TestnetFilesCmd.Flags().StringVar(&privKeyType, "priv_key_type", privval.PrivKeyTypeEd25519,
"Specify validator's private key type (ed25519 | composite)")
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func DefaultBaseConfig() BaseConfig {
FilterPeers: false,
DBBackend: "goleveldb",
DBPath: "data",
PrivKeyType: privval.PrevKeyTypeEd25519,
PrivKeyType: privval.PrivKeyTypeEd25519,
}
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ func randConsensusNetWithPeers(
panic(err)
}

privVal, _ = privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), privval.PrevKeyTypeEd25519)
privVal, _ = privval.GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), privval.PrivKeyTypeEd25519)
}

app := appFunc(path.Join(config.DBDir(), fmt.Sprintf("%s_%d", testName, i)))
Expand Down
8 changes: 4 additions & 4 deletions privval/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const (
)

const (
PrevKeyTypeEd25519 string = "ed25519"
PrevKeyTypeComposite string = "composite"
PrivKeyTypeEd25519 string = "ed25519"
PrivKeyTypeComposite string = "composite"
)

// A vote is either stepPrevote or stepPrecommit.
Expand Down Expand Up @@ -160,9 +160,9 @@ type FilePV struct {
func GenFilePV(keyFilePath, stateFilePath, privKeyType string) (filePV *FilePV, err error) {
var privKey crypto.PrivKey
switch strings.ToLower(privKeyType) {
case PrevKeyTypeEd25519:
case PrivKeyTypeEd25519:
privKey = ed25519.GenPrivKey()
case PrevKeyTypeComposite:
case PrivKeyTypeComposite:
privKey = composite.NewPrivKeyComposite(bls.GenPrivKey(), ed25519.GenPrivKey())
default:
return nil, fmt.Errorf("undefined private key type: %s", privKeyType)
Expand Down
16 changes: 8 additions & 8 deletions privval/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestGenLoadValidator(t *testing.T) {
tempStateFile, err := ioutil.TempFile("", "priv_validator_state_")
require.Nil(t, err)

privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrevKeyTypeEd25519)
privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrivKeyTypeEd25519)
require.Nil(t, err)

height := int64(100)
Expand All @@ -44,7 +44,7 @@ func TestResetValidator(t *testing.T) {
tempStateFile, err := ioutil.TempFile("", "priv_validator_state_")
require.Nil(t, err)

privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrevKeyTypeEd25519)
privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrivKeyTypeEd25519)
require.Nil(t, err)

emptyState := FilePVLastSignState{filePath: tempStateFile.Name()}
Expand Down Expand Up @@ -85,11 +85,11 @@ func TestLoadOrGenValidator(t *testing.T) {
t.Error(err)
}

privVal, err := LoadOrGenFilePV(tempKeyFilePath, tempStateFilePath, PrevKeyTypeEd25519)
privVal, err := LoadOrGenFilePV(tempKeyFilePath, tempStateFilePath, PrivKeyTypeEd25519)
require.Nil(t, err)

addr := privVal.GetAddress()
privVal, err = LoadOrGenFilePV(tempKeyFilePath, tempStateFilePath, PrevKeyTypeEd25519)
privVal, err = LoadOrGenFilePV(tempKeyFilePath, tempStateFilePath, PrivKeyTypeEd25519)
require.Nil(t, err)

assert.Equal(addr, privVal.GetAddress(), "expected privval addr to be the same")
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestSignVote(t *testing.T) {
tempStateFile, err := ioutil.TempFile("", "priv_validator_state_")
require.Nil(t, err)

privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrevKeyTypeEd25519)
privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrivKeyTypeEd25519)
require.Nil(t, err)

block1 := types.BlockID{Hash: []byte{1, 2, 3}, PartsHeader: types.PartSetHeader{}}
Expand Down Expand Up @@ -216,7 +216,7 @@ func TestSignProposal(t *testing.T) {
tempStateFile, err := ioutil.TempFile("", "priv_validator_state_")
require.Nil(t, err)

privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrevKeyTypeEd25519)
privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrivKeyTypeEd25519)
require.Nil(t, err)

block1 := types.BlockID{Hash: []byte{1, 2, 3}, PartsHeader: types.PartSetHeader{Total: 5, Hash: []byte{1, 2, 3}}}
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestGenerateVRFProof(t *testing.T) {
tempStateFile, err := ioutil.TempFile("", "priv_validator_state_")
require.Nil(t, err)

privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrevKeyTypeEd25519)
privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrivKeyTypeEd25519)
require.Nil(t, err)

success := [][]byte{{}, {0x00}, make([]byte, 100)}
Expand All @@ -279,7 +279,7 @@ func TestDifferByTimestamp(t *testing.T) {
tempStateFile, err := ioutil.TempFile("", "priv_validator_state_")
require.Nil(t, err)

privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrevKeyTypeEd25519)
privVal, err := GenFilePV(tempKeyFile.Name(), tempStateFile.Name(), PrivKeyTypeEd25519)
require.Nil(t, err)

block1 := types.BlockID{Hash: []byte{1, 2, 3}, PartsHeader: types.PartSetHeader{Total: 5, Hash: []byte{1, 2, 3}}}
Expand Down

0 comments on commit 034541a

Please sign in to comment.