Skip to content

Commit

Permalink
✅ testSortCandidatesPositionStaysAtIndex3
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Sep 15, 2023
1 parent cdad92f commit 8b57a2b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/AutomatedVoting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,41 @@ contract AutomatedVotingTest is DefaultStakingV2Setup {
assertEq(result[4], user5);
}

function testSortCandidatesPositionStaysAtIndex3() public {
vm.warp(block.timestamp + 21 weeks);
automatedVotingInternals.startScheduledElection();
fundAccountAndStakeV2(user1, 1);
fundAccountAndStakeV2(user2, 1);
fundAccountAndStakeV2(user3, 1);
fundAccountAndStakeV2(user4, 1);
fundAccountAndStakeV2(user5, 1);
vm.prank(user1);
automatedVotingInternals.nominateMultipleCandidates(1, council);
vm.warp(block.timestamp + 1 weeks);

vm.prank(user1);
automatedVotingInternals.vote(1, user1);
vm.prank(user2);
automatedVotingInternals.vote(1, user2);
vm.prank(user3);
automatedVotingInternals.vote(1, user3);

assertEq(automatedVotingInternals.getCandidateAddress(1, 0), user1);
assertEq(automatedVotingInternals.getCandidateAddress(1, 1), user2);
assertEq(automatedVotingInternals.getCandidateAddress(1, 2), user3);
assertEq(automatedVotingInternals.getCandidateAddress(1, 3), user4);
assertEq(automatedVotingInternals.getCandidateAddress(1, 4), user5);

address[] memory result = automatedVotingInternals.sortCandidates(1, user4, 1);

/// @dev make sure index 3 doesnt move
assertEq(result[0], user1);
assertEq(result[1], user2);
assertEq(result[2], user3);
assertEq(result[3], user4);
assertEq(result[4], user5);
}

// _cancelOngoingElections()

function testCancelOngoingElectionsStepDown() public {
Expand Down

0 comments on commit 8b57a2b

Please sign in to comment.