mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 15:04:22 +00:00
fix tests
This commit is contained in:
@@ -229,8 +229,8 @@ func (conR *ConsensusReactor) Receive(chId byte, peer *p2p.Peer, msgBytes []byte
|
||||
if vote.Height != rs.Height || vote.Height != ps.Height {
|
||||
return
|
||||
}
|
||||
index, ok := rs.Validators.GetIndexById(vote.SignerId)
|
||||
if !ok {
|
||||
index, val := rs.Validators.GetById(vote.SignerId)
|
||||
if val == nil {
|
||||
log.Warning("Peer gave us an invalid vote.")
|
||||
return
|
||||
}
|
||||
@@ -348,8 +348,8 @@ OUTER_LOOP:
|
||||
if prs.Step <= RoundStepVote {
|
||||
index, ok := rs.Votes.BitArray().Sub(prs.Votes).PickRandom()
|
||||
if ok {
|
||||
valId, ok := rs.Validators.GetIdByIndex(uint32(index))
|
||||
if ok {
|
||||
valId, val := rs.Validators.GetByIndex(uint32(index))
|
||||
if val != nil {
|
||||
vote := rs.Votes.GetVote(valId)
|
||||
msg := p2p.TypedMessage{msgTypeVote, vote}
|
||||
peer.Send(VoteCh, msg)
|
||||
@@ -365,8 +365,8 @@ OUTER_LOOP:
|
||||
if prs.Step <= RoundStepPrecommit {
|
||||
index, ok := rs.Precommits.BitArray().Sub(prs.Precommits).PickRandom()
|
||||
if ok {
|
||||
valId, ok := rs.Validators.GetIdByIndex(uint32(index))
|
||||
if ok {
|
||||
valId, val := rs.Validators.GetByIndex(uint32(index))
|
||||
if val != nil {
|
||||
vote := rs.Precommits.GetVote(valId)
|
||||
msg := p2p.TypedMessage{msgTypeVote, vote}
|
||||
peer.Send(VoteCh, msg)
|
||||
@@ -381,8 +381,8 @@ OUTER_LOOP:
|
||||
// If there are any commits to send...
|
||||
index, ok := rs.Commits.BitArray().Sub(prs.Commits).PickRandom()
|
||||
if ok {
|
||||
valId, ok := rs.Validators.GetIdByIndex(uint32(index))
|
||||
if ok {
|
||||
valId, val := rs.Validators.GetByIndex(uint32(index))
|
||||
if val != nil {
|
||||
vote := rs.Commits.GetVote(valId)
|
||||
msg := p2p.TypedMessage{msgTypeVote, vote}
|
||||
peer.Send(VoteCh, msg)
|
||||
|
||||
+10
-10
@@ -55,17 +55,17 @@ func (pol *POL) Verify(vset *ValidatorSet) error {
|
||||
if _, seen := seenValidators[sig.SignerId]; seen {
|
||||
return Errorf("Duplicate validator for vote %v for POL %v", sig, pol)
|
||||
}
|
||||
validator := vset.GetById(sig.SignerId)
|
||||
if validator == nil {
|
||||
_, val := vset.GetById(sig.SignerId)
|
||||
if val == nil {
|
||||
return Errorf("Invalid validator for vote %v for POL %v", sig, pol)
|
||||
}
|
||||
if !validator.VerifyBytes(voteDoc, sig) {
|
||||
if !val.VerifyBytes(voteDoc, sig) {
|
||||
return Errorf("Invalid signature for vote %v for POL %v", sig, pol)
|
||||
}
|
||||
|
||||
// Tally
|
||||
seenValidators[validator.Id] = struct{}{}
|
||||
talliedVotingPower += validator.VotingPower
|
||||
seenValidators[val.Id] = struct{}{}
|
||||
talliedVotingPower += val.VotingPower
|
||||
}
|
||||
|
||||
for i, sig := range pol.Commits {
|
||||
@@ -75,20 +75,20 @@ func (pol *POL) Verify(vset *ValidatorSet) error {
|
||||
if _, seen := seenValidators[sig.SignerId]; seen {
|
||||
return Errorf("Duplicate validator for commit %v for POL %v", sig, pol)
|
||||
}
|
||||
validator := vset.GetById(sig.SignerId)
|
||||
if validator == nil {
|
||||
_, val := vset.GetById(sig.SignerId)
|
||||
if val == nil {
|
||||
return Errorf("Invalid validator for commit %v for POL %v", sig, pol)
|
||||
}
|
||||
|
||||
commitDoc := BinaryBytes(&Vote{Height: pol.Height, Round: round,
|
||||
Type: VoteTypeCommit, BlockHash: pol.BlockHash}) // TODO cache
|
||||
if !validator.VerifyBytes(commitDoc, sig) {
|
||||
if !val.VerifyBytes(commitDoc, sig) {
|
||||
return Errorf("Invalid signature for commit %v for POL %v", sig, pol)
|
||||
}
|
||||
|
||||
// Tally
|
||||
seenValidators[validator.Id] = struct{}{}
|
||||
talliedVotingPower += validator.VotingPower
|
||||
seenValidators[val.Id] = struct{}{}
|
||||
talliedVotingPower += val.VotingPower
|
||||
}
|
||||
|
||||
if talliedVotingPower > vset.TotalVotingPower()*2/3 {
|
||||
|
||||
+2
-2
@@ -92,7 +92,7 @@ func (cs *ConsensusState) updateToState(state *State) {
|
||||
cs.Step = RoundStepStart
|
||||
cs.StartTime = state.CommitTime.Add(newBlockWaitDuration)
|
||||
cs.Validators = validators
|
||||
cs.Proposer = validators.GetProposer()
|
||||
cs.Proposer = validators.Proposer()
|
||||
cs.Proposal = nil
|
||||
cs.ProposalBlock = nil
|
||||
cs.ProposalBlockPartSet = nil
|
||||
@@ -135,7 +135,7 @@ func (cs *ConsensusState) setupRound(round uint16) {
|
||||
cs.Round = round
|
||||
cs.Step = RoundStepStart
|
||||
cs.Validators = validators
|
||||
cs.Proposer = validators.GetProposer()
|
||||
cs.Proposer = validators.Proposer()
|
||||
cs.Proposal = nil
|
||||
cs.ProposalBlock = nil
|
||||
cs.ProposalBlockPartSet = nil
|
||||
|
||||
@@ -63,7 +63,7 @@ func (vs *VoteSet) AddVote(vote *Vote) (bool, error) {
|
||||
}
|
||||
|
||||
// Ensure that signer is a validator.
|
||||
val := vs.vset.GetById(vote.SignerId)
|
||||
_, val := vs.vset.GetById(vote.SignerId)
|
||||
if val == nil {
|
||||
return false, ErrVoteInvalidAccount
|
||||
}
|
||||
@@ -89,12 +89,11 @@ func (vs *VoteSet) addVote(vote *Vote) (bool, error) {
|
||||
|
||||
// Add vote.
|
||||
vs.votes[vote.SignerId] = vote
|
||||
voterIndex, ok := vs.vset.GetIndexById(vote.SignerId)
|
||||
if !ok {
|
||||
voterIndex, val := vs.vset.GetById(vote.SignerId)
|
||||
if val == nil {
|
||||
return false, ErrVoteInvalidAccount
|
||||
}
|
||||
vs.votesBitArray.SetIndex(uint(voterIndex), true)
|
||||
val := vs.vset.GetById(vote.SignerId)
|
||||
totalBlockHashVotes := vs.votesByBlockHash[string(vote.BlockHash)] + val.VotingPower
|
||||
vs.votesByBlockHash[string(vote.BlockHash)] = totalBlockHashVotes
|
||||
vs.totalVotes += val.VotingPower
|
||||
|
||||
Reference in New Issue
Block a user