Skip to content

Commit

Permalink
Merge pull request #82 from GenerationSoftware/gen-1085-prize-pool-in…
Browse files Browse the repository at this point in the history
…variant-test-is-broken

Fixed prize pool invariant test
  • Loading branch information
asselstine authored Jan 30, 2024
2 parents 8313523 + 2133913 commit ddd70f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
14 changes: 4 additions & 10 deletions test/invariants/PrizePoolInvariants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,16 @@ contract PrizePoolInvariants is Test {
function setUp() external {
prizePoolHarness = new PrizePoolFuzzHarness();

bytes4[] memory selectors = new bytes4[](6);
selectors[0] = prizePoolHarness.contributePrizeTokens.selector;
selectors[1] = prizePoolHarness.contributeReserve.selector;
selectors[2] = prizePoolHarness.allocateRewardFromReserve.selector;
selectors[3] = prizePoolHarness.withdrawClaimReward.selector;
selectors[4] = prizePoolHarness.claimPrizes.selector;
selectors[5] = prizePoolHarness.awardDraw.selector;
targetSelector(FuzzSelector({ addr: address(prizePoolHarness), selectors: selectors }));
targetContract(address(prizePoolHarness));
}

function invariant_balance_equals_accountedBalance() external {
function invariant_balance_equals_accounted() external {
uint balance = prizePoolHarness.token().balanceOf(address(prizePoolHarness.prizePool()));
uint accounted = prizePoolHarness.prizePool().accountedBalance();

assertEq(
balance,
prizePoolHarness.prizePool().accountedBalance(),
accounted,
"balance does not match accountedBalance"
);
}
Expand Down
10 changes: 6 additions & 4 deletions test/invariants/helpers/PrizePoolFuzzHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ contract PrizePoolFuzzHarness is CommonBase, StdCheats {
uint256 currentTime;

constructor() {
vm.warp(365 days);

currentTime = 365 days;
claimer = makeAddr("claimer");
address drawManager = address(this);
uint48 drawPeriodSeconds = 1 hours;
currentTime = block.timestamp;
uint48 awardDrawStartsAt = uint48(currentTime);
uint8 numberOfTiers = 3;
uint8 tierShares = 100;
uint8 reserveShares = 10;
SD1x18 smoothing = SD1x18.wrap(0.9e18);

vm.warp(currentTime);

token = new ERC20Mintable("name", "SYMBOL");
TwabController twabController = new TwabController(
Expand All @@ -54,6 +54,7 @@ contract PrizePoolFuzzHarness is CommonBase, StdCheats {
tierShares,
reserveShares
);
vm.startPrank(address(this));
prizePool = new PrizePool(params);
prizePool.setDrawManager(drawManager);
}
Expand Down Expand Up @@ -109,10 +110,11 @@ contract PrizePoolFuzzHarness is CommonBase, StdCheats {
}
}

function awardDraw() public {
function awardDraw() public warp {
uint256 drawToAwardClosesAt = prizePool.drawClosesAt(prizePool.getDrawIdToAward());
currentTime = drawToAwardClosesAt;
vm.warp(currentTime);
// vm.startPrank(address(this));
prizePool.awardDraw(uint256(keccak256(abi.encode(block.timestamp))));
}

Expand Down

0 comments on commit ddd70f7

Please sign in to comment.