-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(allowed recipients): move some tests into separate files
- Loading branch information
Showing
3 changed files
with
421 additions
and
281 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
tests/evm_script_factories/test_top_up_allowed_recipients.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.