Skip to content

Commit

Permalink
Merge pull request #39 from aragon/feature/rd-985-enable-withdrawals-…
Browse files Browse the repository at this point in the history
…outside-of-voting-periods

Enable withdrawals outside voting period
  • Loading branch information
jordaniza authored Dec 13, 2024
2 parents f5cbe5b + 61cbba8 commit dbdda9f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/voting/SimpleGaugeVoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ contract SimpleGaugeVoter is
}

/*///////////////////////////////////////////////////////////////
Voting
Voting
//////////////////////////////////////////////////////////////*/

/// @notice extrememly simple for loop. We don't need reentrancy checks in this implementation
Expand Down Expand Up @@ -181,7 +181,7 @@ contract SimpleGaugeVoter is
voteData.lastVoted = block.timestamp;
}

function reset(uint256 _tokenId) external nonReentrant whenNotPaused whenVotingActive {
function reset(uint256 _tokenId) external nonReentrant whenNotPaused {
if (!IVotingEscrow(escrow).isApprovedOrOwner(msg.sender, _tokenId))
revert NotApprovedOrOwner();
if (!isVoting(_tokenId)) revert NotCurrentlyVoting();
Expand Down
32 changes: 28 additions & 4 deletions test/voting/GaugeVote.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,39 @@ contract TestGaugeVote is GaugeVotingBase {
vm.expectRevert(VotingInactive.selector);
voter.vote(0, votes);

// try to reset
vm.expectRevert(VotingInactive.selector);
voter.reset(0);

// vote multiple
vm.expectRevert(VotingInactive.selector);
voter.voteMultiple(ids, votes);
}

function testFuzz_canResetInDistributionPeriod() public {
// create the vote
votes.push(GaugeVote(1, gauge));

// vote
vm.startPrank(owner);
{
voter.vote(tokenId, votes);
}
vm.stopPrank();

// check the vote
assertEq(voter.isVoting(tokenId), true);

// warp to the next distribution period
vm.warp(block.timestamp + 1 weeks);
vm.assume(!voter.votingActive());

// try to reset
vm.startPrank(owner);
{
voter.reset(tokenId);
}
vm.stopPrank();

assertEq(voter.isVoting(tokenId), false);
}

// can't vote if you don't own the token
function testCannotVoteIfYouDontOwnTheToken() public {
// try to vote as this address (not the holder)
Expand Down

0 comments on commit dbdda9f

Please sign in to comment.