Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable withdrawals outside voting period #39

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading