Browse Source

rename privval#GetAddress and GetPubKey to Address and PubKey

pull/1936/head
Anton Kaliaev 6 years ago
parent
commit
ff8ddee708
No known key found for this signature in database GPG Key ID: 7B6881D965918214
23 changed files with 121 additions and 119 deletions
  1. +1
    -1
      cmd/tendermint/commands/init.go
  2. +2
    -1
      cmd/tendermint/commands/show_validator.go
  3. +1
    -1
      cmd/tendermint/commands/testnet.go
  4. +4
    -4
      consensus/common_test.go
  5. +7
    -7
      consensus/reactor_test.go
  6. +3
    -3
      consensus/replay_test.go
  7. +7
    -7
      consensus/state.go
  8. +9
    -9
      consensus/state_test.go
  9. +1
    -1
      consensus/types/height_vote_set_test.go
  10. +5
    -5
      node/node.go
  11. +13
    -13
      privval/priv_validator.go
  12. +13
    -13
      privval/priv_validator_test.go
  13. +5
    -5
      privval/socket.go
  14. +4
    -4
      privval/socket_test.go
  15. +3
    -3
      scripts/wire2amino.go
  16. +2
    -2
      types/evidence_test.go
  17. +6
    -6
      types/priv_validator.go
  18. +2
    -2
      types/proposal_test.go
  19. +2
    -2
      types/protobuf_test.go
  20. +1
    -1
      types/test_util.go
  21. +2
    -1
      types/validator.go
  22. +27
    -27
      types/vote_set_test.go
  23. +1
    -1
      types/vote_test.go

+ 1
- 1
cmd/tendermint/commands/init.go View File

@ -57,7 +57,7 @@ func initFilesWithConfig(config *cfg.Config) error {
ConsensusParams: types.DefaultConsensusParams(), ConsensusParams: types.DefaultConsensusParams(),
} }
genDoc.Validators = []types.GenesisValidator{{ genDoc.Validators = []types.GenesisValidator{{
PubKey: pv.GetPubKey(),
PubKey: pv.PubKey(),
Power: 10, Power: 10,
}} }}


+ 2
- 1
cmd/tendermint/commands/show_validator.go View File

@ -17,6 +17,7 @@ var ShowValidatorCmd = &cobra.Command{
func showValidator(cmd *cobra.Command, args []string) { func showValidator(cmd *cobra.Command, args []string) {
privValidator := privval.LoadOrGenFilePV(config.PrivValidatorFile()) privValidator := privval.LoadOrGenFilePV(config.PrivValidatorFile())
pubKeyJSONBytes, _ := cdc.MarshalJSON(privValidator.GetPubKey())
pubKeyJSONBytes, _ := cdc.MarshalJSON(privValidator.PubKey())
fmt.Println(string(pubKeyJSONBytes)) fmt.Println(string(pubKeyJSONBytes))
} }

+ 1
- 1
cmd/tendermint/commands/testnet.go View File

@ -91,7 +91,7 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
pvFile := filepath.Join(nodeDir, config.BaseConfig.PrivValidator) pvFile := filepath.Join(nodeDir, config.BaseConfig.PrivValidator)
pv := privval.LoadFilePV(pvFile) pv := privval.LoadFilePV(pvFile)
genVals[i] = types.GenesisValidator{ genVals[i] = types.GenesisValidator{
PubKey: pv.GetPubKey(),
PubKey: pv.PubKey(),
Power: 1, Power: 1,
Name: nodeDirName, Name: nodeDirName,
} }


+ 4
- 4
consensus/common_test.go View File

@ -72,7 +72,7 @@ func NewValidatorStub(privValidator types.PrivValidator, valIndex int) *validato
func (vs *validatorStub) signVote(voteType byte, hash []byte, header types.PartSetHeader) (*types.Vote, error) { func (vs *validatorStub) signVote(voteType byte, hash []byte, header types.PartSetHeader) (*types.Vote, error) {
vote := &types.Vote{ vote := &types.Vote{
ValidatorIndex: vs.Index, ValidatorIndex: vs.Index,
ValidatorAddress: vs.PrivValidator.GetAddress(),
ValidatorAddress: vs.PrivValidator.Address(),
Height: vs.Height, Height: vs.Height,
Round: vs.Round, Round: vs.Round,
Timestamp: time.Now().UTC(), Timestamp: time.Now().UTC(),
@ -150,7 +150,7 @@ func signAddVotes(to *ConsensusState, voteType byte, hash []byte, header types.P
func validatePrevote(t *testing.T, cs *ConsensusState, round int, privVal *validatorStub, blockHash []byte) { func validatePrevote(t *testing.T, cs *ConsensusState, round int, privVal *validatorStub, blockHash []byte) {
prevotes := cs.Votes.Prevotes(round) prevotes := cs.Votes.Prevotes(round)
var vote *types.Vote var vote *types.Vote
if vote = prevotes.GetByAddress(privVal.GetAddress()); vote == nil {
if vote = prevotes.GetByAddress(privVal.Address()); vote == nil {
panic("Failed to find prevote from validator") panic("Failed to find prevote from validator")
} }
if blockHash == nil { if blockHash == nil {
@ -167,7 +167,7 @@ func validatePrevote(t *testing.T, cs *ConsensusState, round int, privVal *valid
func validateLastPrecommit(t *testing.T, cs *ConsensusState, privVal *validatorStub, blockHash []byte) { func validateLastPrecommit(t *testing.T, cs *ConsensusState, privVal *validatorStub, blockHash []byte) {
votes := cs.LastCommit votes := cs.LastCommit
var vote *types.Vote var vote *types.Vote
if vote = votes.GetByAddress(privVal.GetAddress()); vote == nil {
if vote = votes.GetByAddress(privVal.Address()); vote == nil {
panic("Failed to find precommit from validator") panic("Failed to find precommit from validator")
} }
if !bytes.Equal(vote.BlockID.Hash, blockHash) { if !bytes.Equal(vote.BlockID.Hash, blockHash) {
@ -178,7 +178,7 @@ func validateLastPrecommit(t *testing.T, cs *ConsensusState, privVal *validatorS
func validatePrecommit(t *testing.T, cs *ConsensusState, thisRound, lockRound int, privVal *validatorStub, votedBlockHash, lockedBlockHash []byte) { func validatePrecommit(t *testing.T, cs *ConsensusState, thisRound, lockRound int, privVal *validatorStub, votedBlockHash, lockedBlockHash []byte) {
precommits := cs.Votes.Precommits(thisRound) precommits := cs.Votes.Precommits(thisRound)
var vote *types.Vote var vote *types.Vote
if vote = precommits.GetByAddress(privVal.GetAddress()); vote == nil {
if vote = precommits.GetByAddress(privVal.Address()); vote == nil {
panic("Failed to find precommit from validator") panic("Failed to find precommit from validator")
} }


+ 7
- 7
consensus/reactor_test.go View File

@ -242,7 +242,7 @@ func TestReactorVotingPowerChange(t *testing.T) {
// map of active validators // map of active validators
activeVals := make(map[string]struct{}) activeVals := make(map[string]struct{})
for i := 0; i < nVals; i++ { for i := 0; i < nVals; i++ {
activeVals[string(css[i].privValidator.GetAddress())] = struct{}{}
activeVals[string(css[i].privValidator.Address())] = struct{}{}
} }
// wait till everyone makes block 1 // wait till everyone makes block 1
@ -253,7 +253,7 @@ func TestReactorVotingPowerChange(t *testing.T) {
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
logger.Debug("---------------------------- Testing changing the voting power of one validator a few times") logger.Debug("---------------------------- Testing changing the voting power of one validator a few times")
val1PubKey := css[0].privValidator.GetPubKey()
val1PubKey := css[0].privValidator.PubKey()
val1PubKeyABCI := types.TM2PB.PubKey(val1PubKey) val1PubKeyABCI := types.TM2PB.PubKey(val1PubKey)
updateValidatorTx := kvstore.MakeValSetChangeTx(val1PubKeyABCI, 25) updateValidatorTx := kvstore.MakeValSetChangeTx(val1PubKeyABCI, 25)
previousTotalVotingPower := css[0].GetRoundState().LastValidators.TotalVotingPower() previousTotalVotingPower := css[0].GetRoundState().LastValidators.TotalVotingPower()
@ -305,7 +305,7 @@ func TestReactorValidatorSetChanges(t *testing.T) {
// map of active validators // map of active validators
activeVals := make(map[string]struct{}) activeVals := make(map[string]struct{})
for i := 0; i < nVals; i++ { for i := 0; i < nVals; i++ {
activeVals[string(css[i].privValidator.GetAddress())] = struct{}{}
activeVals[string(css[i].privValidator.Address())] = struct{}{}
} }
// wait till everyone makes block 1 // wait till everyone makes block 1
@ -316,7 +316,7 @@ func TestReactorValidatorSetChanges(t *testing.T) {
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
logger.Info("---------------------------- Testing adding one validator") logger.Info("---------------------------- Testing adding one validator")
newValidatorPubKey1 := css[nVals].privValidator.GetPubKey()
newValidatorPubKey1 := css[nVals].privValidator.PubKey()
valPubKey1ABCI := types.TM2PB.PubKey(newValidatorPubKey1) valPubKey1ABCI := types.TM2PB.PubKey(newValidatorPubKey1)
newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower) newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower)
@ -343,7 +343,7 @@ func TestReactorValidatorSetChanges(t *testing.T) {
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
logger.Info("---------------------------- Testing changing the voting power of one validator") logger.Info("---------------------------- Testing changing the voting power of one validator")
updateValidatorPubKey1 := css[nVals].privValidator.GetPubKey()
updateValidatorPubKey1 := css[nVals].privValidator.PubKey()
updatePubKey1ABCI := types.TM2PB.PubKey(updateValidatorPubKey1) updatePubKey1ABCI := types.TM2PB.PubKey(updateValidatorPubKey1)
updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25) updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25)
previousTotalVotingPower := css[nVals].GetRoundState().LastValidators.TotalVotingPower() previousTotalVotingPower := css[nVals].GetRoundState().LastValidators.TotalVotingPower()
@ -360,11 +360,11 @@ func TestReactorValidatorSetChanges(t *testing.T) {
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
logger.Info("---------------------------- Testing adding two validators at once") logger.Info("---------------------------- Testing adding two validators at once")
newValidatorPubKey2 := css[nVals+1].privValidator.GetPubKey()
newValidatorPubKey2 := css[nVals+1].privValidator.PubKey()
newVal2ABCI := types.TM2PB.PubKey(newValidatorPubKey2) newVal2ABCI := types.TM2PB.PubKey(newValidatorPubKey2)
newValidatorTx2 := kvstore.MakeValSetChangeTx(newVal2ABCI, testMinPower) newValidatorTx2 := kvstore.MakeValSetChangeTx(newVal2ABCI, testMinPower)
newValidatorPubKey3 := css[nVals+2].privValidator.GetPubKey()
newValidatorPubKey3 := css[nVals+2].privValidator.PubKey()
newVal3ABCI := types.TM2PB.PubKey(newValidatorPubKey3) newVal3ABCI := types.TM2PB.PubKey(newValidatorPubKey3)
newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower) newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower)


+ 3
- 3
consensus/replay_test.go View File

@ -347,7 +347,7 @@ func testHandshakeReplay(t *testing.T, nBlocks int, mode uint) {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
stateDB, state, store := stateAndStore(config, privVal.GetPubKey())
stateDB, state, store := stateAndStore(config, privVal.PubKey())
store.chain = chain store.chain = chain
store.commits = commits store.commits = commits
@ -362,7 +362,7 @@ func testHandshakeReplay(t *testing.T, nBlocks int, mode uint) {
// run nBlocks against a new client to build up the app state. // run nBlocks against a new client to build up the app state.
// use a throwaway tendermint state // use a throwaway tendermint state
proxyApp := proxy.NewAppConns(clientCreator2, nil) proxyApp := proxy.NewAppConns(clientCreator2, nil)
stateDB, state, _ := stateAndStore(config, privVal.GetPubKey())
stateDB, state, _ := stateAndStore(config, privVal.PubKey())
buildAppStateFromChain(proxyApp, stateDB, state, chain, nBlocks, mode) buildAppStateFromChain(proxyApp, stateDB, state, chain, nBlocks, mode)
} }
@ -646,7 +646,7 @@ func TestInitChainUpdateValidators(t *testing.T) {
config := ResetConfig("proxy_test_") config := ResetConfig("proxy_test_")
privVal := privval.LoadFilePV(config.PrivValidatorFile()) privVal := privval.LoadFilePV(config.PrivValidatorFile())
stateDB, state, store := stateAndStore(config, privVal.GetPubKey())
stateDB, state, store := stateAndStore(config, privVal.PubKey())
oldValAddr := state.Validators.Validators[0].Address oldValAddr := state.Validators.Validators[0].Address


+ 7
- 7
consensus/state.go View File

@ -768,7 +768,7 @@ func (cs *ConsensusState) needProofBlock(height int64) bool {
func (cs *ConsensusState) proposalHeartbeat(height int64, round int) { func (cs *ConsensusState) proposalHeartbeat(height int64, round int) {
counter := 0 counter := 0
addr := cs.privValidator.GetAddress()
addr := cs.privValidator.Address()
valIndex, _ := cs.Validators.GetByAddress(addr) valIndex, _ := cs.Validators.GetByAddress(addr)
chainID := cs.state.ChainID chainID := cs.state.ChainID
for { for {
@ -827,8 +827,8 @@ func (cs *ConsensusState) enterPropose(height int64, round int) {
} }
// if not a validator, we're done // if not a validator, we're done
if !cs.Validators.HasAddress(cs.privValidator.GetAddress()) {
logger.Debug("This node is not a validator", "addr", cs.privValidator.GetAddress(), "vals", cs.Validators)
if !cs.Validators.HasAddress(cs.privValidator.Address()) {
logger.Debug("This node is not a validator", "addr", cs.privValidator.Address(), "vals", cs.Validators)
return return
} }
logger.Debug("This node is a validator") logger.Debug("This node is a validator")
@ -842,7 +842,7 @@ func (cs *ConsensusState) enterPropose(height int64, round int) {
} }
func (cs *ConsensusState) isProposer() bool { func (cs *ConsensusState) isProposer() bool {
return bytes.Equal(cs.Validators.GetProposer().Address, cs.privValidator.GetAddress())
return bytes.Equal(cs.Validators.GetProposer().Address, cs.privValidator.Address())
} }
func (cs *ConsensusState) defaultDecideProposal(height int64, round int) { func (cs *ConsensusState) defaultDecideProposal(height int64, round int) {
@ -1463,7 +1463,7 @@ func (cs *ConsensusState) tryAddVote(vote *types.Vote, peerID p2p.ID) error {
if err == ErrVoteHeightMismatch { if err == ErrVoteHeightMismatch {
return err return err
} else if voteErr, ok := err.(*types.ErrVoteConflictingVotes); ok { } else if voteErr, ok := err.(*types.ErrVoteConflictingVotes); ok {
if bytes.Equal(vote.ValidatorAddress, cs.privValidator.GetAddress()) {
if bytes.Equal(vote.ValidatorAddress, cs.privValidator.Address()) {
cs.Logger.Error("Found conflicting vote from ourselves. Did you unsafe_reset a validator?", "height", vote.Height, "round", vote.Round, "type", vote.Type) cs.Logger.Error("Found conflicting vote from ourselves. Did you unsafe_reset a validator?", "height", vote.Height, "round", vote.Round, "type", vote.Type)
return err return err
} }
@ -1620,7 +1620,7 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
} }
func (cs *ConsensusState) signVote(type_ byte, hash []byte, header types.PartSetHeader) (*types.Vote, error) { func (cs *ConsensusState) signVote(type_ byte, hash []byte, header types.PartSetHeader) (*types.Vote, error) {
addr := cs.privValidator.GetAddress()
addr := cs.privValidator.Address()
valIndex, _ := cs.Validators.GetByAddress(addr) valIndex, _ := cs.Validators.GetByAddress(addr)
vote := &types.Vote{ vote := &types.Vote{
ValidatorAddress: addr, ValidatorAddress: addr,
@ -1638,7 +1638,7 @@ func (cs *ConsensusState) signVote(type_ byte, hash []byte, header types.PartSet
// sign the vote and publish on internalMsgQueue // sign the vote and publish on internalMsgQueue
func (cs *ConsensusState) signAddVote(type_ byte, hash []byte, header types.PartSetHeader) *types.Vote { func (cs *ConsensusState) signAddVote(type_ byte, hash []byte, header types.PartSetHeader) *types.Vote {
// if we don't have a key or we're not in the validator set, do nothing // if we don't have a key or we're not in the validator set, do nothing
if cs.privValidator == nil || !cs.Validators.HasAddress(cs.privValidator.GetAddress()) {
if cs.privValidator == nil || !cs.Validators.HasAddress(cs.privValidator.Address()) {
return nil return nil
} }
vote, err := cs.signVote(type_, hash, header) vote, err := cs.signVote(type_, hash, header)


+ 9
- 9
consensus/state_test.go View File

@ -69,7 +69,7 @@ func TestStateProposerSelection0(t *testing.T) {
// lets commit a block and ensure proposer for the next height is correct // lets commit a block and ensure proposer for the next height is correct
prop := cs1.GetRoundState().Validators.GetProposer() prop := cs1.GetRoundState().Validators.GetProposer()
if !bytes.Equal(prop.Address, cs1.privValidator.GetAddress()) {
if !bytes.Equal(prop.Address, cs1.privValidator.Address()) {
t.Fatalf("expected proposer to be validator %d. Got %X", 0, prop.Address) t.Fatalf("expected proposer to be validator %d. Got %X", 0, prop.Address)
} }
@ -83,7 +83,7 @@ func TestStateProposerSelection0(t *testing.T) {
<-newRoundCh <-newRoundCh
prop = cs1.GetRoundState().Validators.GetProposer() prop = cs1.GetRoundState().Validators.GetProposer()
if !bytes.Equal(prop.Address, vss[1].GetAddress()) {
if !bytes.Equal(prop.Address, vss[1].Address()) {
panic(cmn.Fmt("expected proposer to be validator %d. Got %X", 1, prop.Address)) panic(cmn.Fmt("expected proposer to be validator %d. Got %X", 1, prop.Address))
} }
} }
@ -104,7 +104,7 @@ func TestStateProposerSelection2(t *testing.T) {
// everyone just votes nil. we get a new proposer each round // everyone just votes nil. we get a new proposer each round
for i := 0; i < len(vss); i++ { for i := 0; i < len(vss); i++ {
prop := cs1.GetRoundState().Validators.GetProposer() prop := cs1.GetRoundState().Validators.GetProposer()
if !bytes.Equal(prop.Address, vss[(i+2)%len(vss)].GetAddress()) {
if !bytes.Equal(prop.Address, vss[(i+2)%len(vss)].Address()) {
panic(cmn.Fmt("expected proposer to be validator %d. Got %X", (i+2)%len(vss), prop.Address)) panic(cmn.Fmt("expected proposer to be validator %d. Got %X", (i+2)%len(vss), prop.Address))
} }
@ -629,7 +629,7 @@ func TestStateLockPOLUnlock(t *testing.T) {
timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait)
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
unlockCh := subscribe(cs1.eventBus, types.EventQueryUnlock) unlockCh := subscribe(cs1.eventBus, types.EventQueryUnlock)
voteCh := subscribeToVoter(cs1, cs1.privValidator.GetAddress())
voteCh := subscribeToVoter(cs1, cs1.privValidator.Address())
// everything done from perspective of cs1 // everything done from perspective of cs1
@ -725,7 +725,7 @@ func TestStateLockPOLSafety1(t *testing.T) {
timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose) timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose)
timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait)
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
voteCh := subscribeToVoter(cs1, cs1.privValidator.GetAddress())
voteCh := subscribeToVoter(cs1, cs1.privValidator.Address())
// start round and wait for propose and prevote // start round and wait for propose and prevote
startTestRound(cs1, cs1.Height, 0) startTestRound(cs1, cs1.Height, 0)
@ -849,7 +849,7 @@ func TestStateLockPOLSafety2(t *testing.T) {
timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait)
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
unlockCh := subscribe(cs1.eventBus, types.EventQueryUnlock) unlockCh := subscribe(cs1.eventBus, types.EventQueryUnlock)
voteCh := subscribeToVoter(cs1, cs1.privValidator.GetAddress())
voteCh := subscribeToVoter(cs1, cs1.privValidator.Address())
// the block for R0: gets polkad but we miss it // the block for R0: gets polkad but we miss it
// (even though we signed it, shhh) // (even though we signed it, shhh)
@ -945,7 +945,7 @@ func TestStateSlashingPrevotes(t *testing.T) {
proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal)
timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait)
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
voteCh := subscribeToVoter(cs1, cs1.privValidator.GetAddress())
voteCh := subscribeToVoter(cs1, cs1.privValidator.Address())
// start round and wait for propose and prevote // start round and wait for propose and prevote
startTestRound(cs1, cs1.Height, 0) startTestRound(cs1, cs1.Height, 0)
@ -980,7 +980,7 @@ func TestStateSlashingPrecommits(t *testing.T) {
proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal)
timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait)
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
voteCh := subscribeToVoter(cs1, cs1.privValidator.GetAddress())
voteCh := subscribeToVoter(cs1, cs1.privValidator.Address())
// start round and wait for propose and prevote // start round and wait for propose and prevote
startTestRound(cs1, cs1.Height, 0) startTestRound(cs1, cs1.Height, 0)
@ -1027,7 +1027,7 @@ func TestStateHalt1(t *testing.T) {
timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait)
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
newBlockCh := subscribe(cs1.eventBus, types.EventQueryNewBlock) newBlockCh := subscribe(cs1.eventBus, types.EventQueryNewBlock)
voteCh := subscribeToVoter(cs1, cs1.privValidator.GetAddress())
voteCh := subscribeToVoter(cs1, cs1.privValidator.Address())
// start round and wait for propose and prevote // start round and wait for propose and prevote
startTestRound(cs1, cs1.Height, 0) startTestRound(cs1, cs1.Height, 0)


+ 1
- 1
consensus/types/height_vote_set_test.go View File

@ -51,7 +51,7 @@ func TestPeerCatchupRounds(t *testing.T) {
func makeVoteHR(t *testing.T, height int64, round int, privVals []types.PrivValidator, valIndex int) *types.Vote { func makeVoteHR(t *testing.T, height int64, round int, privVals []types.PrivValidator, valIndex int) *types.Vote {
privVal := privVals[valIndex] privVal := privVals[valIndex]
vote := &types.Vote{ vote := &types.Vote{
ValidatorAddress: privVal.GetAddress(),
ValidatorAddress: privVal.Address(),
ValidatorIndex: valIndex, ValidatorIndex: valIndex,
Height: height, Height: height,
Round: round, Round: round,


+ 5
- 5
node/node.go View File

@ -217,16 +217,16 @@ func NewNode(config *cfg.Config,
fastSync := config.FastSync fastSync := config.FastSync
if state.Validators.Size() == 1 { if state.Validators.Size() == 1 {
addr, _ := state.Validators.GetByIndex(0) addr, _ := state.Validators.GetByIndex(0)
if bytes.Equal(privValidator.GetAddress(), addr) {
if bytes.Equal(privValidator.Address(), addr) {
fastSync = false fastSync = false
} }
} }
// Log whether this node is a validator or an observer // Log whether this node is a validator or an observer
if state.Validators.HasAddress(privValidator.GetAddress()) {
consensusLogger.Info("This node is a validator", "addr", privValidator.GetAddress(), "pubKey", privValidator.GetPubKey())
if state.Validators.HasAddress(privValidator.Address()) {
consensusLogger.Info("This node is a validator", "addr", privValidator.Address(), "pubKey", privValidator.PubKey())
} else { } else {
consensusLogger.Info("This node is not a validator", "addr", privValidator.GetAddress(), "pubKey", privValidator.GetPubKey())
consensusLogger.Info("This node is not a validator", "addr", privValidator.Address(), "pubKey", privValidator.PubKey())
} }
// metrics // metrics
@ -537,7 +537,7 @@ func (n *Node) ConfigureRPC() {
rpccore.SetMempool(n.mempoolReactor.Mempool) rpccore.SetMempool(n.mempoolReactor.Mempool)
rpccore.SetEvidencePool(n.evidencePool) rpccore.SetEvidencePool(n.evidencePool)
rpccore.SetSwitch(n.sw) rpccore.SetSwitch(n.sw)
rpccore.SetPubKey(n.privValidator.GetPubKey())
rpccore.SetPubKey(n.privValidator.PubKey())
rpccore.SetGenesisDoc(n.genesisDoc) rpccore.SetGenesisDoc(n.genesisDoc)
rpccore.SetAddrBook(n.addrBook) rpccore.SetAddrBook(n.addrBook)
rpccore.SetProxyAppQuery(n.proxyApp.Query()) rpccore.SetProxyAppQuery(n.proxyApp.Query())


+ 13
- 13
privval/priv_validator.go View File

@ -37,8 +37,8 @@ func voteToStep(vote *types.Vote) int8 {
// to prevent double signing. // to prevent double signing.
// NOTE: the directory containing the pv.filePath must already exist. // NOTE: the directory containing the pv.filePath must already exist.
type FilePV struct { type FilePV struct {
Address types.Address `json:"address"`
PubKey crypto.PubKey `json:"pub_key"`
Address_ types.Address `json:"address"`
PubKey_ crypto.PubKey `json:"pub_key"`
LastHeight int64 `json:"last_height"` LastHeight int64 `json:"last_height"`
LastRound int `json:"last_round"` LastRound int `json:"last_round"`
LastStep int8 `json:"last_step"` LastStep int8 `json:"last_step"`
@ -52,16 +52,16 @@ type FilePV struct {
mtx sync.Mutex mtx sync.Mutex
} }
// GetAddress returns the address of the validator.
// Address returns the address of the validator.
// Implements PrivValidator. // Implements PrivValidator.
func (pv *FilePV) GetAddress() types.Address {
return pv.Address
func (pv *FilePV) Address() types.Address {
return pv.Address_
} }
// GetPubKey returns the public key of the validator.
// PubKey returns the public key of the validator.
// Implements PrivValidator. // Implements PrivValidator.
func (pv *FilePV) GetPubKey() crypto.PubKey {
return pv.PubKey
func (pv *FilePV) PubKey() crypto.PubKey {
return pv.PubKey_
} }
// GenFilePV generates a new validator with randomly generated private key // GenFilePV generates a new validator with randomly generated private key
@ -69,8 +69,8 @@ func (pv *FilePV) GetPubKey() crypto.PubKey {
func GenFilePV(filePath string) *FilePV { func GenFilePV(filePath string) *FilePV {
privKey := crypto.GenPrivKeyEd25519() privKey := crypto.GenPrivKeyEd25519()
return &FilePV{ return &FilePV{
Address: privKey.PubKey().Address(),
PubKey: privKey.PubKey(),
Address_: privKey.PubKey().Address(),
PubKey_: privKey.PubKey(),
PrivKey: privKey, PrivKey: privKey,
LastStep: stepNone, LastStep: stepNone,
filePath: filePath, filePath: filePath,
@ -92,8 +92,8 @@ func LoadFilePV(filePath string) *FilePV {
} }
// overwrite pubkey and address for convenience // overwrite pubkey and address for convenience
pv.PubKey = pv.PrivKey.PubKey()
pv.Address = pv.PubKey.Address()
pv.PubKey_ = pv.PrivKey.PubKey()
pv.Address_ = pv.PubKey_.Address()
pv.filePath = filePath pv.filePath = filePath
return pv return pv
@ -301,7 +301,7 @@ func (pv *FilePV) SignHeartbeat(chainID string, heartbeat *types.Heartbeat) erro
// String returns a string representation of the FilePV. // String returns a string representation of the FilePV.
func (pv *FilePV) String() string { func (pv *FilePV) String() string {
return fmt.Sprintf("PrivValidator{%v LH:%v, LR:%v, LS:%v}", pv.GetAddress(), pv.LastHeight, pv.LastRound, pv.LastStep)
return fmt.Sprintf("PrivValidator{%v LH:%v, LR:%v, LS:%v}", pv.Address(), pv.LastHeight, pv.LastRound, pv.LastStep)
} }
//------------------------------------- //-------------------------------------


+ 13
- 13
privval/priv_validator_test.go View File

@ -10,8 +10,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/types"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/types"
) )
func TestGenLoadValidator(t *testing.T) { func TestGenLoadValidator(t *testing.T) {
@ -23,10 +23,10 @@ func TestGenLoadValidator(t *testing.T) {
height := int64(100) height := int64(100)
privVal.LastHeight = height privVal.LastHeight = height
privVal.Save() privVal.Save()
addr := privVal.GetAddress()
addr := privVal.Address()
privVal = LoadFilePV(tempFilePath) privVal = LoadFilePV(tempFilePath)
assert.Equal(addr, privVal.GetAddress(), "expected privval addr to be the same")
assert.Equal(addr, privVal.Address(), "expected privval addr to be the same")
assert.Equal(height, privVal.LastHeight, "expected privval.LastHeight to have been saved") assert.Equal(height, privVal.LastHeight, "expected privval.LastHeight to have been saved")
} }
@ -38,9 +38,9 @@ func TestLoadOrGenValidator(t *testing.T) {
t.Error(err) t.Error(err)
} }
privVal := LoadOrGenFilePV(tempFilePath) privVal := LoadOrGenFilePV(tempFilePath)
addr := privVal.GetAddress()
addr := privVal.Address()
privVal = LoadOrGenFilePV(tempFilePath) privVal = LoadOrGenFilePV(tempFilePath)
assert.Equal(addr, privVal.GetAddress(), "expected privval addr to be the same")
assert.Equal(addr, privVal.Address(), "expected privval addr to be the same")
} }
func TestUnmarshalValidator(t *testing.T) { func TestUnmarshalValidator(t *testing.T) {
@ -77,8 +77,8 @@ func TestUnmarshalValidator(t *testing.T) {
require.Nil(err, "%+v", err) require.Nil(err, "%+v", err)
// make sure the values match // make sure the values match
assert.EqualValues(addr, val.GetAddress())
assert.EqualValues(pubKey, val.GetPubKey())
assert.EqualValues(addr, val.Address())
assert.EqualValues(pubKey, val.PubKey())
assert.EqualValues(privKey, val.PrivKey) assert.EqualValues(privKey, val.PrivKey)
// export it and make sure it is the same // export it and make sure it is the same
@ -99,7 +99,7 @@ func TestSignVote(t *testing.T) {
voteType := types.VoteTypePrevote voteType := types.VoteTypePrevote
// sign a vote for first time // sign a vote for first time
vote := newVote(privVal.Address, 0, height, round, voteType, block1)
vote := newVote(privVal.Address(), 0, height, round, voteType, block1)
err := privVal.SignVote("mychainid", vote) err := privVal.SignVote("mychainid", vote)
assert.NoError(err, "expected no error signing vote") assert.NoError(err, "expected no error signing vote")
@ -109,10 +109,10 @@ func TestSignVote(t *testing.T) {
// now try some bad votes // now try some bad votes
cases := []*types.Vote{ cases := []*types.Vote{
newVote(privVal.Address, 0, height, round-1, voteType, block1), // round regression
newVote(privVal.Address, 0, height-1, round, voteType, block1), // height regression
newVote(privVal.Address, 0, height-2, round+4, voteType, block1), // height regression and different round
newVote(privVal.Address, 0, height, round, voteType, block2), // different block
newVote(privVal.Address(), 0, height, round-1, voteType, block1), // round regression
newVote(privVal.Address(), 0, height-1, round, voteType, block1), // height regression
newVote(privVal.Address(), 0, height-2, round+4, voteType, block1), // height regression and different round
newVote(privVal.Address(), 0, height, round, voteType, block2), // different block
} }
for _, c := range cases { for _, c := range cases {
@ -201,7 +201,7 @@ func TestDifferByTimestamp(t *testing.T) {
{ {
voteType := types.VoteTypePrevote voteType := types.VoteTypePrevote
blockID := types.BlockID{[]byte{1, 2, 3}, types.PartSetHeader{}} blockID := types.BlockID{[]byte{1, 2, 3}, types.PartSetHeader{}}
vote := newVote(privVal.Address, 0, height, round, voteType, blockID)
vote := newVote(privVal.Address(), 0, height, round, voteType, blockID)
err := privVal.SignVote("mychainid", vote) err := privVal.SignVote("mychainid", vote)
assert.NoError(t, err, "expected no error signing vote") assert.NoError(t, err, "expected no error signing vote")


+ 5
- 5
privval/socket.go View File

@ -103,8 +103,8 @@ func NewSocketPV(
return sc return sc
} }
// GetAddress implements PrivValidator.
func (sc *SocketPV) GetAddress() types.Address {
// Address implements PrivValidator.
func (sc *SocketPV) Address() types.Address {
addr, err := sc.getAddress() addr, err := sc.getAddress()
if err != nil { if err != nil {
panic(err) panic(err)
@ -123,8 +123,8 @@ func (sc *SocketPV) getAddress() (cmn.HexBytes, error) {
return p.Address(), nil return p.Address(), nil
} }
// GetPubKey implements PrivValidator.
func (sc *SocketPV) GetPubKey() crypto.PubKey {
// PubKey implements PrivValidator.
func (sc *SocketPV) PubKey() crypto.PubKey {
pubKey, err := sc.getPubKey() pubKey, err := sc.getPubKey()
if err != nil { if err != nil {
panic(err) panic(err)
@ -459,7 +459,7 @@ func (rs *RemoteSigner) handleConnection(conn net.Conn) {
switch r := req.(type) { switch r := req.(type) {
case *PubKeyMsg: case *PubKeyMsg:
var p crypto.PubKey var p crypto.PubKey
p = rs.privVal.GetPubKey()
p = rs.privVal.PubKey()
res = &PubKeyMsg{p} res = &PubKeyMsg{p}
case *SignVoteMsg: case *SignVoteMsg:
err = rs.privVal.SignVote(rs.chainID, r.Vote) err = rs.privVal.SignVote(rs.chainID, r.Vote)


+ 4
- 4
privval/socket_test.go View File

@ -25,7 +25,7 @@ func TestSocketPVAddress(t *testing.T) {
defer sc.Stop() defer sc.Stop()
defer rs.Stop() defer rs.Stop()
serverAddr := rs.privVal.GetAddress()
serverAddr := rs.privVal.Address()
clientAddr, err := sc.getAddress() clientAddr, err := sc.getAddress()
require.NoError(t, err) require.NoError(t, err)
@ -33,7 +33,7 @@ func TestSocketPVAddress(t *testing.T) {
assert.Equal(t, serverAddr, clientAddr) assert.Equal(t, serverAddr, clientAddr)
// TODO(xla): Remove when PrivValidator2 replaced PrivValidator. // TODO(xla): Remove when PrivValidator2 replaced PrivValidator.
assert.Equal(t, serverAddr, sc.GetAddress())
assert.Equal(t, serverAddr, sc.Address())
} }
@ -48,12 +48,12 @@ func TestSocketPVPubKey(t *testing.T) {
clientKey, err := sc.getPubKey() clientKey, err := sc.getPubKey()
require.NoError(t, err) require.NoError(t, err)
privKey := rs.privVal.GetPubKey()
privKey := rs.privVal.PubKey()
assert.Equal(t, privKey, clientKey) assert.Equal(t, privKey, clientKey)
// TODO(xla): Remove when PrivValidator2 replaced PrivValidator. // TODO(xla): Remove when PrivValidator2 replaced PrivValidator.
assert.Equal(t, privKey, sc.GetPubKey())
assert.Equal(t, privKey, sc.PubKey())
} }
func TestSocketPVProposal(t *testing.T) { func TestSocketPVProposal(t *testing.T) {


+ 3
- 3
scripts/wire2amino.go View File

@ -8,7 +8,7 @@ import (
"path/filepath" "path/filepath"
"time" "time"
"github.com/tendermint/go-amino"
amino "github.com/tendermint/go-amino"
crypto "github.com/tendermint/tendermint/crypto" crypto "github.com/tendermint/tendermint/crypto"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
@ -84,8 +84,8 @@ func convertPrivVal(cdc *amino.Codec, jsonBytes []byte) ([]byte, error) {
copy(pubKey[:], privVal.PubKey.Data) copy(pubKey[:], privVal.PubKey.Data)
privValNew := privval.FilePV{ privValNew := privval.FilePV{
Address: pubKey.Address(),
PubKey: pubKey,
Address_: pubKey.Address(),
PubKey_: pubKey,
LastHeight: privVal.LastHeight, LastHeight: privVal.LastHeight,
LastRound: privVal.LastRound, LastRound: privVal.LastRound,
LastStep: privVal.LastStep, LastStep: privVal.LastStep,


+ 2
- 2
types/evidence_test.go View File

@ -14,7 +14,7 @@ type voteData struct {
func makeVote(val PrivValidator, chainID string, valIndex int, height int64, round, step int, blockID BlockID) *Vote { func makeVote(val PrivValidator, chainID string, valIndex int, height int64, round, step int, blockID BlockID) *Vote {
v := &Vote{ v := &Vote{
ValidatorAddress: val.GetAddress(),
ValidatorAddress: val.Address(),
ValidatorIndex: valIndex, ValidatorIndex: valIndex,
Height: height, Height: height,
Round: round, Round: round,
@ -59,7 +59,7 @@ func TestEvidence(t *testing.T) {
{vote1, badVote, false}, // signed by wrong key {vote1, badVote, false}, // signed by wrong key
} }
pubKey := val.GetPubKey()
pubKey := val.PubKey()
for _, c := range cases { for _, c := range cases {
ev := &DuplicateVoteEvidence{ ev := &DuplicateVoteEvidence{
VoteA: c.vote1, VoteA: c.vote1,


+ 6
- 6
types/priv_validator.go View File

@ -10,8 +10,8 @@ import (
// PrivValidator defines the functionality of a local Tendermint validator // PrivValidator defines the functionality of a local Tendermint validator
// that signs votes, proposals, and heartbeats, and never double signs. // that signs votes, proposals, and heartbeats, and never double signs.
type PrivValidator interface { type PrivValidator interface {
GetAddress() Address // redundant since .PubKey().Address()
GetPubKey() crypto.PubKey
Address() Address // redundant since .PubKey().Address()
PubKey() crypto.PubKey
SignVote(chainID string, vote *Vote) error SignVote(chainID string, vote *Vote) error
SignProposal(chainID string, proposal *Proposal) error SignProposal(chainID string, proposal *Proposal) error
@ -28,7 +28,7 @@ func (pvs PrivValidatorsByAddress) Len() int {
} }
func (pvs PrivValidatorsByAddress) Less(i, j int) bool { func (pvs PrivValidatorsByAddress) Less(i, j int) bool {
return bytes.Compare(pvs[i].GetAddress(), pvs[j].GetAddress()) == -1
return bytes.Compare(pvs[i].Address(), pvs[j].Address()) == -1
} }
func (pvs PrivValidatorsByAddress) Swap(i, j int) { func (pvs PrivValidatorsByAddress) Swap(i, j int) {
@ -51,12 +51,12 @@ func NewMockPV() *MockPV {
} }
// Implements PrivValidator. // Implements PrivValidator.
func (pv *MockPV) GetAddress() Address {
func (pv *MockPV) Address() Address {
return pv.privKey.PubKey().Address() return pv.privKey.PubKey().Address()
} }
// Implements PrivValidator. // Implements PrivValidator.
func (pv *MockPV) GetPubKey() crypto.PubKey {
func (pv *MockPV) PubKey() crypto.PubKey {
return pv.privKey.PubKey() return pv.privKey.PubKey()
} }
@ -94,7 +94,7 @@ func (pv *MockPV) SignHeartbeat(chainID string, heartbeat *Heartbeat) error {
// String returns a string representation of the MockPV. // String returns a string representation of the MockPV.
func (pv *MockPV) String() string { func (pv *MockPV) String() string {
return fmt.Sprintf("MockPV{%v}", pv.GetAddress())
return fmt.Sprintf("MockPV{%v}", pv.Address())
} }
// XXX: Implement. // XXX: Implement.


+ 2
- 2
types/proposal_test.go View File

@ -47,7 +47,7 @@ func TestProposalString(t *testing.T) {
func TestProposalVerifySignature(t *testing.T) { func TestProposalVerifySignature(t *testing.T) {
privVal := NewMockPV() privVal := NewMockPV()
pubKey := privVal.GetPubKey()
pubKey := privVal.PubKey()
prop := NewProposal(4, 2, PartSetHeader{777, []byte("proper")}, 2, BlockID{}) prop := NewProposal(4, 2, PartSetHeader{777, []byte("proper")}, 2, BlockID{})
signBytes := prop.SignBytes("test_chain_id") signBytes := prop.SignBytes("test_chain_id")
@ -94,7 +94,7 @@ func BenchmarkProposalVerifySignature(b *testing.B) {
privVal := NewMockPV() privVal := NewMockPV()
err := privVal.SignProposal("test_chain_id", testProposal) err := privVal.SignProposal("test_chain_id", testProposal)
require.Nil(b, err) require.Nil(b, err)
pubKey := privVal.GetPubKey()
pubKey := privVal.PubKey()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
pubKey.VerifyBytes(testProposal.SignBytes("test_chain_id"), testProposal.Signature) pubKey.VerifyBytes(testProposal.SignBytes("test_chain_id"), testProposal.Signature)


+ 2
- 2
types/protobuf_test.go View File

@ -89,13 +89,13 @@ func TestABCIEvidence(t *testing.T) {
blockID2 := makeBlockID("blockhash2", 1000, "partshash") blockID2 := makeBlockID("blockhash2", 1000, "partshash")
const chainID = "mychain" const chainID = "mychain"
ev := &DuplicateVoteEvidence{ ev := &DuplicateVoteEvidence{
PubKey: val.GetPubKey(),
PubKey: val.PubKey(),
VoteA: makeVote(val, chainID, 0, 10, 2, 1, blockID), VoteA: makeVote(val, chainID, 0, 10, 2, 1, blockID),
VoteB: makeVote(val, chainID, 0, 10, 2, 1, blockID2), VoteB: makeVote(val, chainID, 0, 10, 2, 1, blockID2),
} }
abciEv := TM2PB.Evidence( abciEv := TM2PB.Evidence(
ev, ev,
NewValidatorSet([]*Validator{NewValidator(val.GetPubKey(), 10)}),
NewValidatorSet([]*Validator{NewValidator(val.PubKey(), 10)}),
time.Now(), time.Now(),
) )


+ 1
- 1
types/test_util.go View File

@ -10,7 +10,7 @@ func MakeCommit(blockID BlockID, height int64, round int,
for i := 0; i < len(validators); i++ { for i := 0; i < len(validators); i++ {
vote := &Vote{ vote := &Vote{
ValidatorAddress: validators[i].GetAddress(),
ValidatorAddress: validators[i].Address(),
ValidatorIndex: i, ValidatorIndex: i,
Height: height, Height: height,
Round: round, Round: round,


+ 2
- 1
types/validator.go View File

@ -93,6 +93,7 @@ func RandValidator(randPower bool, minPower int64) (*Validator, PrivValidator) {
if randPower { if randPower {
votePower += int64(cmn.RandUint32()) votePower += int64(cmn.RandUint32())
} }
val := NewValidator(privVal.GetPubKey(), votePower)
val := NewValidator(privVal.PubKey(), votePower)
return val, privVal return val, privVal
} }

+ 27
- 27
types/vote_set_test.go View File

@ -66,7 +66,7 @@ func TestAddVote(t *testing.T) {
// t.Logf(">> %v", voteSet) // t.Logf(">> %v", voteSet)
if voteSet.GetByAddress(val0.GetAddress()) != nil {
if voteSet.GetByAddress(val0.Address()) != nil {
t.Errorf("Expected GetByAddress(val0.Address) to be nil") t.Errorf("Expected GetByAddress(val0.Address) to be nil")
} }
if voteSet.BitArray().GetIndex(0) { if voteSet.BitArray().GetIndex(0) {
@ -78,7 +78,7 @@ func TestAddVote(t *testing.T) {
} }
vote := &Vote{ vote := &Vote{
ValidatorAddress: val0.GetAddress(),
ValidatorAddress: val0.Address(),
ValidatorIndex: 0, // since privValidators are in order ValidatorIndex: 0, // since privValidators are in order
Height: height, Height: height,
Round: round, Round: round,
@ -91,7 +91,7 @@ func TestAddVote(t *testing.T) {
t.Error(err) t.Error(err)
} }
if voteSet.GetByAddress(val0.GetAddress()) == nil {
if voteSet.GetByAddress(val0.Address()) == nil {
t.Errorf("Expected GetByAddress(val0.Address) to be present") t.Errorf("Expected GetByAddress(val0.Address) to be present")
} }
if !voteSet.BitArray().GetIndex(0) { if !voteSet.BitArray().GetIndex(0) {
@ -118,7 +118,7 @@ func Test2_3Majority(t *testing.T) {
} }
// 6 out of 10 voted for nil. // 6 out of 10 voted for nil.
for i := 0; i < 6; i++ { for i := 0; i < 6; i++ {
vote := withValidator(voteProto, privValidators[i].GetAddress(), i)
vote := withValidator(voteProto, privValidators[i].Address(), i)
_, err := signAddVote(privValidators[i], vote, voteSet) _, err := signAddVote(privValidators[i], vote, voteSet)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -131,7 +131,7 @@ func Test2_3Majority(t *testing.T) {
// 7th validator voted for some blockhash // 7th validator voted for some blockhash
{ {
vote := withValidator(voteProto, privValidators[6].GetAddress(), 6)
vote := withValidator(voteProto, privValidators[6].Address(), 6)
_, err := signAddVote(privValidators[6], withBlockHash(vote, cmn.RandBytes(32)), voteSet) _, err := signAddVote(privValidators[6], withBlockHash(vote, cmn.RandBytes(32)), voteSet)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -144,7 +144,7 @@ func Test2_3Majority(t *testing.T) {
// 8th validator voted for nil. // 8th validator voted for nil.
{ {
vote := withValidator(voteProto, privValidators[7].GetAddress(), 7)
vote := withValidator(voteProto, privValidators[7].Address(), 7)
_, err := signAddVote(privValidators[7], vote, voteSet) _, err := signAddVote(privValidators[7], vote, voteSet)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -176,7 +176,7 @@ func Test2_3MajorityRedux(t *testing.T) {
// 66 out of 100 voted for nil. // 66 out of 100 voted for nil.
for i := 0; i < 66; i++ { for i := 0; i < 66; i++ {
vote := withValidator(voteProto, privValidators[i].GetAddress(), i)
vote := withValidator(voteProto, privValidators[i].Address(), i)
_, err := signAddVote(privValidators[i], vote, voteSet) _, err := signAddVote(privValidators[i], vote, voteSet)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -189,7 +189,7 @@ func Test2_3MajorityRedux(t *testing.T) {
// 67th validator voted for nil // 67th validator voted for nil
{ {
vote := withValidator(voteProto, privValidators[66].GetAddress(), 66)
vote := withValidator(voteProto, privValidators[66].Address(), 66)
_, err := signAddVote(privValidators[66], withBlockHash(vote, nil), voteSet) _, err := signAddVote(privValidators[66], withBlockHash(vote, nil), voteSet)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -202,7 +202,7 @@ func Test2_3MajorityRedux(t *testing.T) {
// 68th validator voted for a different BlockParts PartSetHeader // 68th validator voted for a different BlockParts PartSetHeader
{ {
vote := withValidator(voteProto, privValidators[67].GetAddress(), 67)
vote := withValidator(voteProto, privValidators[67].Address(), 67)
blockPartsHeader := PartSetHeader{blockPartsTotal, crypto.CRandBytes(32)} blockPartsHeader := PartSetHeader{blockPartsTotal, crypto.CRandBytes(32)}
_, err := signAddVote(privValidators[67], withBlockPartsHeader(vote, blockPartsHeader), voteSet) _, err := signAddVote(privValidators[67], withBlockPartsHeader(vote, blockPartsHeader), voteSet)
if err != nil { if err != nil {
@ -216,7 +216,7 @@ func Test2_3MajorityRedux(t *testing.T) {
// 69th validator voted for different BlockParts Total // 69th validator voted for different BlockParts Total
{ {
vote := withValidator(voteProto, privValidators[68].GetAddress(), 68)
vote := withValidator(voteProto, privValidators[68].Address(), 68)
blockPartsHeader := PartSetHeader{blockPartsTotal + 1, blockPartsHeader.Hash} blockPartsHeader := PartSetHeader{blockPartsTotal + 1, blockPartsHeader.Hash}
_, err := signAddVote(privValidators[68], withBlockPartsHeader(vote, blockPartsHeader), voteSet) _, err := signAddVote(privValidators[68], withBlockPartsHeader(vote, blockPartsHeader), voteSet)
if err != nil { if err != nil {
@ -230,7 +230,7 @@ func Test2_3MajorityRedux(t *testing.T) {
// 70th validator voted for different BlockHash // 70th validator voted for different BlockHash
{ {
vote := withValidator(voteProto, privValidators[69].GetAddress(), 69)
vote := withValidator(voteProto, privValidators[69].Address(), 69)
_, err := signAddVote(privValidators[69], withBlockHash(vote, cmn.RandBytes(32)), voteSet) _, err := signAddVote(privValidators[69], withBlockHash(vote, cmn.RandBytes(32)), voteSet)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -243,7 +243,7 @@ func Test2_3MajorityRedux(t *testing.T) {
// 71st validator voted for the right BlockHash & BlockPartsHeader // 71st validator voted for the right BlockHash & BlockPartsHeader
{ {
vote := withValidator(voteProto, privValidators[70].GetAddress(), 70)
vote := withValidator(voteProto, privValidators[70].Address(), 70)
_, err := signAddVote(privValidators[70], vote, voteSet) _, err := signAddVote(privValidators[70], vote, voteSet)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -271,7 +271,7 @@ func TestBadVotes(t *testing.T) {
// val0 votes for nil. // val0 votes for nil.
{ {
vote := withValidator(voteProto, privValidators[0].GetAddress(), 0)
vote := withValidator(voteProto, privValidators[0].Address(), 0)
added, err := signAddVote(privValidators[0], vote, voteSet) added, err := signAddVote(privValidators[0], vote, voteSet)
if !added || err != nil { if !added || err != nil {
t.Errorf("Expected VoteSet.Add to succeed") t.Errorf("Expected VoteSet.Add to succeed")
@ -280,7 +280,7 @@ func TestBadVotes(t *testing.T) {
// val0 votes again for some block. // val0 votes again for some block.
{ {
vote := withValidator(voteProto, privValidators[0].GetAddress(), 0)
vote := withValidator(voteProto, privValidators[0].Address(), 0)
added, err := signAddVote(privValidators[0], withBlockHash(vote, cmn.RandBytes(32)), voteSet) added, err := signAddVote(privValidators[0], withBlockHash(vote, cmn.RandBytes(32)), voteSet)
if added || err == nil { if added || err == nil {
t.Errorf("Expected VoteSet.Add to fail, conflicting vote.") t.Errorf("Expected VoteSet.Add to fail, conflicting vote.")
@ -289,7 +289,7 @@ func TestBadVotes(t *testing.T) {
// val1 votes on another height // val1 votes on another height
{ {
vote := withValidator(voteProto, privValidators[1].GetAddress(), 1)
vote := withValidator(voteProto, privValidators[1].Address(), 1)
added, err := signAddVote(privValidators[1], withHeight(vote, height+1), voteSet) added, err := signAddVote(privValidators[1], withHeight(vote, height+1), voteSet)
if added || err == nil { if added || err == nil {
t.Errorf("Expected VoteSet.Add to fail, wrong height") t.Errorf("Expected VoteSet.Add to fail, wrong height")
@ -298,7 +298,7 @@ func TestBadVotes(t *testing.T) {
// val2 votes on another round // val2 votes on another round
{ {
vote := withValidator(voteProto, privValidators[2].GetAddress(), 2)
vote := withValidator(voteProto, privValidators[2].Address(), 2)
added, err := signAddVote(privValidators[2], withRound(vote, round+1), voteSet) added, err := signAddVote(privValidators[2], withRound(vote, round+1), voteSet)
if added || err == nil { if added || err == nil {
t.Errorf("Expected VoteSet.Add to fail, wrong round") t.Errorf("Expected VoteSet.Add to fail, wrong round")
@ -307,7 +307,7 @@ func TestBadVotes(t *testing.T) {
// val3 votes of another type. // val3 votes of another type.
{ {
vote := withValidator(voteProto, privValidators[3].GetAddress(), 3)
vote := withValidator(voteProto, privValidators[3].Address(), 3)
added, err := signAddVote(privValidators[3], withType(vote, VoteTypePrecommit), voteSet) added, err := signAddVote(privValidators[3], withType(vote, VoteTypePrecommit), voteSet)
if added || err == nil { if added || err == nil {
t.Errorf("Expected VoteSet.Add to fail, wrong type") t.Errorf("Expected VoteSet.Add to fail, wrong type")
@ -333,7 +333,7 @@ func TestConflicts(t *testing.T) {
// val0 votes for nil. // val0 votes for nil.
{ {
vote := withValidator(voteProto, privValidators[0].GetAddress(), 0)
vote := withValidator(voteProto, privValidators[0].Address(), 0)
added, err := signAddVote(privValidators[0], vote, voteSet) added, err := signAddVote(privValidators[0], vote, voteSet)
if !added || err != nil { if !added || err != nil {
t.Errorf("Expected VoteSet.Add to succeed") t.Errorf("Expected VoteSet.Add to succeed")
@ -342,7 +342,7 @@ func TestConflicts(t *testing.T) {
// val0 votes again for blockHash1. // val0 votes again for blockHash1.
{ {
vote := withValidator(voteProto, privValidators[0].GetAddress(), 0)
vote := withValidator(voteProto, privValidators[0].Address(), 0)
added, err := signAddVote(privValidators[0], withBlockHash(vote, blockHash1), voteSet) added, err := signAddVote(privValidators[0], withBlockHash(vote, blockHash1), voteSet)
if added { if added {
t.Errorf("Expected VoteSet.Add to fail, conflicting vote.") t.Errorf("Expected VoteSet.Add to fail, conflicting vote.")
@ -357,7 +357,7 @@ func TestConflicts(t *testing.T) {
// val0 votes again for blockHash1. // val0 votes again for blockHash1.
{ {
vote := withValidator(voteProto, privValidators[0].GetAddress(), 0)
vote := withValidator(voteProto, privValidators[0].Address(), 0)
added, err := signAddVote(privValidators[0], withBlockHash(vote, blockHash1), voteSet) added, err := signAddVote(privValidators[0], withBlockHash(vote, blockHash1), voteSet)
if !added { if !added {
t.Errorf("Expected VoteSet.Add to succeed, called SetPeerMaj23().") t.Errorf("Expected VoteSet.Add to succeed, called SetPeerMaj23().")
@ -372,7 +372,7 @@ func TestConflicts(t *testing.T) {
// val0 votes again for blockHash1. // val0 votes again for blockHash1.
{ {
vote := withValidator(voteProto, privValidators[0].GetAddress(), 0)
vote := withValidator(voteProto, privValidators[0].Address(), 0)
added, err := signAddVote(privValidators[0], withBlockHash(vote, blockHash2), voteSet) added, err := signAddVote(privValidators[0], withBlockHash(vote, blockHash2), voteSet)
if added { if added {
t.Errorf("Expected VoteSet.Add to fail, duplicate SetPeerMaj23() from peerA") t.Errorf("Expected VoteSet.Add to fail, duplicate SetPeerMaj23() from peerA")
@ -384,7 +384,7 @@ func TestConflicts(t *testing.T) {
// val1 votes for blockHash1. // val1 votes for blockHash1.
{ {
vote := withValidator(voteProto, privValidators[1].GetAddress(), 1)
vote := withValidator(voteProto, privValidators[1].Address(), 1)
added, err := signAddVote(privValidators[1], withBlockHash(vote, blockHash1), voteSet) added, err := signAddVote(privValidators[1], withBlockHash(vote, blockHash1), voteSet)
if !added || err != nil { if !added || err != nil {
t.Errorf("Expected VoteSet.Add to succeed") t.Errorf("Expected VoteSet.Add to succeed")
@ -401,7 +401,7 @@ func TestConflicts(t *testing.T) {
// val2 votes for blockHash2. // val2 votes for blockHash2.
{ {
vote := withValidator(voteProto, privValidators[2].GetAddress(), 2)
vote := withValidator(voteProto, privValidators[2].Address(), 2)
added, err := signAddVote(privValidators[2], withBlockHash(vote, blockHash2), voteSet) added, err := signAddVote(privValidators[2], withBlockHash(vote, blockHash2), voteSet)
if !added || err != nil { if !added || err != nil {
t.Errorf("Expected VoteSet.Add to succeed") t.Errorf("Expected VoteSet.Add to succeed")
@ -421,7 +421,7 @@ func TestConflicts(t *testing.T) {
// val2 votes for blockHash1. // val2 votes for blockHash1.
{ {
vote := withValidator(voteProto, privValidators[2].GetAddress(), 2)
vote := withValidator(voteProto, privValidators[2].Address(), 2)
added, err := signAddVote(privValidators[2], withBlockHash(vote, blockHash1), voteSet) added, err := signAddVote(privValidators[2], withBlockHash(vote, blockHash1), voteSet)
if !added { if !added {
t.Errorf("Expected VoteSet.Add to succeed") t.Errorf("Expected VoteSet.Add to succeed")
@ -462,7 +462,7 @@ func TestMakeCommit(t *testing.T) {
// 6 out of 10 voted for some block. // 6 out of 10 voted for some block.
for i := 0; i < 6; i++ { for i := 0; i < 6; i++ {
vote := withValidator(voteProto, privValidators[i].GetAddress(), i)
vote := withValidator(voteProto, privValidators[i].Address(), i)
_, err := signAddVote(privValidators[i], vote, voteSet) _, err := signAddVote(privValidators[i], vote, voteSet)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -474,7 +474,7 @@ func TestMakeCommit(t *testing.T) {
// 7th voted for some other block. // 7th voted for some other block.
{ {
vote := withValidator(voteProto, privValidators[6].GetAddress(), 6)
vote := withValidator(voteProto, privValidators[6].Address(), 6)
vote = withBlockHash(vote, cmn.RandBytes(32)) vote = withBlockHash(vote, cmn.RandBytes(32))
vote = withBlockPartsHeader(vote, PartSetHeader{123, cmn.RandBytes(32)}) vote = withBlockPartsHeader(vote, PartSetHeader{123, cmn.RandBytes(32)})
@ -486,7 +486,7 @@ func TestMakeCommit(t *testing.T) {
// The 8th voted like everyone else. // The 8th voted like everyone else.
{ {
vote := withValidator(voteProto, privValidators[7].GetAddress(), 7)
vote := withValidator(voteProto, privValidators[7].Address(), 7)
_, err := signAddVote(privValidators[7], vote, voteSet) _, err := signAddVote(privValidators[7], vote, voteSet)
if err != nil { if err != nil {
t.Error(err) t.Error(err)


+ 1
- 1
types/vote_test.go View File

@ -72,7 +72,7 @@ func TestVoteString(t *testing.T) {
func TestVoteVerifySignature(t *testing.T) { func TestVoteVerifySignature(t *testing.T) {
privVal := NewMockPV() privVal := NewMockPV()
pubKey := privVal.GetPubKey()
pubKey := privVal.PubKey()
vote := examplePrecommit() vote := examplePrecommit()
signBytes := vote.SignBytes("test_chain_id") signBytes := vote.SignBytes("test_chain_id")


Loading…
Cancel
Save