-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from GalloDaSballo/fix-quantstamp-fixes
Fix quantstamp fixes
- Loading branch information
Showing
18 changed files
with
704 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import brownie | ||
from brownie import * | ||
from helpers.utils import ( | ||
approx, | ||
) | ||
AddressZero = "0x0000000000000000000000000000000000000000" | ||
MaxUint256 = str(int(2 ** 256 - 1)) | ||
|
||
""" | ||
Tests for QSP-2 | ||
Optimized functions will burn shares if user uses them with 1 epoch range (same epoch start and end) | ||
-> Post-FIX -> Test Passes because of overflow protection | ||
""" | ||
|
||
def test_can_get_rewards_for_zero_due_to_overflow(initialized_contract, deployer, fake_vault, token): | ||
## Before fix, no revert, rewards are set, but no tokens are transfered | After fix, reverts | ||
with brownie.reverts(): | ||
initialized_contract.addBulkRewards(3, 4, fake_vault, token,[MaxUint256, 1], {"from": deployer}) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import brownie | ||
from brownie import * | ||
from helpers.utils import ( | ||
approx, | ||
) | ||
AddressZero = "0x0000000000000000000000000000000000000000" | ||
MaxUint256 = str(int(2 ** 256 - 1)) | ||
|
||
""" | ||
Tests for QSP-5 | ||
- Overflowing Total Supply cannot happen | ||
- Overflowing of points cannot happen | ||
""" | ||
|
||
def test_cannot_overflow_total_supply(initialized_contract, deployer, user, fake_vault, token): | ||
initialized_contract.notifyTransfer(AddressZero, user, MaxUint256, {"from": fake_vault}) | ||
|
||
## Adding above total supply will overflow | ||
with brownie.reverts(): | ||
initialized_contract.notifyTransfer(AddressZero, user, 1, {"from": fake_vault}) | ||
|
||
def test_cannot_overflow_points(initialized_contract, deployer, user, fake_vault, token): | ||
|
||
EPOCH = initialized_contract.currentEpoch() | ||
|
||
## Deposit max | ||
initialized_contract.notifyTransfer(AddressZero, user, MaxUint256, {"from": fake_vault}) | ||
|
||
chain.sleep(2) | ||
## Will revert after 1 second has elapsed | ||
with brownie.reverts(): | ||
initialized_contract.accrueVault(EPOCH, fake_vault, {"from": user}) | ||
|
||
## Any accrual of Vault must revert | ||
chain.sleep(initialized_contract.SECONDS_PER_EPOCH() + 1) | ||
chain.mine() | ||
|
||
## Will also revert at end of epoch because seconds are > 1 | ||
with brownie.reverts(): | ||
initialized_contract.accrueVault(EPOCH, fake_vault, {"from": user}) | ||
|
||
## Additionally any function for claiming rewards should also revert as while the revert above prevents the storage to be changed | ||
## The other functions that minimize storage usage are not going | ||
|
||
with brownie.reverts(): | ||
initialized_contract.claimRewardReference(EPOCH, fake_vault, token, user, {"from": user}) | ||
|
||
with brownie.reverts(): | ||
initialized_contract.claimReward(EPOCH, fake_vault, token, user, {"from": user}) | ||
|
||
with brownie.reverts(): | ||
initialized_contract.claimBulkTokensOverMultipleEpochs(EPOCH, EPOCH, fake_vault, [token], user, {"from": user}) | ||
|
||
with brownie.reverts(): | ||
initialized_contract.reap([EPOCH, EPOCH, fake_vault, [token]], {"from": user}) | ||
|
||
with brownie.reverts(): | ||
initialized_contract.tear([EPOCH, EPOCH, fake_vault, [token]], {"from": user}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.