Skip to content

Commit

Permalink
refactor(allowed recipients): move some tests into separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
arwer13 committed Sep 20, 2022
1 parent 7a39018 commit 6b8950b
Show file tree
Hide file tree
Showing 3 changed files with 421 additions and 281 deletions.
68 changes: 68 additions & 0 deletions tests/evm_script_factories/test_top_up_allowed_recipients.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from datetime import datetime

from brownie.network import chain
from brownie import accounts, reverts

from eth_abi import encode_single


def test_top_up_factory_evm_script_validation(
AllowedRecipientsRegistry,
TopUpAllowedRecipients,
owner,
finance,
ldo,
easy_track,
voting,
bokkyPooBahsDateTimeContract,
stranger,
):
deployer = owner
trusted_caller = owner
manager = accounts[7]
recipient = deployer.address

registry = deployer.deploy(
AllowedRecipientsRegistry,
voting,
[manager],
[manager],
[manager],
[manager],
bokkyPooBahsDateTimeContract,
)
registry.addRecipient(recipient, "Test Recipient", {"from": manager})
registry.setLimitParameters(int(100e18), 12, {"from": manager})

top_up_factory = deployer.deploy(
TopUpAllowedRecipients, trusted_caller, registry, finance, ldo, easy_track
)

def make_call_data(recipients, amounts):
return encode_single("(address[],uint256[])", [recipients, amounts])

with reverts("EMPTY_DATA"):
top_up_factory.createEVMScript(trusted_caller, make_call_data([], []))

with reverts("LENGTH_MISMATCH"):
top_up_factory.createEVMScript(trusted_caller, make_call_data([recipient], []))

with reverts("LENGTH_MISMATCH"):
top_up_factory.createEVMScript(trusted_caller, make_call_data([], [123]))

with reverts("ZERO_AMOUNT"):
top_up_factory.createEVMScript(trusted_caller, make_call_data([recipient], [0]))

with reverts("ZERO_AMOUNT"):
top_up_factory.createEVMScript(
trusted_caller, make_call_data([recipient, recipient], [123, 0])
)

with reverts("RECIPIENT_NOT_ALLOWED"):
top_up_factory.createEVMScript(trusted_caller, make_call_data([stranger.address], [123]))

payout = int(1e18)
call_data = make_call_data([recipient], [payout])
evm_script = top_up_factory.createEVMScript(trusted_caller, call_data)
assert top_up_factory.decodeEVMScriptCallData(call_data) == ([recipient], [payout])
assert "Top up allowed recipients".encode("utf-8").hex() in str(evm_script)
Loading

0 comments on commit 6b8950b

Please sign in to comment.