From a2f34d7adbef5ffd863440097ab5ba54b2e0dc54 Mon Sep 17 00:00:00 2001 From: Andrew Chiaramonte Date: Tue, 26 Sep 2023 09:57:47 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20change=20single=20to=20replaceme?= =?UTF-8?q?nt=20election?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AutomatedVoting.sol | 14 +++++++------- src/Enums.sol | 2 +- test/AutomatedVoting.t.sol | 26 +++++++++++++------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/AutomatedVoting.sol b/src/AutomatedVoting.sol index 2d02db9..c26cae1 100644 --- a/src/AutomatedVoting.sol +++ b/src/AutomatedVoting.sol @@ -279,7 +279,7 @@ contract AutomatedVoting is IAutomatedVoting { delete council[i]; } } - _startElection(Enums.electionType.single); + _startElection(Enums.electionType.replacement); } /// @notice starts a community election @@ -316,7 +316,7 @@ contract AutomatedVoting is IAutomatedVoting { } } // start election state - _startElection(Enums.electionType.single); + _startElection(Enums.electionType.replacement); } /// @notice finalizes an election @@ -368,9 +368,9 @@ contract AutomatedVoting is IAutomatedVoting { if (elections[election].isNominated[candidate]) { revert CandidateAlreadyNominated(); } - /// @dev this prevent a council member from being nominated in a single election (becoming member twice) + /// @dev this prevent a council member from being nominated in a replacement election (becoming member twice) if ( - elections[election].theElectionType == Enums.electionType.single && + elections[election].theElectionType == Enums.electionType.replacement && isCouncilMember(candidate) ) { revert CandidateIsAlreadyCouncilMember(); @@ -379,7 +379,7 @@ contract AutomatedVoting is IAutomatedVoting { elections[election].isNominated[candidate] = true; } - /// @notice votes for a candidate in a single election + /// @notice votes for a candidate in a replacement election /// @param _election the election to vote in /// @param candidate the candidate to vote for function vote( @@ -501,9 +501,9 @@ contract AutomatedVoting is IAutomatedVoting { //todo: maybe emit an event that quorum was not reached } } else if ( - elections[_election].theElectionType == Enums.electionType.single + elections[_election].theElectionType == Enums.electionType.replacement ) { - /// @dev this is for a single election + /// @dev this is for a replacement election address winner = elections[_election].candidateAddresses[0]; for (uint i = 0; i < council.length; i++) { if (council[i] == address(0)) { diff --git a/src/Enums.sol b/src/Enums.sol index 21adf7e..b2d7af4 100644 --- a/src/Enums.sol +++ b/src/Enums.sol @@ -5,6 +5,6 @@ contract Enums { enum electionType { scheduled, community, - single //todo: make replacement election + replacement } } \ No newline at end of file diff --git a/test/AutomatedVoting.t.sol b/test/AutomatedVoting.t.sol index 1e66b79..0629728 100644 --- a/test/AutomatedVoting.t.sol +++ b/test/AutomatedVoting.t.sol @@ -509,7 +509,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { ) = automatedVoting.elections(1); assertEq(electionStartTime, block.timestamp); assertEq(isFinalized, false); - assertTrue(theElectionType == Enums.electionType.single); + assertTrue(theElectionType == Enums.electionType.replacement); assertEq(stakedAmountsForQuorum, 0); council = automatedVoting.getCouncil(); @@ -639,7 +639,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { // nominateCandidate() - function testNominateInSingleElectionSuccess() public { + function testNominateInReplacementElectionSuccess() public { fundAccountAndStakeV2(user1, 1); vm.prank(user2); automatedVoting.stepDown(); @@ -652,7 +652,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { assertEq(automatedVoting.getIsNominated(1, user1), false); } - function testNominateInSingleElectionNotStaked() public { + function testNominateInReplacementElectionNotStaked() public { vm.warp(block.timestamp + 21 weeks); vm.prank(user2); automatedVoting.stepDown(); @@ -664,7 +664,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { automatedVoting.nominateCandidate(1, user1); } - function testNominateInSingleElectionNotDuringNomination() public { + function testNominateInReplacementElectionNotDuringNomination() public { vm.warp(block.timestamp + 21 weeks); fundAccountAndStakeV2(user1, 1); vm.prank(user2); @@ -679,7 +679,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { automatedVoting.nominateCandidate(1, user1); } - function testNominateInSingleElectionAlreadyMember() public { + function testNominateInReplacementElectionAlreadyMember() public { fundAccountAndStakeV2(user1, 1); vm.prank(user2); automatedVoting.stepDown(); @@ -693,9 +693,9 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { automatedVoting.nominateCandidate(1, user1); } - // voteInSingleElection() + // voteInReplacementElection() - function testVoteInSingleElectionSuccess() public { + function testVoteInReplacementElectionSuccess() public { vm.warp(block.timestamp + 21 weeks); fundAccountAndStakeV2(user1, 1); vm.prank(user2); @@ -714,7 +714,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { assertFalse(automatedVoting.getHasVoted(1, user6)); } - function testVoteInSingleElectionNotStaked() public { + function testVoteInReplacementElectionNotStaked() public { vm.warp(block.timestamp + 21 weeks); vm.prank(user2); automatedVoting.stepDown(); @@ -726,7 +726,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { automatedVoting.vote(1, user1); } - function testVoteInSingleElectionNotDuringVoting() public { + function testVoteInReplacementElectionNotDuringVoting() public { vm.warp(block.timestamp + 21 weeks); fundAccountAndStakeV2(user1, 1); vm.prank(user2); @@ -741,7 +741,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { automatedVoting.vote(1, user1); } - function testVoteInSingleElectionAlreadyEnded() public { + function testVoteInReplacementElectionAlreadyEnded() public { vm.warp(block.timestamp + 21 weeks); automatedVoting.startScheduledElection(); fundAccountAndStakeV2(user1, 1); @@ -755,7 +755,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { automatedVoting.vote(1, user1); } - function testVoteInSingleElectionAlreadyVoted() public { + function testVoteInReplacementElectionAlreadyVoted() public { vm.warp(block.timestamp + 21 weeks); fundAccountAndStakeV2(user1, 1); vm.prank(user2); @@ -772,7 +772,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { automatedVoting.vote(1, user6); } - function testVoteInSingleElectionCandidateNotNominated() public { + function testVoteInReplacementElectionCandidateNotNominated() public { vm.warp(block.timestamp + 21 weeks); fundAccountAndStakeV2(user1, 1); vm.prank(user2); @@ -1284,7 +1284,7 @@ contract AutomatedVotingTest is DefaultStakingV2Setup { assertEq(automatedVotingInternals.isElectionFinalized(2), false); (, , , Enums.electionType theElectionType) = automatedVotingInternals .elections(1); - assertTrue(theElectionType == Enums.electionType.single); + assertTrue(theElectionType == Enums.electionType.replacement); automatedVotingInternals.cancelOngoingElectionsInternal(); assertEq(automatedVotingInternals.isElectionFinalized(1), true); assertEq(automatedVotingInternals.isElectionFinalized(2), true);