-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17fff35
commit ef20673
Showing
6 changed files
with
92 additions
and
5 deletions.
There are no files selected for viewing
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,5 @@ | ||
from hypothesis.stateful import RuleBasedStateMachine | ||
|
||
|
||
class E2EStatefulBase(RuleBasedStateMachine): | ||
pass |
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,63 @@ | ||
import boa | ||
from hypothesis.strategies import composite, integers | ||
|
||
from tests.hypothesis.utils import ( | ||
original_vault_deployer, | ||
vault_factory_deployer, | ||
erc20_deployer, | ||
rewards_handler_deployer, | ||
hash_to_address, | ||
) | ||
from boa.test.strategies import strategy as boa_st | ||
|
||
original_vault = original_vault_deployer(override_address=hash_to_address("original_vault")) | ||
|
||
ZERO = boa.eval("empty(address)") | ||
|
||
addresses = boa_st("address").filter(lambda addr: addr != ZERO) | ||
|
||
# we don't use the `address` strategy here to | ||
# avoid address collisions that are not realistic | ||
yearn_gov = boa.env.generate_address() | ||
role_manager = boa.env.generate_address() | ||
|
||
vault_factory = vault_factory_deployer( | ||
"mock factory", original_vault, yearn_gov, override_address=hash_to_address("vault_factory") | ||
) | ||
|
||
crvusd = erc20_deployer(override_address=hash_to_address("crvusd")) | ||
|
||
|
||
@composite | ||
def vault(draw): | ||
_address = vault_factory.deploy_new_vault(crvusd, "Staked crvUSD", "st-crvUSD", role_manager, 0) | ||
|
||
# we just "cast the interface" on the address | ||
return original_vault_deployer.at(_address) | ||
|
||
|
||
bps = integers(min_value=1, max_value=10_000) | ||
|
||
minimum_weights = bps | ||
|
||
scaling_factors = integers() | ||
|
||
|
||
@composite | ||
def rewards_handler(draw): | ||
_rewards_handler = rewards_handler_deployer( | ||
crvusd, | ||
_vault := draw(vault()), | ||
draw(minimum_weights), | ||
draw(scaling_factors), | ||
draw(addresses), # TODO mock this | ||
draw(addresses), | ||
) | ||
|
||
_vault.set_role(_rewards_handler, 1, sender=role_manager) | ||
|
||
return _rewards_handler | ||
|
||
|
||
if __name__ == "__main__": | ||
rewards_handler().example() |
File renamed without changes.
Empty file.
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
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,19 @@ | ||
import boa | ||
from eth_account import Account | ||
import hashlib | ||
|
||
rewards_handler_deployer = boa.load_partial("contracts/RewardsHandler.vy") | ||
original_vault_deployer = boa.load_partial("contracts/yearn/VaultV3.vy") | ||
vault_factory_deployer = boa.load_partial("contracts/yearn/VaultFactory.vy") | ||
erc20_deployer = boa.load_partial("tests/mocks/MockERC20.vy") | ||
rewards_handler_deployer = boa.load_partial("contracts/RewardsHandler.vy") | ||
|
||
|
||
def hash_to_address(input_string: str) -> str: | ||
# Hash the input string using SHA-256 to create a 32-byte private key | ||
private_key = hashlib.sha256(input_string.encode("utf-8")).hexdigest() | ||
# Create an account object from the private key | ||
account = Account.from_key(private_key) | ||
# Retrieve the Ethereum address in checksum format | ||
address = account.address | ||
return address |