Skip to content

Commit

Permalink
feat: more realistic lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
GalloDaSballo committed Jan 13, 2022
1 parent 59958ac commit 04a3c4e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions contracts/RemBadger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ contract RemBadger is ERC20Upgradeable, SettAccessControlDefended, PausableUpgra

function _depositFor(address recipient, uint256 _amount) internal virtual {
require(!depositsEnded, "No longer accepting Deposits");
_onlyGovernance();
uint256 _pool = balance();
uint256 _before = token.balanceOf(address(this));
token.safeTransferFrom(msg.sender, address(this), _amount);
Expand Down
9 changes: 5 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ def deployed():
"""
Deploys, vault, controller and strats and wires them up for you to test
"""
deployer = accounts[0]
a0 = accounts[0]

strategist = deployer
keeper = deployer
guardian = deployer
strategist = a0
keeper = a0
guardian = a0

governance = accounts.at(BADGER_DEV_MULTISIG, force=True)
deployer = governance

controller = Controller.deploy({"from": deployer})
controller.initialize(BADGER_DEV_MULTISIG, strategist, keeper, BADGER_DEV_MULTISIG)
Expand Down
27 changes: 22 additions & 5 deletions tests/test_remBadger_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,34 @@ def test_lifecycle_for_rem_badger(deployer, sett, strategy, controller, want, go
assert want.balanceOf(sett) == 0

want.approve(sett, MaxUint256, {"from": deployer})
## Works
sett.deposit(depositAmount, {"from": deployer})

assert sett.getPricePerFullShare() == 1e18
assert sett.totalSupply() == 0

print("Initial ppfs")
print(1e18)

## Mint200k more shares
## Mint 2k more shares
sett.mintExtra(2000e18, {"from": governance})

assert sett.totalSupply() == 2000e18

last_ppfs = sett.getPricePerFullShare()
assert last_ppfs < 1e18 ## We diluted

print("Diluted PPFS")
print(1e18)

sett.addWant(depositAmount, {"from": deployer})

assert sett.getPricePerFullShare() > last_ppfs
last_ppfs = sett.getPricePerFullShare()

print("New ppfs 1")
print(sett.getPricePerFullShare())

sett.addWant(restOfTokens, {"from": deployer})

assert sett.getPricePerFullShare() > last_ppfs
assert sett.getPricePerFullShare() > last_ppfs

print("New ppfs 2")
print(sett.getPricePerFullShare())
6 changes: 0 additions & 6 deletions tests/test_remBadger_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
See test_strategy_permissions, for tests at the permissions level
"""
def test_brick_permissions(deployer, sett, rando, strategist, governance):
with brownie.reverts("onlyGovernance"):
sett.brickDeposits({"from": deployer})

with brownie.reverts("onlyGovernance"):
sett.brickDeposits({"from": strategist})

Expand All @@ -22,9 +19,6 @@ def test_brick_permissions(deployer, sett, rando, strategist, governance):
sett.brickDeposits({"from": governance})

def test_mint_permissions(deployer, sett, rando, strategist, governance):
with brownie.reverts("onlyGovernance"):
sett.mintExtra(123, {"from": deployer})

with brownie.reverts("onlyGovernance"):
sett.mintExtra(123, {"from": strategist})

Expand Down

0 comments on commit 04a3c4e

Please sign in to comment.