Skip to content

Commit cee640d

Browse files
committed
blockchain -> clique voting: fixed test
1 parent b043bd8 commit cee640d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/blockchain/src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ export default class Blockchain implements BlockchainInterface {
511511
// Do two rounds here, one to execute on a potential previously reached consensus
512512
// on the newly touched beneficiary, one with the added new vote
513513
for (let round = 1; round <= 2; round++) {
514-
515514
// See if there is a new majority consensus to update the signer list
516515
const lastEpochBlockNumber = header.number.sub(
517516
header.number.mod(new BN(this._common.consensusConfig().epoch))
@@ -521,7 +520,7 @@ export default class Blockchain implements BlockchainInterface {
521520
let consensus = false
522521

523522
// AUTH vote analysis
524-
if (round === 1 || round === 2 && nonce.equals(CLIQUE_NONCE_AUTH)) {
523+
if (round === 1 || (round === 2 && nonce.equals(CLIQUE_NONCE_AUTH))) {
525524
let beneficiaryVotesAUTH = this._cliqueLatestVotes.filter((vote) => {
526525
return (
527526
vote[0].gte(lastEpochBlockNumber) &&
@@ -552,7 +551,7 @@ export default class Blockchain implements BlockchainInterface {
552551
}
553552
}
554553
// DROP vote
555-
if (round === 1 || round === 2 && nonce.equals(CLIQUE_NONCE_DROP)) {
554+
if (round === 1 || (round === 2 && nonce.equals(CLIQUE_NONCE_DROP))) {
556555
let beneficiaryVotesDROP = this._cliqueLatestVotes.filter((vote) => {
557556
return (
558557
vote[0].gte(lastEpochBlockNumber) &&
@@ -569,9 +568,9 @@ export default class Blockchain implements BlockchainInterface {
569568
consensus = true
570569
// Drop signer
571570
activeSigners = activeSigners.filter((signer) => !signer.equals(beneficiary))
572-
// Discard votes from removed signer
573571
this._cliqueLatestVotes = this._cliqueLatestVotes.filter(
574-
(vote) => !vote[1][0].equals(beneficiary)
572+
// Discard votes from removed signer and for removed signer
573+
(vote) => !vote[1][0].equals(beneficiary) && !vote[1][1].equals(beneficiary)
575574
)
576575
debug(
577576
`[Block ${header.number.toNumber()}] Clique majority consensus (DROP ${beneficiary})`

0 commit comments

Comments
 (0)