mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-25 18:51:39 +00:00
Address more review comments: require instead assert & wrap errors
This commit is contained in:
@ -284,7 +284,7 @@ func TestReactorVotingPowerChange(t *testing.T) {
|
||||
logger.Debug("---------------------------- Testing changing the voting power of one validator a few times")
|
||||
|
||||
pubKey, err := css[0].privValidator.GetPubKey()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
val1PubKey := pubKey
|
||||
val1PubKeyABCI := types.TM2PB.PubKey(val1PubKey)
|
||||
updateValidatorTx := kvstore.MakeValSetChangeTx(val1PubKeyABCI, 25)
|
||||
@ -338,7 +338,7 @@ func TestReactorValidatorSetChanges(t *testing.T) {
|
||||
activeVals := make(map[string]struct{})
|
||||
for i := 0; i < nVals; i++ {
|
||||
addr, err := css[i].privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
activeVals[string(addr)] = struct{}{}
|
||||
}
|
||||
|
||||
@ -351,7 +351,7 @@ func TestReactorValidatorSetChanges(t *testing.T) {
|
||||
logger.Info("---------------------------- Testing adding one validator")
|
||||
|
||||
pubKey, err := css[nVals].privValidator.GetPubKey()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
newValidatorPubKey1 := pubKey
|
||||
valPubKey1ABCI := types.TM2PB.PubKey(newValidatorPubKey1)
|
||||
newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower)
|
||||
@ -380,7 +380,7 @@ func TestReactorValidatorSetChanges(t *testing.T) {
|
||||
logger.Info("---------------------------- Testing changing the voting power of one validator")
|
||||
|
||||
pubKey, err = css[nVals].privValidator.GetPubKey()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
updateValidatorPubKey1 := pubKey
|
||||
updatePubKey1ABCI := types.TM2PB.PubKey(updateValidatorPubKey1)
|
||||
updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25)
|
||||
@ -399,13 +399,13 @@ func TestReactorValidatorSetChanges(t *testing.T) {
|
||||
logger.Info("---------------------------- Testing adding two validators at once")
|
||||
|
||||
pubKey, err = css[nVals+1].privValidator.GetPubKey()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
newValidatorPubKey2 := pubKey
|
||||
newVal2ABCI := types.TM2PB.PubKey(newValidatorPubKey2)
|
||||
newValidatorTx2 := kvstore.MakeValSetChangeTx(newVal2ABCI, testMinPower)
|
||||
|
||||
pubKey, err = css[nVals+2].privValidator.GetPubKey()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
newValidatorPubKey3 := pubKey
|
||||
newVal3ABCI := types.TM2PB.PubKey(newValidatorPubKey3)
|
||||
newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower)
|
||||
|
@ -332,7 +332,7 @@ func testHandshakeReplay(t *testing.T, nBlocks int, mode uint) {
|
||||
require.NoError(t, err)
|
||||
|
||||
pubKey, err := privVal.GetPubKey()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
stateDB, state, store := stateAndStore(config, pubKey, kvstore.ProtocolVersion)
|
||||
store.chain = chain
|
||||
store.commits = commits
|
||||
@ -637,7 +637,7 @@ func TestInitChainUpdateValidators(t *testing.T) {
|
||||
config := ResetConfig("proxy_test_")
|
||||
privVal := privval.LoadFilePV(config.PrivValidatorFile())
|
||||
pubKey, err := privVal.GetPubKey()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
stateDB, state, store := stateAndStore(config, pubKey, 0x0)
|
||||
|
||||
oldValAddr := state.Validators.Validators[0].Address
|
||||
|
@ -9,6 +9,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
errs "github.com/pkg/errors"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/fail"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
@ -831,7 +833,7 @@ func (cs *ConsensusState) enterPropose(height int64, round int) {
|
||||
// if not a validator, we're done
|
||||
address, err := cs.privValidator.GetAddress()
|
||||
if err != nil {
|
||||
logger.Error("Could not retrieve potenial validator address", cs.privValidator)
|
||||
logger.Error("Failed to get private validator address", "err", err)
|
||||
return
|
||||
}
|
||||
if !cs.Validators.HasAddress(address) {
|
||||
@ -936,7 +938,7 @@ func (cs *ConsensusState) createProposalBlock() (block *types.Block, blockParts
|
||||
), maxGas)
|
||||
proposerAddr, err := cs.privValidator.GetAddress()
|
||||
if err != nil {
|
||||
cs.Logger.Error("could not retrieve proposer's address from privValidator", cs.privValidator)
|
||||
cs.Logger.Error("Failed to get private validator address", "err", err)
|
||||
return
|
||||
}
|
||||
block, parts := cs.state.MakeBlock(cs.Height, txs, commit, evidence, proposerAddr)
|
||||
@ -1484,7 +1486,10 @@ func (cs *ConsensusState) tryAddVote(vote *types.Vote, peerID p2p.ID) (bool, err
|
||||
return added, err
|
||||
} else if voteErr, ok := err.(*types.ErrVoteConflictingVotes); ok {
|
||||
addr, err := cs.privValidator.GetAddress()
|
||||
cs.Logger.Error("Can not retrieve privValidator's address", "err", err)
|
||||
if err != nil {
|
||||
cs.Logger.Error("Failed to get private validator address", "err", err)
|
||||
return added, err
|
||||
}
|
||||
if bytes.Equal(vote.ValidatorAddress, addr) {
|
||||
cs.Logger.Error("Found conflicting vote from ourselves. Did you unsafe_reset a validator?", "height", vote.Height, "round", vote.Round, "type", vote.Type)
|
||||
return added, err
|
||||
@ -1652,8 +1657,8 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
|
||||
func (cs *ConsensusState) signVote(type_ types.SignedMsgType, hash []byte, header types.PartSetHeader) (*types.Vote, error) {
|
||||
addr, err := cs.privValidator.GetAddress()
|
||||
if err != nil {
|
||||
cs.Logger.Error("Could not retrieve privValidator's address. The remote signer's connection might have dropped?", "err", err)
|
||||
return nil, err
|
||||
cs.Logger.Error("Failed to get private validator address", "err", err)
|
||||
return nil, errs.Wrap(err, "Failed to get private validator address")
|
||||
}
|
||||
valIndex, _ := cs.Validators.GetByAddress(addr)
|
||||
|
||||
@ -1692,7 +1697,7 @@ func (cs *ConsensusState) signAddVote(type_ types.SignedMsgType, hash []byte, he
|
||||
// if we don't have a key or we're not in the validator set, do nothing
|
||||
privValAddr, err := cs.privValidator.GetAddress()
|
||||
if err != nil {
|
||||
cs.Logger.Error("Error signing vote. Could not retrieve privValidator's address.", "privValidator", cs.privValidator, "height", cs.Height, "round", cs.Round)
|
||||
cs.Logger.Error("Failed to get private validator address", "err", err, "height", cs.Height, "round", cs.Round)
|
||||
return nil
|
||||
}
|
||||
if cs.privValidator == nil || !cs.Validators.HasAddress(privValAddr) {
|
||||
|
@ -74,7 +74,7 @@ func TestStateProposerSelection0(t *testing.T) {
|
||||
// Commit a block and ensure proposer for the next height is correct.
|
||||
prop := cs1.GetRoundState().Validators.GetProposer()
|
||||
address, err := cs1.privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
if !bytes.Equal(prop.Address, address) {
|
||||
t.Fatalf("expected proposer to be validator %d. Got %X", 0, prop.Address)
|
||||
}
|
||||
@ -818,7 +818,7 @@ func TestStateLockPOLSafety2(t *testing.T) {
|
||||
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
|
||||
unlockCh := subscribe(cs1.eventBus, types.EventQueryUnlock)
|
||||
addr, err := cs1.privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
voteCh := subscribeToVoter(cs1, addr)
|
||||
|
||||
// the block for R0: gets polkad but we miss it
|
||||
@ -911,7 +911,7 @@ func TestProposeValidBlock(t *testing.T) {
|
||||
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
|
||||
unlockCh := subscribe(cs1.eventBus, types.EventQueryUnlock)
|
||||
addr, err := cs1.privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
voteCh := subscribeToVoter(cs1, addr)
|
||||
|
||||
// start round and wait for propose and prevote
|
||||
@ -999,7 +999,7 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) {
|
||||
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
|
||||
validBlockCh := subscribe(cs1.eventBus, types.EventQueryValidBlock)
|
||||
addr, err := cs1.privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
voteCh := subscribeToVoter(cs1, addr)
|
||||
|
||||
// start round and wait for propose and prevote
|
||||
@ -1060,7 +1060,7 @@ func TestSetValidBlockOnDelayedProposal(t *testing.T) {
|
||||
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
|
||||
validBlockCh := subscribe(cs1.eventBus, types.EventQueryValidBlock)
|
||||
addr, err := cs1.privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
voteCh := subscribeToVoter(cs1, addr)
|
||||
proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal)
|
||||
|
||||
@ -1132,7 +1132,7 @@ func TestWaitingTimeoutProposeOnNewRound(t *testing.T) {
|
||||
timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose)
|
||||
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
|
||||
addr, err := cs1.privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
voteCh := subscribeToVoter(cs1, addr)
|
||||
|
||||
// start round
|
||||
@ -1167,7 +1167,7 @@ func TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) {
|
||||
timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait)
|
||||
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
|
||||
addr, err := cs1.privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
voteCh := subscribeToVoter(cs1, addr)
|
||||
|
||||
// start round
|
||||
@ -1202,7 +1202,7 @@ func TestWaitTimeoutProposeOnNilPolkaForTheCurrentRound(t *testing.T) {
|
||||
timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose)
|
||||
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
|
||||
addr, err := cs1.privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
voteCh := subscribeToVoter(cs1, addr)
|
||||
|
||||
// start round in which PO is not proposer
|
||||
@ -1388,7 +1388,7 @@ func TestStateHalt1(t *testing.T) {
|
||||
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
|
||||
newBlockCh := subscribe(cs1.eventBus, types.EventQueryNewBlock)
|
||||
addr, err := cs1.privValidator.GetAddress()
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
voteCh := subscribeToVoter(cs1, addr)
|
||||
|
||||
// start round and wait for propose and prevote
|
||||
|
Reference in New Issue
Block a user