Skip to content

Commit

Permalink
fix: bribe unit tests for resetting allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
nican0r committed Oct 18, 2024
1 parent 5bdf44e commit e7c94d0
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions test/BribeInitiative.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {BribeInitiative} from "../src/BribeInitiative.sol";

import {MockStakingV1} from "./mocks/MockStakingV1.sol";

// coverage: forge coverage --mc BribeInitiativeTest --report lcov
contract BribeInitiativeTest is Test {
MockERC20 private lqty;
MockERC20 private lusd;
Expand Down Expand Up @@ -150,7 +149,7 @@ contract BribeInitiativeTest is Test {
bribeInitiative.totalLQTYAllocatedByEpoch(governance.epoch());
(uint88 userLQTYAllocated2, ) =
bribeInitiative.lqtyAllocatedByUserAtEpoch(user1, governance.epoch());
assertEq(totalLQTYAllocated2, 10e18);
assertEq(totalLQTYAllocated2, 5e18);
assertEq(userLQTYAllocated1, 5e18);

}
Expand All @@ -170,15 +169,13 @@ contract BribeInitiativeTest is Test {
assertEq(totalLQTYAllocated1, 5e18);
assertEq(userLQTYAllocated1, 5e18);

// vm.warp(block.timestamp + EPOCH_DURATION);

_allocateLQTY(user1, 5e18, 0);
(uint88 totalLQTYAllocated2,) =
bribeInitiative.totalLQTYAllocatedByEpoch(governance.epoch());
(uint88 userLQTYAllocated2,) =
bribeInitiative.lqtyAllocatedByUserAtEpoch(user1, governance.epoch());
assertEq(totalLQTYAllocated2, 10e18);
assertEq(userLQTYAllocated2, 10e18);
assertEq(totalLQTYAllocated2, 5e18);
assertEq(userLQTYAllocated2, 5e18);
}

function test_allocation_stored_in_list() public {
Expand Down Expand Up @@ -420,7 +417,6 @@ contract BribeInitiativeTest is Test {
assertEq(userShareOfTotalAllocated, userShareOfTotalBribeForEpoch, "userShareOfTotalAllocated != userShareOfTotalBribeForEpoch");
}

/// forge-config: default.fuzz.runs = 50000
function test_claimedBribes_fraction_fuzz(uint88 user1StakeAmount, uint88 user2StakeAmount, uint88 user3StakeAmount) public {
// =========== epoch 1 ==================
user1StakeAmount = uint88(bound(uint256(user1StakeAmount), 1, lqty.balanceOf(user1)));
Expand Down Expand Up @@ -610,7 +606,7 @@ contract BribeInitiativeTest is Test {
assertEq(bribeTokenAmount, 1e18);

// decrease user allocation for the initiative
_allocateLQTY(user1, -1e18, 0);
_allocateLQTY(user1, 0, 0);

// check if user can still receive bribes after removing votes
claimEpoch = governance.epoch() - 1; // claim for epoch 4
Expand Down Expand Up @@ -667,8 +663,8 @@ contract BribeInitiativeTest is Test {
bribeInitiative.totalLQTYAllocatedByEpoch(governance.epoch());
(uint88 userLQTYAllocated,) =
bribeInitiative.lqtyAllocatedByUserAtEpoch(user1, governance.epoch());
assertEq(totalLQTYAllocated, 1e18, "total allocation");
assertEq(userLQTYAllocated, 1e18, "user allocation");
assertEq(totalLQTYAllocated, 5e17, "total allocation");
assertEq(userLQTYAllocated, 5e17, "user allocation");

vm.warp(block.timestamp + (EPOCH_DURATION));
// We are now at epoch + 1 // Should be able to claim epoch - 1
Expand All @@ -682,7 +678,7 @@ contract BribeInitiativeTest is Test {
_claimBribe(user1, governance.epoch(), governance.epoch() - 1, governance.epoch() - 1, true);

// decrease user allocation for the initiative
_allocateLQTY(user1, -1e18, 0);
_allocateLQTY(user1, 0, 0);

(userLQTYAllocated,) = bribeInitiative.lqtyAllocatedByUserAtEpoch(user1, governance.epoch());
(totalLQTYAllocated,) = bribeInitiative.totalLQTYAllocatedByEpoch(governance.epoch());
Expand Down

0 comments on commit e7c94d0

Please sign in to comment.