Skip to content

Commit

Permalink
Add inclusion vote tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xkorin committed Feb 21, 2024
1 parent 75ce328 commit c6ac506
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions contracts/governance/InclusionVote.vy
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,18 @@ def _vote_open() -> bool:
@external
@view
def enabled() -> bool:
"""
@notice Query whether the inclusion voting is enabled this epoch
@return True: inclusion vote is enabled this epoch, False: inclusion vote is not enabled
"""
return self._enabled()

@internal
@view
def _enabled() -> bool:
"""
@notice Query whether the inclusion voting is enabled this epoch
"""
return self._epoch() == self.enable_epoch

@external
Expand Down
23 changes: 23 additions & 0 deletions tests/governance/test_inclusion_vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ def test_finalize(chain, deployer, alice, bob, measure, token, token2, voting):
voting.finalize_epochs(sender=bob)
assert voting.latest_finalized_epoch() == epoch - 1

# cant apply before finalizing
with ape.reverts():
voting.apply(token2, sender=alice)

# finalize
chain.pending_timestamp += WEEK
voting.finalize_epochs(sender=bob)
Expand All @@ -228,6 +232,25 @@ def test_finalize(chain, deployer, alice, bob, measure, token, token2, voting):
# winners cant apply anymore
with ape.reverts():
voting.apply(token, sender=alice)

# can apply again if not a winner
voting.apply(token2, sender=alice)

def test_auto_finalize(chain, deployer, alice, bob, measure, token, token2, voting):
epoch = voting.epoch()
voting.set_rate_provider(token, RATE_PROVIDER, sender=deployer)
voting.set_rate_provider(token2, RATE_PROVIDER2, sender=deployer)
voting.apply(token, sender=alice)
voting.apply(token2, sender=alice)
measure.set_vote_weight(alice, UNIT, sender=alice)
chain.pending_timestamp += VOTE_START
voting.vote([1000, 6000, 3000], sender=alice)

chain.pending_timestamp += 3 * EPOCH_LENGTH
chain.mine()
assert voting.latest_finalized_epoch() == epoch - 1
voting.finalize_epochs(sender=bob)
assert voting.latest_finalized_epoch() == epoch + 2

def test_blank_winner(chain, deployer, alice, bob, measure, token, voting):
epoch = voting.epoch()
Expand Down

0 comments on commit c6ac506

Please sign in to comment.