diff --git a/tests/lens/test_lens_is_equivalent.py b/tests/lens/test_lens_is_equivalent.py index b55be7c..8b3991a 100644 --- a/tests/lens/test_lens_is_equivalent.py +++ b/tests/lens/test_lens_is_equivalent.py @@ -93,4 +93,52 @@ def test_claimBulkTokensOverMultipleEpochsOptimized_basic(initialized_contract, ## Verify you got the entire reward amount assert token.balanceOf(user) == initial_reward_balance + REWARD_AMOUNT - assert calculated_amount == REWARD_AMOUNT \ No newline at end of file + assert calculated_amount == REWARD_AMOUNT + +def test_getClaimableBulkRewards_coverage(initialized_contract, user, fake_vault, token, second_user): + INITIAL_DEPOSIT = 1e18 + REWARD_AMOUNT = 1e20 + EPOCH = initialized_contract.currentEpoch() + + ## Add rewards here + token.approve(initialized_contract, MaxUint256, {"from": user}) + initialized_contract.addReward(EPOCH, fake_vault, token, REWARD_AMOUNT, {"from": user}) + + ## User didn't deposited, they have 0 points + assert initialized_contract.points(EPOCH, fake_vault, user) == 0 + + ## Because user has the tokens too, we check the balance here + initial_reward_balance = token.balanceOf(user) + + ## Test revert cases: require(params.epochStart <= params.epochEnd); + claimParams = [EPOCH + 1, EPOCH, fake_vault.address, [token.address]] + with brownie.reverts(): + quote = initialized_contract.getClaimableBulkRewards(claimParams, user) + + ## Test revert cases: require(params.epochEnd < currentEpoch()); + claimParams = [EPOCH, EPOCH + 1000, fake_vault.address, [token.address]] + with brownie.reverts(): + quote = initialized_contract.getClaimableBulkRewards(claimParams, user) + + ## Wait the epoch to end + chain.sleep(initialized_contract.SECONDS_PER_EPOCH() + 1) + chain.mine() + claimParams = [EPOCH, EPOCH, fake_vault.address, [token.address]] + quote = initialized_contract.getClaimableBulkRewards(claimParams, user) + after_reward_balance = token.balanceOf(user) + assert after_reward_balance == initial_reward_balance ## no reward here since no deposit + + ## Only deposit so we get 100% of rewards and claim midway + initialized_contract.notifyTransfer(AddressZero, user, INITIAL_DEPOSIT, {"from": fake_vault}) + nxtEPOCH = initialized_contract.currentEpoch() + initialized_contract.addReward(nxtEPOCH, fake_vault, token, REWARD_AMOUNT, {"from": user}) + chain.sleep(initialized_contract.SECONDS_PER_EPOCH() + 1) + chain.mine() + initialized_contract.claimReward(nxtEPOCH, fake_vault, token, user, {"from": user}) + + ## Test revert cases: require(pointsWithdrawn[epochId][params.vault][user][token] == 0); + claimParams = [nxtEPOCH, nxtEPOCH, fake_vault.address, [token.address]] + with brownie.reverts(): + quote = initialized_contract.getClaimableBulkRewards(claimParams, user) + + \ No newline at end of file diff --git a/tests/unit/test_accrue_points.py b/tests/unit/test_accrue_points.py index 4ed3692..c84da7b 100644 --- a/tests/unit/test_accrue_points.py +++ b/tests/unit/test_accrue_points.py @@ -119,4 +119,7 @@ def test_revert_if_accrue_future(initialized_contract, user, fake_vault): initialized_contract.accrueUser(epoch + 1, fake_vault, user) with brownie.reverts(): - initialized_contract.accrueVault(epoch + 1, fake_vault) \ No newline at end of file + initialized_contract.accrueVault(epoch + 1, fake_vault) + + with brownie.reverts(): + initialized_contract.getVaultTimeLeftToAccrue(epoch + 1000, fake_vault) \ No newline at end of file diff --git a/tests/unit/test_time_to_accrue_math.py b/tests/unit/test_time_to_accrue_math.py index cec722d..4179300 100644 --- a/tests/unit/test_time_to_accrue_math.py +++ b/tests/unit/test_time_to_accrue_math.py @@ -137,4 +137,15 @@ def test_if_wait_one_more_epoch(initialized_contract, user, fake_vault): epoch_two_end = epoch_two[1] assert initialized_contract.getUserTimeLeftToAccrue(2, fake_vault, user) == epoch_two_end - epoch_two_start ## Accrue happens at deposit +def test_getUserTimeLeftToAccure_revert(initialized_contract, user, fake_vault): + INITIAL_DEPOSIT = 1e18 + + EPOCH = 1 + + deposit_tx = initialized_contract.notifyTransfer(AddressZero, user, INITIAL_DEPOSIT, {"from": fake_vault}) + time_of_deposit = deposit_tx.timestamp + ## Test revert case: require(epochId <= currentEpoch()); + with brownie.reverts(): + initialized_contract.getUserTimeLeftToAccrue(EPOCH + 1000, fake_vault, user) + diff --git a/tests/unit/test_weird.py b/tests/unit/test_weird.py index 8f6b236..93dad28 100644 --- a/tests/unit/test_weird.py +++ b/tests/unit/test_weird.py @@ -35,6 +35,10 @@ def test_zero_balance_epoch_two(initialized_contract, user, fake_vault, token): ## Check that we have non-zero balance and totalSupply for current assert initialized_contract.getBalanceAtEpoch(initialized_contract.currentEpoch(), fake_vault, user)[0] == INITIAL_DEPOSIT assert initialized_contract.getTotalSupplyAtEpoch(initialized_contract.currentEpoch(), fake_vault)[0] == INITIAL_DEPOSIT + + ## Test revert case: require(epochId <= currentEpoch()); + with brownie.reverts(): + initialized_contract.getTotalSupplyAtEpoch(2000, fake_vault) def test_add_reward_zero_add(initialized_contract, user, fake_vault, token):