Skip to content

Commit

Permalink
test: full loss
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Sep 10, 2024
1 parent 2fea2ac commit be419b9
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions tests/unit/vault/test_shares.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,61 @@ def test__mint_shares_with_zero_total_supply_positive_assets(
# shares should be minted at 1:1
assert vault.balanceOf(fish) == amount
assert vault.pricePerShare() > (10 ** vault.decimals())


def test__deposit_with_zero_total_assets_positive_supply(
asset, fish_amount, fish, initial_set_up, gov
):
amount = fish_amount // 10

vault, strategy, _ = initial_set_up(asset, gov, amount, fish)

# Create a loss
asset.transfer(gov, amount, sender=strategy)
strategy.report(sender=gov)

assert strategy.convertToAssets(amount) == 0

vault.process_report(strategy, sender=gov)

assert vault.totalAssets() == 0
assert vault.totalSupply() != 0

with ape.reverts("cannot mint zero"):
vault.deposit(amount, fish, sender=fish)

# shares should not be
assert vault.balanceOf(fish) == amount
assert vault.pricePerShare() == 0
assert vault.convertToShares(amount) == 0
assert vault.convertToAssets(amount) == 0
# assert vault.maxDeposit(fish) == 0


def test__mint_with_zero_total_assets_positive_supply(
asset, fish_amount, fish, initial_set_up, gov
):
amount = fish_amount // 10

vault, strategy, _ = initial_set_up(asset, gov, amount, fish)

# Create a loss
asset.transfer(gov, amount, sender=strategy)
strategy.report(sender=gov)

assert strategy.convertToAssets(amount) == 0

vault.process_report(strategy, sender=gov)

assert vault.totalAssets() == 0
assert vault.totalSupply() != 0

with ape.reverts("cannot deposit zero"):
vault.mint(amount, fish, sender=fish)

# shares should not be
assert vault.balanceOf(fish) == amount
assert vault.pricePerShare() == 0
assert vault.convertToShares(amount) == 0
assert vault.convertToAssets(amount) == 0
# assert vault.maxMint(fish) == 0

0 comments on commit be419b9

Please sign in to comment.