Skip to content

Commit

Permalink
test: dumper tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Jun 4, 2024
1 parent 1d1f995 commit 80c5736
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
8 changes: 8 additions & 0 deletions contracts/Mocks/MockTradeFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.18;

contract MockTradeFactory {
function enable(address, address) external {}

function disable(address, address) external {}
}
78 changes: 78 additions & 0 deletions tests/splitter/test_dumper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import ape
from ape import project


def test_dumper(asset, vault, accountant, daddy, brain, amount):
splitter = daddy
tf = brain.deploy(project.MockTradeFactory)
dumper = brain.deploy(
project.Dumper, brain, accountant.address, splitter, tf, vault
)
accountant.setFeeRecipient(dumper, sender=daddy)

assert dumper.governance() == brain
assert dumper.accountant() == accountant
assert dumper.tradeFactory() == tf
assert dumper.splitToken() == vault
assert dumper.rewardTokens() == []

with ape.reverts("!governance"):
dumper.addTokens([asset], sender=daddy)

with ape.reverts("!governance"):
dumper.addToken(asset, sender=daddy)

dumper.addTokens([asset], sender=brain)

assert dumper.rewardTokens() == [asset]

asset.mint(accountant, amount, sender=brain)

assert asset.balanceOf(accountant) == amount
assert asset.balanceOf(dumper) == 0
assert asset.balanceOf(splitter) == 0

with ape.reverts("!governance"):
dumper.claim([asset], sender=daddy)

dumper.claim([asset], sender=brain)

assert asset.balanceOf(accountant) == 0
assert asset.balanceOf(dumper) == amount
assert vault.balanceOf(dumper) == 0
assert asset.balanceOf(splitter) == 0
assert vault.balanceOf(splitter) == 0

asset.transferFrom(dumper, tf, amount, sender=tf)

assert asset.balanceOf(accountant) == 0
assert asset.balanceOf(dumper) == 0
assert asset.balanceOf(tf) == amount

asset.approve(vault, amount, sender=tf)
vault.deposit(amount, dumper, sender=tf)

assert asset.balanceOf(accountant) == 0
assert asset.balanceOf(dumper) == 0
assert vault.balanceOf(dumper) == amount
assert asset.balanceOf(splitter) == 0
assert vault.balanceOf(splitter) == 0

dumper.distribute(sender=daddy)

assert asset.balanceOf(accountant) == 0
assert asset.balanceOf(dumper) == 0
assert vault.balanceOf(dumper) == 1
assert asset.balanceOf(splitter) == 0
assert vault.balanceOf(splitter) == amount - 1

with ape.reverts("!governance"):
dumper.setSplitToken(asset, sender=daddy)

dumper.setSplitToken(asset, sender=brain)

assert dumper.governance() == brain
assert dumper.accountant() == accountant
assert dumper.tradeFactory() == tf
assert dumper.splitToken() == asset
assert dumper.rewardTokens() == [asset]

0 comments on commit 80c5736

Please sign in to comment.