Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastijankuzner committed Jan 9, 2025
1 parent efbe048 commit 30f247e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions contracts/test/consensus/Consensus-CalculateTop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ contract ConsensusTest is Base {
vm.deal(addr, balance);

if (balance == highestBalance) {
if (addr > highest) {
if (addr < highest || highest == address(0)) {
highest = addr;
}
}
Expand All @@ -179,15 +179,17 @@ contract ConsensusTest is Base {

assertEq(validators[activeValidators - 1].addr, address(0x1B)); // Shuffled address
validators = sortValidators(validators);
assertEq(validators[activeValidators - 1].addr, address(0x35));
assertEq(validators[0].addr, highest);
assertEq(validators[activeValidators - 1].addr, address(53));

// Seccond attempt should return the same result
// Second attempt should return the same result
consensus.calculateActiveValidators(uint8(activeValidators));

validators = consensus.getActiveValidators();
assertEq(validators[activeValidators - 1].addr, address(0x1B)); // Shuffled address
validators = sortValidators(validators);
assertEq(validators.length, activeValidators);
assertEq(validators[activeValidators - 1].addr, address(0x35));
assertEq(validators[0].addr, highest);
assertEq(validators[activeValidators - 1].addr, address(53));
}
}

0 comments on commit 30f247e

Please sign in to comment.