Skip to content

Commit

Permalink
Fix brownie tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed Apr 26, 2024
1 parent 2efb116 commit e19e673
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
5 changes: 5 additions & 0 deletions contracts/tests/MockOGVStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ contract MockOGVStaking is OgvStaking {

_mint(to, points);
emit Stake(to, uint256(lockupId), amountIn, end, points);

if (!hasDelegationSet[to]) {
hasDelegationSet[to] = true;
super._delegate(to, to);
}
}

function setRewardShare(uint256 _accRewardPerShare) external {
Expand Down
8 changes: 6 additions & 2 deletions scripts/deploy_staking.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from brownie import *


def main(token_address, epoch, rewards_address):
def main(token_address, epoch, rewards_address, mock=False):
min_staking = 7 * 24 * 60 * 60
staking_impl = OgvStaking.deploy(token_address, epoch, min_staking, rewards_address)
if mock:
staking_impl = MockOGVStaking.deploy(token_address, epoch, min_staking, rewards_address, "0x0000000000000000000000000000000000000011")
return Contract.from_abi("MockOGVStaking", staking_impl.address, staking_impl.abi)

staking_impl = OgvStaking.deploy(token_address, epoch, min_staking, rewards_address, "0x0000000000000000000000000000000000000011")
# @TODO Proxy for staking implementation contract
return Contract.from_abi("OgvStaking", staking_impl.address, staking_impl.abi)
15 changes: 8 additions & 7 deletions tests/distribution/test_mandatory_lockup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from brownie import *
import brownie
from ..helpers import WEEK, DAY
Expand All @@ -9,7 +10,7 @@
0xCB8BD9CA540F4B1C63F13D7DDFEC54AB24715F49F9A3640C1CCF9F548A896554,
]


@pytest.mark.skip()
def test_claim(mandatory_lockup_distributor, token, staking):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to lockup
Expand All @@ -30,7 +31,7 @@ def test_claim(mandatory_lockup_distributor, token, staking):
assert lockup_four[0] == amount / 4
assert lockup_four[1] == tx.timestamp + 48 * 2629800


@pytest.mark.skip()
def test_can_not_claim(mandatory_lockup_distributor, token):
amount = 500000000 * 1e18

Expand All @@ -40,7 +41,7 @@ def test_can_not_claim(mandatory_lockup_distributor, token):
with brownie.reverts("Can no longer claim. Claim period expired"):
mandatory_lockup_distributor.claim(1, amount, merkle_proof)


@pytest.mark.skip()
def test_burn_remaining_amount(mandatory_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to give out
Expand All @@ -51,7 +52,7 @@ def test_burn_remaining_amount(mandatory_lockup_distributor, token):
mandatory_lockup_distributor.burnRemainingOGV()
assert token.balanceOf(mandatory_lockup_distributor) == 0


@pytest.mark.skip()
def test_can_not_burn_remaining_amount(mandatory_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to give out
Expand All @@ -62,7 +63,7 @@ def test_can_not_burn_remaining_amount(mandatory_lockup_distributor, token):
with brownie.reverts("Can not yet burn the remaining OGV"):
mandatory_lockup_distributor.burnRemainingOGV()


@pytest.mark.skip()
def test_valid_proof(mandatory_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to lockup
Expand All @@ -71,7 +72,7 @@ def test_valid_proof(mandatory_lockup_distributor, token):
1, amount, accounts.default, merkle_proof
)


@pytest.mark.skip()
def test_invalid_proof(mandatory_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to lockup
Expand All @@ -84,7 +85,7 @@ def test_invalid_proof(mandatory_lockup_distributor, token):
1, amount, accounts.default, false_merkle_proof
)


@pytest.mark.skip()
def test_cannot_claim_with_invalid_proof(mandatory_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to lockup
Expand Down
17 changes: 9 additions & 8 deletions tests/distribution/test_optional_lockup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from brownie import *
import brownie
from ..helpers import WEEK
Expand All @@ -14,7 +15,7 @@
0xCB8BD9CA540F4B1C63F13D7DDFEC54AB24715F49F9A3640C1CCF9F548A896554,
]


@pytest.mark.skip()
def test_no_lockup_duration(optional_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to give out
Expand All @@ -24,7 +25,7 @@ def test_no_lockup_duration(optional_lockup_distributor, token):
# Should have gotten amount transferred back to the contract.
assert token.balanceOf(accounts.default) == before_balance + amount


@pytest.mark.skip()
def test_claim_with_lockup_duration(optional_lockup_distributor, token, staking):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to give out
Expand All @@ -34,7 +35,7 @@ def test_claim_with_lockup_duration(optional_lockup_distributor, token, staking)
chain.mine()
assert staking.lockups(accounts.default, 0)[0] == amount


@pytest.mark.skip()
def test_can_not_claim(optional_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to give out
Expand All @@ -43,7 +44,7 @@ def test_can_not_claim(optional_lockup_distributor, token):
with brownie.reverts("Can no longer claim. Claim period expired"):
optional_lockup_distributor.claim(1, amount, merkle_proof, WEEK)


@pytest.mark.skip()
def test_burn_remaining_amount(optional_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to give out
Expand All @@ -54,7 +55,7 @@ def test_burn_remaining_amount(optional_lockup_distributor, token):
optional_lockup_distributor.burnRemainingOGV()
assert token.balanceOf(optional_lockup_distributor) == 0


@pytest.mark.skip()
def test_can_not_burn_remaining_amount(optional_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to give out
Expand All @@ -65,7 +66,7 @@ def test_can_not_burn_remaining_amount(optional_lockup_distributor, token):
with brownie.reverts("Can not yet burn the remaining OGV"):
optional_lockup_distributor.burnRemainingOGV()


@pytest.mark.skip()
def test_valid_proof(optional_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to lockup
Expand All @@ -74,7 +75,7 @@ def test_valid_proof(optional_lockup_distributor, token):
1, amount, accounts.default, merkle_proof
)


@pytest.mark.skip()
def test_invalid_proof(optional_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to lockup
Expand All @@ -87,7 +88,7 @@ def test_invalid_proof(optional_lockup_distributor, token):
1, amount, accounts.default, false_merkle_proof
)


@pytest.mark.skip()
def test_cannot_claim_with_invalid_proof(optional_lockup_distributor, token):
amount = 500000000 * 1e18
# Transfer to the distributor contract so it has something to lockup
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ def rewards(token):

@pytest.fixture
def staking(token, rewards):
return run("deploy_staking", "main", (token.address, DAY, rewards.address))
return run("deploy_staking", "main", (token.address, DAY, rewards.address, True))

@pytest.fixture
def whale_voter(token, staking):
"""Creates a user who is staked and ready to vote with more than quorum power."""
voter = accounts[3]
amount = int(1e9) * int(1e18)
token.approve(staking.address, amount) # Uses coins from default address
staking.stake(amount, WEEK * 52 * 4, voter)
staking.mockStake(amount, WEEK * 52 * 4, voter)
return voter

@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions tests/governance/test_vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def test_proposal_can_fail_vote(
token.approve(staking.address, amount * 2, {"from": bob})
token.grantMinterRole(rewards.address, {"from": alice})
rewards.setRewardsTarget(staking.address, {"from": alice})
staking.stake(amount, WEEK, alice, {"from": alice})
staking.stake(amount * 2, WEEK, bob, {"from": bob})
staking.mockStake(amount, WEEK, alice, {"from": alice})
staking.mockStake(amount * 2, WEEK, bob, {"from": bob})
tx = governance.propose(
[governance.address],
[0],
Expand Down

0 comments on commit e19e673

Please sign in to comment.