Skip to content

Commit

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

function testSortCandidatesPositionStaysAtIndex4() 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);
vm.prank(user4);
automatedVotingInternals.vote(1, user4);

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, user5, 1);

/// @dev make sure index 4 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 cdad92f

Please sign in to comment.