Skip to content

Commit

Permalink
fix code that may be relevant from Finschia#335 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
torao committed Jan 13, 2023
1 parent 027d481 commit fcdaa82
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 119 deletions.
13 changes: 0 additions & 13 deletions abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,6 @@ func (app *PersistentKVStoreApplication) Query(reqQuery types.RequestQuery) (res

resQuery.Key = reqQuery.Data
resQuery.Value = value

if value == nil {
resQuery.Log = "cannot get"
return
}
validatorUpdate := types.ValidatorUpdate{}
err = types.ReadMessage(bytes.NewReader(resQuery.Value), &validatorUpdate)
if err != nil {
panic(err)
}
pubKey, _ := cryptoenc.PubKeyFromProto(&validatorUpdate.PubKey)
resQuery.Log = fmt.Sprintf("key=%s, validatorUpdate.PubKey=%v, validatorUpdate.Power=%d",
resQuery.Key, pubKey, validatorUpdate.Power)
return
default:
return app.app.Query(reqQuery)
Expand Down
50 changes: 0 additions & 50 deletions abci/example/kvstore/tool/make_val_set_change_tx.go

This file was deleted.

32 changes: 0 additions & 32 deletions abci/example/kvstore/tool/make_val_set_change_tx.sh

This file was deleted.

34 changes: 19 additions & 15 deletions privval/file_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package privval

import (
"encoding/base64"
"encoding/hex"
"fmt"
"io/ioutil"
Expand All @@ -11,7 +12,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/line/ostracon/crypto"
"github.com/line/ostracon/crypto/ed25519"
"github.com/line/ostracon/crypto/tmhash"
tmjson "github.com/line/ostracon/libs/json"
Expand All @@ -21,18 +21,6 @@ import (
tmtime "github.com/line/ostracon/types/time"
)

var jsonKey = func(t *testing.T, addr crypto.Address, privKey crypto.PrivKey, pubKey crypto.PubKey) string {
privKeyBytes, err := tmjson.MarshalIndent(privKey, " ", " ")
assert.Nil(t, err)
pubKeyBytes, err := tmjson.MarshalIndent(pubKey, " ", " ")
assert.Nil(t, err)
return fmt.Sprintf(`{
"address": "%s",
"pub_key": %s,
"priv_key": %s
}`, addr, pubKeyBytes, privKeyBytes)
}

func TestGenFilePV(t *testing.T) {
tempKeyFile, err := ioutil.TempFile("", "priv_validator_key_")
require.Nil(t, err)
Expand All @@ -53,6 +41,7 @@ func TestGenLoadValidator(t *testing.T) {
require.Nil(t, err)

privVal := GenFilePV(tempKeyFile.Name(), tempStateFile.Name())

height := int64(100)
privVal.LastSignState.Height = height
privVal.Save()
Expand Down Expand Up @@ -147,8 +136,22 @@ func TestUnmarshalValidatorKey(t *testing.T) {
privKey := ed25519.GenPrivKey()
pubKey := privKey.PubKey()
addr := pubKey.Address()
pubBytes := pubKey.Bytes()
privBytes := privKey.Bytes()
pubB64 := base64.StdEncoding.EncodeToString(pubBytes)
privB64 := base64.StdEncoding.EncodeToString(privBytes)

serialized := jsonKey(t, addr, privKey, pubKey)
serialized := fmt.Sprintf(`{
"address": "%s",
"pub_key": {
"type": "tendermint/PubKeyEd25519",
"value": "%s"
},
"priv_key": {
"type": "tendermint/PrivKeyEd25519",
"value": "%s"
}
}`, addr, pubB64, privB64)

val := FilePVKey{}
err := tmjson.Unmarshal([]byte(serialized), &val)
Expand All @@ -174,6 +177,7 @@ func TestSignVote(t *testing.T) {
require.Nil(t, err)

privVal := GenFilePV(tempKeyFile.Name(), tempStateFile.Name())

randbytes := tmrand.Bytes(tmhash.Size)
randbytes2 := tmrand.Bytes(tmhash.Size)

Expand Down Expand Up @@ -226,6 +230,7 @@ func TestSignProposal(t *testing.T) {
require.Nil(t, err)

privVal := GenFilePV(tempKeyFile.Name(), tempStateFile.Name())

randbytes := tmrand.Bytes(tmhash.Size)
randbytes2 := tmrand.Bytes(tmhash.Size)

Expand Down Expand Up @@ -293,7 +298,6 @@ func TestDifferByTimestamp(t *testing.T) {
require.Nil(t, err)

privVal := GenFilePV(tempKeyFile.Name(), tempStateFile.Name())
require.Nil(t, err)
randbytes := tmrand.Bytes(tmhash.Size)
block1 := types.BlockID{Hash: randbytes, PartSetHeader: types.PartSetHeader{Total: 5, Hash: randbytes}}
height, round := int64(10), int32(1)
Expand Down
10 changes: 1 addition & 9 deletions types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,14 +836,6 @@ func NewCommit(height int64, round int32, blockID BlockID, commitSigs []CommitSi
}
}

const (
CommitHeighMaxtLen = 11
CommitRoundMaxLen = 6
CommitBlockIDMaxLen = 76
CommitAminoOverhead = 1
CommitAggrSigOverhead = 2
)

// CommitToVoteSet constructs a VoteSet from the Commit and validator set.
// Panics if signatures from the commit can't be added to the voteset.
// Inverse of VoteSet.MakeCommit().
Expand All @@ -855,7 +847,7 @@ func CommitToVoteSet(chainID string, commit *Commit, voters *VoterSet) *VoteSet
}
added, err := voteSet.AddVote(commit.GetVote(int32(idx)))
if !added || err != nil {
panic(fmt.Sprintf("Failedd to reconstruct LastCommit: %v", err))
panic(fmt.Sprintf("Failed to reconstruct LastCommit: %v", err))
}
}
return voteSet
Expand Down

0 comments on commit fcdaa82

Please sign in to comment.