diff --git a/test/invariants/PrizePoolInvariants.t.sol b/test/invariants/PrizePoolInvariants.t.sol index 1e3df48..6a5fd88 100644 --- a/test/invariants/PrizePoolInvariants.t.sol +++ b/test/invariants/PrizePoolInvariants.t.sol @@ -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" ); } diff --git a/test/invariants/helpers/PrizePoolFuzzHarness.sol b/test/invariants/helpers/PrizePoolFuzzHarness.sol index 846fb39..1fc8892 100644 --- a/test/invariants/helpers/PrizePoolFuzzHarness.sol +++ b/test/invariants/helpers/PrizePoolFuzzHarness.sol @@ -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( @@ -54,6 +54,7 @@ contract PrizePoolFuzzHarness is CommonBase, StdCheats { tierShares, reserveShares ); + vm.startPrank(address(this)); prizePool = new PrizePool(params); prizePool.setDrawManager(drawManager); } @@ -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)))); }