Skip to content

Commit

Permalink
Allow resets outside voting period
Browse files Browse the repository at this point in the history
  • Loading branch information
xavikh committed Dec 13, 2024
1 parent ae21ce9 commit 2e9db89
Show file tree
Hide file tree
Showing 2 changed files with 35 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
37 changes: 33 additions & 4 deletions test/voting/GaugeVote.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,44 @@ 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 epoch
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);
}

//Check vp is 0 after reset
//Check gaugeVotes are same before and after reset, and are 0 after next voting period
//

// 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 2e9db89

Please sign in to comment.