From 94ba87f4d0d3b3d995f70df89bc02b9b368f05ba Mon Sep 17 00:00:00 2001 From: kate-aleksseeva Date: Fri, 13 Sep 2024 17:00:29 +0300 Subject: [PATCH 1/5] new files: vote and tests --- scripts/vote_2024_10_01_holesky.py | 79 ++++++++++ tests/test_2024_10_01_holesky.py | 167 +++++++++++++++++++++ tests/test_2024_10_01_holesky_ns.py | 222 ++++++++++++++++++++++++++++ 3 files changed, 468 insertions(+) create mode 100644 scripts/vote_2024_10_01_holesky.py create mode 100644 tests/test_2024_10_01_holesky.py create mode 100644 tests/test_2024_10_01_holesky_ns.py diff --git a/scripts/vote_2024_10_01_holesky.py b/scripts/vote_2024_10_01_holesky.py new file mode 100644 index 00000000..1b4dacd8 --- /dev/null +++ b/scripts/vote_2024_10_01_holesky.py @@ -0,0 +1,79 @@ +""" +Voting 01/10/2024! +Add ET setup for Alliance in stETH +!! Holesky only +""" + +import time + +from typing import Dict, Tuple, Optional, List + +from brownie import interface +from brownie.network.transaction import TransactionReceipt +from utils.voting import bake_vote_items, confirm_vote_script, create_vote +from utils.easy_track import add_evmscript_factory, create_permissions +from utils.permission_parameters import Param, SpecialArgumentID, ArgumentValue, Op +from utils.ipfs import upload_vote_ipfs_description, calculate_vote_ipfs_description + +from utils.config import ( + get_deployer_account, + contracts, + get_is_live, + get_priority_fee, +) + +from utils.easy_track import ( + add_evmscript_factory, + create_permissions, + remove_evmscript_factory +) + +description = """ +1. **Add Alliance Ops stablecoins top up EVM script factory, as decided in the [Snapshot vote](https://snapshot.org/#/lido-snapshot.eth/proposal/0xa478fa5518769096eda2b7403a1d4104ca47de3102e8a9abab8640ef1b50650c). + +""" + +def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: + """Prepare and run voting.""" + + alliance_ops_topup_factory = interface.TopUpAllowedRecipients("0x79e0286a8f60276293a7D29f53979642CcBD4Fff") + alliance_ops_registry = interface.AllowedRecipientRegistry("0x94499410c47FF7572560Ef8CBAf68bCdd0F38D08") + + vote_desc_items, call_script_items = zip( + # + # I. Add Alliance Ops stablecoins top up EVM script factory + # + ( + "1) Add Alliance Ops stablecoins top up EVM script factory 0x79e0286a8f60276293a7D29f53979642CcBD4Fff", + add_evmscript_factory( + factory=alliance_ops_topup_factory, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(alliance_ops_registry, "updateSpentAmount")[2:], + ), + ), + ) + + vote_items = bake_vote_items(list(vote_desc_items), list(call_script_items)) + + if silent: + desc_ipfs = calculate_vote_ipfs_description(description) + else: + desc_ipfs = upload_vote_ipfs_description(description) + + return confirm_vote_script(vote_items, silent, desc_ipfs) and list( + create_vote(vote_items, tx_params, desc_ipfs=desc_ipfs) + ) + + +def main(): + tx_params = {"from": get_deployer_account()} + + if get_is_live(): + tx_params["priority_fee"] = get_priority_fee() + + vote_id, _ = start_vote(tx_params=tx_params, silent=False) + + vote_id >= 0 and print(f"Vote created: {vote_id}.") + + time.sleep(5) # hack for waiting thread #2. + diff --git a/tests/test_2024_10_01_holesky.py b/tests/test_2024_10_01_holesky.py new file mode 100644 index 00000000..d908f81b --- /dev/null +++ b/tests/test_2024_10_01_holesky.py @@ -0,0 +1,167 @@ +""" +Tests for voting 01/10/2024. + +!! Holesky only +""" +from scripts.vote_2024_10_01_holesky import start_vote + +from brownie import ZERO_ADDRESS, chain, accounts +from brownie.network.transaction import TransactionReceipt + +from eth_abi.abi import encode + +from utils.config import ( + network_name, + contracts, + LDO_HOLDER_ADDRESS_FOR_TESTS, +) +from utils.test.tx_tracing_helpers import * +from utils.test.event_validators.easy_track import ( + validate_evmscript_factory_added_event, + EVMScriptFactoryAdded, + validate_evmscript_factory_removed_event, +) +from utils.easy_track import create_permissions +from utils.agent import agent_forward +from utils.voting import create_vote, bake_vote_items + +from utils.test.easy_track_helpers import ( + create_and_enact_payment_motion, + # create_and_enact_add_recipient_motion, + # create_and_enact_remove_recipient_motion, + # check_add_and_remove_recipient_with_voting, +) + +##### +# CONSTANTS +##### + +def test_vote( + helpers, + bypass_events_decoding, + vote_ids_from_env, + accounts, + interface, + ldo_holder, + stranger, + +): + + if not network_name() in ("holesky", "holesky-fork"): + return + + stETH_token = interface.ERC20("0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F") # todo + + finance = contracts.finance + voting = contracts.voting + easy_track = contracts.easy_track # todo: проверить адрес контракта easytrack для holesky + + rewards_share_topup_factory = interface.TopUpAllowedRecipients("0x79e0286a8f60276293a7D29f53979642CcBD4Fff") + # rewards_share_add_recipient_factory = interface.AddAllowedRecipient("0x51916FC3D24CbE19c5e981ae8650668A1F5cF19B") + # rewards_share_remove_recipient_factory = interface.RemoveAllowedRecipient("0x932aab3D6057ed2Beef95471414831C4535600E9") + rewards_share_registry = interface.AllowedRecipientRegistry("0x94499410c47FF7572560Ef8CBAf68bCdd0F38D08") + rewards_share_multisig = accounts.at("0x92ABC000698374B44206148596AcD8a934687E66", {"force": True}) + + old_factories_list = easy_track.getEVMScriptFactories() + + assert len(old_factories_list) == 18 + + assert rewards_share_topup_factory not in old_factories_list + # assert rewards_share_add_recipient_factory not in old_factories_list + # assert rewards_share_remove_recipient_factory not in old_factories_list + + # START VOTE + if len(vote_ids_from_env) > 0: + (vote_id,) = vote_ids_from_env + else: + tx_params = {"from": LDO_HOLDER_ADDRESS_FOR_TESTS} + vote_id, _ = start_vote(tx_params, silent=True) + + vote_tx = helpers.execute_vote(accounts, vote_id, contracts.voting) + + print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") + + updated_factories_list = easy_track.getEVMScriptFactories() + assert len(updated_factories_list) == 21 + + assert rewards_share_topup_factory in updated_factories_list + # assert rewards_share_add_recipient_factory in updated_factories_list + # assert rewards_share_remove_recipient_factory in updated_factories_list + + ''' + check_add_and_remove_recipient_with_voting( + rewards_share_registry, + helpers, ldo_holder, + voting, + )''' + + ''' + create_and_enact_add_recipient_motion( + easy_track, + rewards_share_multisig, + rewards_share_registry, + rewards_share_add_recipient_factory, + stranger, + "New recipient", + ldo_holder, + ) + ''' + + create_and_enact_payment_motion( + easy_track, + rewards_share_multisig, + rewards_share_topup_factory, + stETH_token, + [stranger], + [10 * 10**18], # todo: обновить баланс? + stranger, + ) + + ''' + create_and_enact_remove_recipient_motion( + easy_track, + rewards_share_multisig, + rewards_share_registry, + rewards_share_remove_recipient_factory, + stranger, + ldo_holder, + ) + ''' + + # validate vote events, спросить про количество + assert count_vote_items_by_events(vote_tx, voting) == 2, "Incorrect voting items count" + + display_voting_events(vote_tx) + + ''' + if bypass_events_decoding or network_name() in ("holesky", "holesky-fork"): + return + ''' + + evs = group_voting_events(vote_tx) + + validate_evmscript_factory_added_event( + evs[0], + EVMScriptFactoryAdded( + factory_addr=rewards_share_topup_factory, + permissions=create_permissions(finance, "newImmediatePayment") + + create_permissions(rewards_share_registry, "updateSpentAmount")[2:], + ), + ) + + ''' + validate_evmscript_factory_added_event( + evs[1], + EVMScriptFactoryAdded( + factory_addr=rewards_share_add_recipient_factory, + permissions=create_permissions(rewards_share_registry, "addRecipient"), + ), + ) + validate_evmscript_factory_added_event( + evs[2], + EVMScriptFactoryAdded( + factory_addr=rewards_share_remove_recipient_factory, + permissions=create_permissions(rewards_share_registry, "removeRecipient"), + ), + ) + ''' diff --git a/tests/test_2024_10_01_holesky_ns.py b/tests/test_2024_10_01_holesky_ns.py new file mode 100644 index 00000000..39d82efc --- /dev/null +++ b/tests/test_2024_10_01_holesky_ns.py @@ -0,0 +1,222 @@ +""" +Tests for voting 01/10/2024 + +""" + +from scripts.vote_2024_10_01_holesky import start_vote +from brownie import interface, ZERO_ADDRESS, reverts, web3, accounts, convert +from utils.test.tx_tracing_helpers import * +from utils.voting import find_metadata_by_vote_id +from utils.ipfs import get_lido_vote_cid_from_str +from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, network_name +from utils.easy_track import create_permissions +from configs.config_mainnet import ( + DAI_TOKEN, + USDC_TOKEN, + USDT_TOKEN, +) +from utils.test.easy_track_helpers import create_and_enact_payment_motion, check_add_and_remove_recipient_with_voting +from utils.test.event_validators.easy_track import ( + validate_evmscript_factory_added_event, + EVMScriptFactoryAdded, + validate_evmscript_factory_removed_event, +) + +STETH_TRANSFER_MAX_DELTA = 2 + + +def test_vote(helpers, accounts, vote_ids_from_env, stranger, ldo_holder, bypass_events_decoding): + steth = contracts.lido + easy_track = contracts.easy_track + + evm_script_factories_before = easy_track.getEVMScriptFactories() + + alliance_ops_top_up_evm_script_factory_new = "0x79e0286a8f60276293a7D29f53979642CcBD4Fff" # TopUpAllowedRecipients + assert alliance_ops_top_up_evm_script_factory_new not in evm_script_factories_before + + stonks_multisig_acc = accounts.at("xd4090CA1134F8dE1450B8246916F73d212efdEf6", force=True) # Testnet DAO Multisigs + stonks_dai_usdc_contract = accounts.at("0x2eb8e9198e647f80ccf62a5e291bcd4a5a3ca68c", force=True) # Testnet Stablecoins + stonks_usdc_dai_contract = accounts.at("0x9715b2786f1053294fc8952df923b95cab9aac42", force=True) + stonks_usdt_dai_contract = accounts.at("0x86f6c353a0965eb069cd7f4f91c1afef8c725551", force=True) + + + # START VOTE + if len(vote_ids_from_env) > 0: + (vote_id,) = vote_ids_from_env + else: + tx_params = {"from": LDO_HOLDER_ADDRESS_FOR_TESTS} + vote_id, _ = start_vote(tx_params, silent=True) + + vote_tx = helpers.execute_vote(accounts, vote_id, contracts.voting) + + print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") + + # + # Easy Track stETH and stables top up setups for Lido stonks + # + + evm_script_factories_after = easy_track.getEVMScriptFactories() + + # 1. Add TMC stETH top up EVM script factory address TBA (AllowedRecipientsRegistry address TBA) + assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after + create_and_enact_payment_motion( + easy_track, + trusted_caller=stonks_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=steth, + recievers=[stonks_steth_contract], + transfer_amounts=[10 * 10**18], + stranger=stranger, + ) + + ''' + tmc_steth_allowed_recipients_registry = interface.AllowedRecipientRegistry( + "0x1a7cFA9EFB4D5BfFDE87B0FaEb1fC65d653868C0" + ) + check_add_and_remove_recipient_with_voting( + registry=tmc_steth_allowed_recipients_registry, + helpers=helpers, + ldo_holder=ldo_holder, + dao_voting=contracts.voting, + ) + ''' + + ''' + dai_transfer_amount = 1_000 * 10**18 + prepare_agent_for_steth_payment(4 * dai_transfer_amount) + + usdc_transfer_amount = 1_000 * 10**6 + prepare_agent_for_usdc_payment(4 * usdc_transfer_amount) + + usdt_transfer_amount = 1_000 * 10**6 + prepare_agent_for_usdt_payment(4 * usdt_transfer_amount) + ''' + + # 2. Add TMC stables top up EVM script factory address TBA (AllowedRecipientsRegistry address TBA, AllowedTokensRegistry address TBA) + assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after + + create_and_enact_payment_motion( + easy_track, + trusted_caller=stonks_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Dai(DAI_TOKEN), + recievers=[stonks_dai_usdc_contract], + transfer_amounts=[dai_transfer_amount], + stranger=stranger, + ) + + create_and_enact_payment_motion( + easy_track, + trusted_caller=stonks_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Usdc(USDC_TOKEN), + recievers=[stonks_usdc_dai_contract], + transfer_amounts=[usdc_transfer_amount], + stranger=stranger, + ) + + create_and_enact_payment_motion( + easy_track, + trusted_caller=stonks_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Usdt(USDT_TOKEN), + recievers=[stonks_usdt_dai_contract], + transfer_amounts=[usdt_transfer_amount], + stranger=stranger, + ) + + with reverts("TOKEN_NOT_ALLOWED"): + create_and_enact_payment_motion( + easy_track, + trusted_caller=stonks_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=steth, + recievers=[stonks_dai_usdc_contract], + transfer_amounts=[1], + stranger=stranger, + ) + + alliance_ops_allowed_recipients_registry = interface.AllowedRecipientRegistry( + "0x94499410c47FF7572560Ef8CBAf68bCdd0F38D08" + ) + check_add_and_remove_recipient_with_voting( + registry=alliance_ops_allowed_recipients_registry, + helpers=helpers, + ldo_holder=ldo_holder, + dao_voting=contracts.voting, + ) + + # validate vote events + assert count_vote_items_by_events(vote_tx, contracts.voting) == 2, "Incorrect voting items count" + + metadata = find_metadata_by_vote_id(vote_id) + + # assert get_lido_vote_cid_from_str(metadata) == "bafkreibbrlprupitulahcrl57uda4nkzrbfajtrhhsaa3cbx5of4t2huoa" + + display_voting_events(vote_tx) + ''' + if bypass_events_decoding or network_name() in ("goerli", "goerli-fork"): + return + ''' + + evs = group_voting_events(vote_tx) + + ''' + validate_evmscript_factory_added_event( + evs[0], + EVMScriptFactoryAdded( + factory_addr=alliance_ops_top_up_evm_script_factory_new, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], + ), + ) + ''' + validate_evmscript_factory_added_event( + evs[0], + EVMScriptFactoryAdded( + factory_addr=alliance_ops_top_up_evm_script_factory_new, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], + ), + ) + +''' +def prepare_agent_for_steth_payment(amount: int): + agent, steth = contracts.agent, contracts.lido + eth_whale = accounts.at("0x00000000219ab540356cBB839Cbe05303d7705Fa", force=True) + if steth.balanceOf(agent) < amount: + steth.submit(ZERO_ADDRESS, {"from": eth_whale, "value": amount + 2 * STETH_TRANSFER_MAX_DELTA}) + steth.transfer(agent, amount + STETH_TRANSFER_MAX_DELTA, {"from": eth_whale}) + assert steth.balanceOf(agent) >= amount, "Insufficient stETH balance" + + +def prepare_agent_for_dai_payment(amount: int): + agent, dai = contracts.agent, interface.Dai(DAI_TOKEN) + if dai.balanceOf(agent) < amount: + dai_ward_impersonated = accounts.at("0x9759A6Ac90977b93B58547b4A71c78317f391A28", force=True) + dai.mint(agent, amount, {"from": dai_ward_impersonated}) + + assert dai.balanceOf(agent) >= amount, f"Insufficient DAI balance" + + +def prepare_agent_for_usdc_payment(amount: int): + agent, usdc = contracts.agent, interface.Usdc(USDC_TOKEN) + if usdc.balanceOf(agent) < amount: + usdc_minter = accounts.at("0x5B6122C109B78C6755486966148C1D70a50A47D7", force=True) + usdc_controller = accounts.at("0x79E0946e1C186E745f1352d7C21AB04700C99F71", force=True) + usdc_master_minter = interface.UsdcMasterMinter("0xE982615d461DD5cD06575BbeA87624fda4e3de17") + usdc_master_minter.incrementMinterAllowance(amount, {"from": usdc_controller}) + usdc.mint(agent, amount, {"from": usdc_minter}) + + assert usdc.balanceOf(agent) >= amount, "Insufficient USDC balance" + + +def prepare_agent_for_usdt_payment(amount: int): + agent, usdt = contracts.agent, interface.Usdt(USDT_TOKEN) + if usdt.balanceOf(agent) < amount: + usdt_owner = accounts.at("0xC6CDE7C39eB2f0F0095F41570af89eFC2C1Ea828", force=True) + usdt.issue(amount, {"from": usdt_owner}) + usdt.transfer(agent, amount, {"from": usdt_owner}) + + assert usdt.balanceOf(agent) >= amount, "Insufficient USDT balance" +''' \ No newline at end of file From fac27751a31add83b1272af349624fd631f734ed Mon Sep 17 00:00:00 2001 From: kate-aleksseeva Date: Fri, 27 Sep 2024 16:13:58 +0300 Subject: [PATCH 2/5] new files: vote and tests --- scripts/vote_2024_10_01_holesky.py | 10 +- tests/test_2024_10_01_holesky.py | 273 +++++++++++++++++----------- tests/test_2024_10_01_holesky_ns.py | 222 ---------------------- 3 files changed, 171 insertions(+), 334 deletions(-) delete mode 100644 tests/test_2024_10_01_holesky_ns.py diff --git a/scripts/vote_2024_10_01_holesky.py b/scripts/vote_2024_10_01_holesky.py index 1b4dacd8..28c1cbb7 100644 --- a/scripts/vote_2024_10_01_holesky.py +++ b/scripts/vote_2024_10_01_holesky.py @@ -36,15 +36,15 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | TransactionReceipt | None]: """Prepare and run voting.""" - alliance_ops_topup_factory = interface.TopUpAllowedRecipients("0x79e0286a8f60276293a7D29f53979642CcBD4Fff") - alliance_ops_registry = interface.AllowedRecipientRegistry("0x94499410c47FF7572560Ef8CBAf68bCdd0F38D08") - + alliance_ops_topup_factory = interface.TopUpAllowedRecipients("0x343fa5f0c79277e2d27e440f40420d619f962a23") + alliance_ops_registry = interface.AllowedRecipientRegistry("0xe1ba8dee84a4df8e99e495419365d979cdb19991") + vote_desc_items, call_script_items = zip( # # I. Add Alliance Ops stablecoins top up EVM script factory # ( - "1) Add Alliance Ops stablecoins top up EVM script factory 0x79e0286a8f60276293a7D29f53979642CcBD4Fff", + "1) Add Alliance Ops stablecoins top up EVM script factory 0x343fa5f0c79277e2d27e440f40420d619f962a23", add_evmscript_factory( factory=alliance_ops_topup_factory, permissions=create_permissions(contracts.finance, "newImmediatePayment") @@ -54,7 +54,7 @@ def start_vote(tx_params: Dict[str, str], silent: bool) -> bool | list[int | Tra ) vote_items = bake_vote_items(list(vote_desc_items), list(call_script_items)) - + if silent: desc_ipfs = calculate_vote_ipfs_description(description) else: diff --git a/tests/test_2024_10_01_holesky.py b/tests/test_2024_10_01_holesky.py index d908f81b..a88ef601 100644 --- a/tests/test_2024_10_01_holesky.py +++ b/tests/test_2024_10_01_holesky.py @@ -1,74 +1,42 @@ """ -Tests for voting 01/10/2024. +Tests for voting 01/10/2024 -!! Holesky only """ -from scripts.vote_2024_10_01_holesky import start_vote - -from brownie import ZERO_ADDRESS, chain, accounts -from brownie.network.transaction import TransactionReceipt - -from eth_abi.abi import encode -from utils.config import ( - network_name, - contracts, - LDO_HOLDER_ADDRESS_FOR_TESTS, -) +from scripts.vote_2024_10_01_holesky import start_vote +from brownie import interface, ZERO_ADDRESS, reverts, web3, accounts, convert from utils.test.tx_tracing_helpers import * +from utils.voting import find_metadata_by_vote_id +from utils.ipfs import get_lido_vote_cid_from_str +from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, network_name +from utils.easy_track import create_permissions +from configs.config_mainnet import ( + DAI_TOKEN, + USDC_TOKEN, + USDT_TOKEN, +) +from utils.test.easy_track_helpers import create_and_enact_payment_motion, check_add_and_remove_recipient_with_voting from utils.test.event_validators.easy_track import ( validate_evmscript_factory_added_event, EVMScriptFactoryAdded, validate_evmscript_factory_removed_event, ) -from utils.easy_track import create_permissions -from utils.agent import agent_forward -from utils.voting import create_vote, bake_vote_items - -from utils.test.easy_track_helpers import ( - create_and_enact_payment_motion, - # create_and_enact_add_recipient_motion, - # create_and_enact_remove_recipient_motion, - # check_add_and_remove_recipient_with_voting, -) +_ +# STETH_TRANSFER_MAX_DELTA = 2 -##### -# CONSTANTS -##### +def test_vote(helpers, accounts, vote_ids_from_env, stranger, ldo_holder, bypass_events_decoding): + steth = contracts.lido + easy_track = contracts.easy_track -def test_vote( - helpers, - bypass_events_decoding, - vote_ids_from_env, - accounts, - interface, - ldo_holder, - stranger, + evm_script_factories_before = easy_track.getEVMScriptFactories() -): + alliance_ops_top_up_evm_script_factory_new = "0x343fa5f0c79277e2d27e440f40420d619f962a23" # TopUpAllowedRecipients + assert alliance_ops_top_up_evm_script_factory_new not in evm_script_factories_before - if not network_name() in ("holesky", "holesky-fork"): - return - - stETH_token = interface.ERC20("0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F") # todo - - finance = contracts.finance - voting = contracts.voting - easy_track = contracts.easy_track # todo: проверить адрес контракта easytrack для holesky - - rewards_share_topup_factory = interface.TopUpAllowedRecipients("0x79e0286a8f60276293a7D29f53979642CcBD4Fff") - # rewards_share_add_recipient_factory = interface.AddAllowedRecipient("0x51916FC3D24CbE19c5e981ae8650668A1F5cF19B") - # rewards_share_remove_recipient_factory = interface.RemoveAllowedRecipient("0x932aab3D6057ed2Beef95471414831C4535600E9") - rewards_share_registry = interface.AllowedRecipientRegistry("0x94499410c47FF7572560Ef8CBAf68bCdd0F38D08") - rewards_share_multisig = accounts.at("0x92ABC000698374B44206148596AcD8a934687E66", {"force": True}) - - old_factories_list = easy_track.getEVMScriptFactories() - - assert len(old_factories_list) == 18 - - assert rewards_share_topup_factory not in old_factories_list - # assert rewards_share_add_recipient_factory not in old_factories_list - # assert rewards_share_remove_recipient_factory not in old_factories_list + alliance_multisig_acc = accounts.at("xd4090CA1134F8dE1450B8246916F73d212efdEf6", force=True) # Testnet DAO Multisigs + alliance_dai_usdc_contract = accounts.at("0x2eb8e9198e647f80ccf62a5e291bcd4a5a3ca68c", force=True) # Testnet Stablecoins + alliance_usdc_dai_contract = accounts.at("0x9715b2786f1053294fc8952df923b95cab9aac42", force=True) + alliance_usdt_dai_contract = accounts.at("0x86f6c353a0965eb069cd7f4f91c1afef8c725551", force=True) # START VOTE if len(vote_ids_from_env) > 0: @@ -81,87 +49,178 @@ def test_vote( print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") - updated_factories_list = easy_track.getEVMScriptFactories() - assert len(updated_factories_list) == 21 + evm_script_factories_after = easy_track.getEVMScriptFactories() + + # 1. Add TMC stETH top up EVM script factory address TBA (AllowedRecipientsRegistry address TBA) + assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after - assert rewards_share_topup_factory in updated_factories_list - # assert rewards_share_add_recipient_factory in updated_factories_list - # assert rewards_share_remove_recipient_factory in updated_factories_list + ''' + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=steth, + recievers=[alliance_steth_contract], + transfer_amounts=[10 * 10**18], + stranger=stranger, + ) + ''' ''' + tmc_steth_allowed_recipients_registry = interface.AllowedRecipientRegistry( + "0x1a7cFA9EFB4D5BfFDE87B0FaEb1fC65d653868C0" + ) check_add_and_remove_recipient_with_voting( - rewards_share_registry, - helpers, ldo_holder, - voting, - )''' + registry=tmc_steth_allowed_recipients_registry, + helpers=helpers, + ldo_holder=ldo_holder, + dao_voting=contracts.voting, + ) + ''' + + dai_transfer_amount = 1_000 * 10**18 ''' - create_and_enact_add_recipient_motion( + prepare_agent_for_steth_payment(4 * dai_transfer_amount) + ''' + + usdc_transfer_amount = 1_000 * 10**6 + ''' + prepare_agent_for_usdc_payment(4 * usdc_transfer_amount) + ''' + + usdt_transfer_amount = 1_000 * 10**6 + ''' + prepare_agent_for_usdt_payment(4 * usdt_transfer_amount) + ''' + + # 2. Add TMC stables top up EVM script factory address TBA (AllowedRecipientsRegistry address TBA, AllowedTokensRegistry address TBA) + assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after + + create_and_enact_payment_motion( easy_track, - rewards_share_multisig, - rewards_share_registry, - rewards_share_add_recipient_factory, - stranger, - "New recipient", - ldo_holder, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Dai(DAI_TOKEN), + recievers=[alliance_dai_usdc_contract], + transfer_amounts=[dai_transfer_amount], + stranger=stranger, ) - ''' create_and_enact_payment_motion( easy_track, - rewards_share_multisig, - rewards_share_topup_factory, - stETH_token, - [stranger], - [10 * 10**18], # todo: обновить баланс? - stranger, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Usdc(USDC_TOKEN), + recievers=[alliance_usdc_dai_contract], + transfer_amounts=[usdc_transfer_amount], + stranger=stranger, ) - ''' - create_and_enact_remove_recipient_motion( + create_and_enact_payment_motion( easy_track, - rewards_share_multisig, - rewards_share_registry, - rewards_share_remove_recipient_factory, - stranger, - ldo_holder, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Usdt(USDT_TOKEN), + recievers=[alliance_usdt_dai_contract], + transfer_amounts=[usdt_transfer_amount], + stranger=stranger, ) - ''' - # validate vote events, спросить про количество - assert count_vote_items_by_events(vote_tx, voting) == 2, "Incorrect voting items count" + with reverts("TOKEN_NOT_ALLOWED"): + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=steth, + recievers=[alliance_dai_usdc_contract], + transfer_amounts=[1], + stranger=stranger, + ) - display_voting_events(vote_tx) + alliance_ops_allowed_recipients_registry = interface.AllowedRecipientRegistry( + "0xe1ba8dee84a4df8e99e495419365d979cdb19991" + ) + + check_add_and_remove_recipient_with_voting( + registry=alliance_ops_allowed_recipients_registry, + helpers=helpers, + ldo_holder=ldo_holder, + dao_voting=contracts.voting, + ) + + # validate vote events + assert count_vote_items_by_events(vote_tx, contracts.voting) == 1, "Incorrect voting items count" + + metadata = find_metadata_by_vote_id(vote_id) + + assert get_lido_vote_cid_from_str(metadata) == "bafkreibbrlprupitulahcrl57uda4nkzrbfajtrhhsaa3cbx5of4t2huoa" # todo: поменять адрес после тестовой публикации голоосвания на форке + + display_voting_events(vote_tx) ''' - if bypass_events_decoding or network_name() in ("holesky", "holesky-fork"): + if bypass_events_decoding or network_name() in ("goerli", "goerli-fork"): return ''' evs = group_voting_events(vote_tx) + ''' validate_evmscript_factory_added_event( evs[0], EVMScriptFactoryAdded( - factory_addr=rewards_share_topup_factory, - permissions=create_permissions(finance, "newImmediatePayment") - + create_permissions(rewards_share_registry, "updateSpentAmount")[2:], + factory_addr=alliance_ops_top_up_evm_script_factory_new, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], ), ) - ''' validate_evmscript_factory_added_event( - evs[1], - EVMScriptFactoryAdded( - factory_addr=rewards_share_add_recipient_factory, - permissions=create_permissions(rewards_share_registry, "addRecipient"), - ), - ) - validate_evmscript_factory_added_event( - evs[2], + evs[0], EVMScriptFactoryAdded( - factory_addr=rewards_share_remove_recipient_factory, - permissions=create_permissions(rewards_share_registry, "removeRecipient"), + factory_addr=alliance_ops_top_up_evm_script_factory_new, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], ), ) - ''' + +''' +def prepare_agent_for_steth_payment(amount: int): + agent, steth = contracts.agent, contracts.lido + eth_whale = accounts.at("0x00000000219ab540356cBB839Cbe05303d7705Fa", force=True) + if steth.balanceOf(agent) < amount: + steth.submit(ZERO_ADDRESS, {"from": eth_whale, "value": amount + 2 * STETH_TRANSFER_MAX_DELTA}) + steth.transfer(agent, amount + STETH_TRANSFER_MAX_DELTA, {"from": eth_whale}) + assert steth.balanceOf(agent) >= amount, "Insufficient stETH balance" + + +def prepare_agent_for_dai_payment(amount: int): + agent, dai = contracts.agent, interface.Dai(DAI_TOKEN) + if dai.balanceOf(agent) < amount: + dai_ward_impersonated = accounts.at("0x9759A6Ac90977b93B58547b4A71c78317f391A28", force=True) + dai.mint(agent, amount, {"from": dai_ward_impersonated}) + + assert dai.balanceOf(agent) >= amount, f"Insufficient DAI balance" + + +def prepare_agent_for_usdc_payment(amount: int): + agent, usdc = contracts.agent, interface.Usdc(USDC_TOKEN) + if usdc.balanceOf(agent) < amount: + usdc_minter = accounts.at("0x5B6122C109B78C6755486966148C1D70a50A47D7", force=True) + usdc_controller = accounts.at("0x79E0946e1C186E745f1352d7C21AB04700C99F71", force=True) + usdc_master_minter = interface.UsdcMasterMinter("0xE982615d461DD5cD06575BbeA87624fda4e3de17") + usdc_master_minter.incrementMinterAllowance(amount, {"from": usdc_controller}) + usdc.mint(agent, amount, {"from": usdc_minter}) + + assert usdc.balanceOf(agent) >= amount, "Insufficient USDC balance" + + +def prepare_agent_for_usdt_payment(amount: int): + agent, usdt = contracts.agent, interface.Usdt(USDT_TOKEN) + if usdt.balanceOf(agent) < amount: + usdt_owner = accounts.at("0xC6CDE7C39eB2f0F0095F41570af89eFC2C1Ea828", force=True) + usdt.issue(amount, {"from": usdt_owner}) + usdt.transfer(agent, amount, {"from": usdt_owner}) + + assert usdt.balanceOf(agent) >= amount, "Insufficient USDT balance" +''' diff --git a/tests/test_2024_10_01_holesky_ns.py b/tests/test_2024_10_01_holesky_ns.py deleted file mode 100644 index 39d82efc..00000000 --- a/tests/test_2024_10_01_holesky_ns.py +++ /dev/null @@ -1,222 +0,0 @@ -""" -Tests for voting 01/10/2024 - -""" - -from scripts.vote_2024_10_01_holesky import start_vote -from brownie import interface, ZERO_ADDRESS, reverts, web3, accounts, convert -from utils.test.tx_tracing_helpers import * -from utils.voting import find_metadata_by_vote_id -from utils.ipfs import get_lido_vote_cid_from_str -from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, network_name -from utils.easy_track import create_permissions -from configs.config_mainnet import ( - DAI_TOKEN, - USDC_TOKEN, - USDT_TOKEN, -) -from utils.test.easy_track_helpers import create_and_enact_payment_motion, check_add_and_remove_recipient_with_voting -from utils.test.event_validators.easy_track import ( - validate_evmscript_factory_added_event, - EVMScriptFactoryAdded, - validate_evmscript_factory_removed_event, -) - -STETH_TRANSFER_MAX_DELTA = 2 - - -def test_vote(helpers, accounts, vote_ids_from_env, stranger, ldo_holder, bypass_events_decoding): - steth = contracts.lido - easy_track = contracts.easy_track - - evm_script_factories_before = easy_track.getEVMScriptFactories() - - alliance_ops_top_up_evm_script_factory_new = "0x79e0286a8f60276293a7D29f53979642CcBD4Fff" # TopUpAllowedRecipients - assert alliance_ops_top_up_evm_script_factory_new not in evm_script_factories_before - - stonks_multisig_acc = accounts.at("xd4090CA1134F8dE1450B8246916F73d212efdEf6", force=True) # Testnet DAO Multisigs - stonks_dai_usdc_contract = accounts.at("0x2eb8e9198e647f80ccf62a5e291bcd4a5a3ca68c", force=True) # Testnet Stablecoins - stonks_usdc_dai_contract = accounts.at("0x9715b2786f1053294fc8952df923b95cab9aac42", force=True) - stonks_usdt_dai_contract = accounts.at("0x86f6c353a0965eb069cd7f4f91c1afef8c725551", force=True) - - - # START VOTE - if len(vote_ids_from_env) > 0: - (vote_id,) = vote_ids_from_env - else: - tx_params = {"from": LDO_HOLDER_ADDRESS_FOR_TESTS} - vote_id, _ = start_vote(tx_params, silent=True) - - vote_tx = helpers.execute_vote(accounts, vote_id, contracts.voting) - - print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") - - # - # Easy Track stETH and stables top up setups for Lido stonks - # - - evm_script_factories_after = easy_track.getEVMScriptFactories() - - # 1. Add TMC stETH top up EVM script factory address TBA (AllowedRecipientsRegistry address TBA) - assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after - create_and_enact_payment_motion( - easy_track, - trusted_caller=stonks_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=steth, - recievers=[stonks_steth_contract], - transfer_amounts=[10 * 10**18], - stranger=stranger, - ) - - ''' - tmc_steth_allowed_recipients_registry = interface.AllowedRecipientRegistry( - "0x1a7cFA9EFB4D5BfFDE87B0FaEb1fC65d653868C0" - ) - check_add_and_remove_recipient_with_voting( - registry=tmc_steth_allowed_recipients_registry, - helpers=helpers, - ldo_holder=ldo_holder, - dao_voting=contracts.voting, - ) - ''' - - ''' - dai_transfer_amount = 1_000 * 10**18 - prepare_agent_for_steth_payment(4 * dai_transfer_amount) - - usdc_transfer_amount = 1_000 * 10**6 - prepare_agent_for_usdc_payment(4 * usdc_transfer_amount) - - usdt_transfer_amount = 1_000 * 10**6 - prepare_agent_for_usdt_payment(4 * usdt_transfer_amount) - ''' - - # 2. Add TMC stables top up EVM script factory address TBA (AllowedRecipientsRegistry address TBA, AllowedTokensRegistry address TBA) - assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after - - create_and_enact_payment_motion( - easy_track, - trusted_caller=stonks_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=interface.Dai(DAI_TOKEN), - recievers=[stonks_dai_usdc_contract], - transfer_amounts=[dai_transfer_amount], - stranger=stranger, - ) - - create_and_enact_payment_motion( - easy_track, - trusted_caller=stonks_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=interface.Usdc(USDC_TOKEN), - recievers=[stonks_usdc_dai_contract], - transfer_amounts=[usdc_transfer_amount], - stranger=stranger, - ) - - create_and_enact_payment_motion( - easy_track, - trusted_caller=stonks_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=interface.Usdt(USDT_TOKEN), - recievers=[stonks_usdt_dai_contract], - transfer_amounts=[usdt_transfer_amount], - stranger=stranger, - ) - - with reverts("TOKEN_NOT_ALLOWED"): - create_and_enact_payment_motion( - easy_track, - trusted_caller=stonks_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=steth, - recievers=[stonks_dai_usdc_contract], - transfer_amounts=[1], - stranger=stranger, - ) - - alliance_ops_allowed_recipients_registry = interface.AllowedRecipientRegistry( - "0x94499410c47FF7572560Ef8CBAf68bCdd0F38D08" - ) - check_add_and_remove_recipient_with_voting( - registry=alliance_ops_allowed_recipients_registry, - helpers=helpers, - ldo_holder=ldo_holder, - dao_voting=contracts.voting, - ) - - # validate vote events - assert count_vote_items_by_events(vote_tx, contracts.voting) == 2, "Incorrect voting items count" - - metadata = find_metadata_by_vote_id(vote_id) - - # assert get_lido_vote_cid_from_str(metadata) == "bafkreibbrlprupitulahcrl57uda4nkzrbfajtrhhsaa3cbx5of4t2huoa" - - display_voting_events(vote_tx) - ''' - if bypass_events_decoding or network_name() in ("goerli", "goerli-fork"): - return - ''' - - evs = group_voting_events(vote_tx) - - ''' - validate_evmscript_factory_added_event( - evs[0], - EVMScriptFactoryAdded( - factory_addr=alliance_ops_top_up_evm_script_factory_new, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], - ), - ) - ''' - validate_evmscript_factory_added_event( - evs[0], - EVMScriptFactoryAdded( - factory_addr=alliance_ops_top_up_evm_script_factory_new, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], - ), - ) - -''' -def prepare_agent_for_steth_payment(amount: int): - agent, steth = contracts.agent, contracts.lido - eth_whale = accounts.at("0x00000000219ab540356cBB839Cbe05303d7705Fa", force=True) - if steth.balanceOf(agent) < amount: - steth.submit(ZERO_ADDRESS, {"from": eth_whale, "value": amount + 2 * STETH_TRANSFER_MAX_DELTA}) - steth.transfer(agent, amount + STETH_TRANSFER_MAX_DELTA, {"from": eth_whale}) - assert steth.balanceOf(agent) >= amount, "Insufficient stETH balance" - - -def prepare_agent_for_dai_payment(amount: int): - agent, dai = contracts.agent, interface.Dai(DAI_TOKEN) - if dai.balanceOf(agent) < amount: - dai_ward_impersonated = accounts.at("0x9759A6Ac90977b93B58547b4A71c78317f391A28", force=True) - dai.mint(agent, amount, {"from": dai_ward_impersonated}) - - assert dai.balanceOf(agent) >= amount, f"Insufficient DAI balance" - - -def prepare_agent_for_usdc_payment(amount: int): - agent, usdc = contracts.agent, interface.Usdc(USDC_TOKEN) - if usdc.balanceOf(agent) < amount: - usdc_minter = accounts.at("0x5B6122C109B78C6755486966148C1D70a50A47D7", force=True) - usdc_controller = accounts.at("0x79E0946e1C186E745f1352d7C21AB04700C99F71", force=True) - usdc_master_minter = interface.UsdcMasterMinter("0xE982615d461DD5cD06575BbeA87624fda4e3de17") - usdc_master_minter.incrementMinterAllowance(amount, {"from": usdc_controller}) - usdc.mint(agent, amount, {"from": usdc_minter}) - - assert usdc.balanceOf(agent) >= amount, "Insufficient USDC balance" - - -def prepare_agent_for_usdt_payment(amount: int): - agent, usdt = contracts.agent, interface.Usdt(USDT_TOKEN) - if usdt.balanceOf(agent) < amount: - usdt_owner = accounts.at("0xC6CDE7C39eB2f0F0095F41570af89eFC2C1Ea828", force=True) - usdt.issue(amount, {"from": usdt_owner}) - usdt.transfer(agent, amount, {"from": usdt_owner}) - - assert usdt.balanceOf(agent) >= amount, "Insufficient USDT balance" -''' \ No newline at end of file From 786538430658912abe85a6d6ce2c3afce75a821b Mon Sep 17 00:00:00 2001 From: kate-aleksseeva Date: Fri, 27 Sep 2024 17:01:09 +0300 Subject: [PATCH 3/5] new files: vote and tests --- ..._holesky.py => vote_2024_10_08_holesky.py} | 5 +- tests/test_2024_10_01_holesky.py | 226 ------------------ tests/test_2024_10_08_holesky.py | 131 ++++++++++ 3 files changed, 133 insertions(+), 229 deletions(-) rename scripts/{vote_2024_10_01_holesky.py => vote_2024_10_08_holesky.py} (97%) delete mode 100644 tests/test_2024_10_01_holesky.py create mode 100644 tests/test_2024_10_08_holesky.py diff --git a/scripts/vote_2024_10_01_holesky.py b/scripts/vote_2024_10_08_holesky.py similarity index 97% rename from scripts/vote_2024_10_01_holesky.py rename to scripts/vote_2024_10_08_holesky.py index 28c1cbb7..f113eae5 100644 --- a/scripts/vote_2024_10_01_holesky.py +++ b/scripts/vote_2024_10_08_holesky.py @@ -1,7 +1,6 @@ """ -Voting 01/10/2024! -Add ET setup for Alliance in stETH -!! Holesky only +Voting 08/10/2024 + """ import time diff --git a/tests/test_2024_10_01_holesky.py b/tests/test_2024_10_01_holesky.py deleted file mode 100644 index a88ef601..00000000 --- a/tests/test_2024_10_01_holesky.py +++ /dev/null @@ -1,226 +0,0 @@ -""" -Tests for voting 01/10/2024 - -""" - -from scripts.vote_2024_10_01_holesky import start_vote -from brownie import interface, ZERO_ADDRESS, reverts, web3, accounts, convert -from utils.test.tx_tracing_helpers import * -from utils.voting import find_metadata_by_vote_id -from utils.ipfs import get_lido_vote_cid_from_str -from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, network_name -from utils.easy_track import create_permissions -from configs.config_mainnet import ( - DAI_TOKEN, - USDC_TOKEN, - USDT_TOKEN, -) -from utils.test.easy_track_helpers import create_and_enact_payment_motion, check_add_and_remove_recipient_with_voting -from utils.test.event_validators.easy_track import ( - validate_evmscript_factory_added_event, - EVMScriptFactoryAdded, - validate_evmscript_factory_removed_event, -) -_ -# STETH_TRANSFER_MAX_DELTA = 2 - -def test_vote(helpers, accounts, vote_ids_from_env, stranger, ldo_holder, bypass_events_decoding): - steth = contracts.lido - easy_track = contracts.easy_track - - evm_script_factories_before = easy_track.getEVMScriptFactories() - - alliance_ops_top_up_evm_script_factory_new = "0x343fa5f0c79277e2d27e440f40420d619f962a23" # TopUpAllowedRecipients - assert alliance_ops_top_up_evm_script_factory_new not in evm_script_factories_before - - alliance_multisig_acc = accounts.at("xd4090CA1134F8dE1450B8246916F73d212efdEf6", force=True) # Testnet DAO Multisigs - alliance_dai_usdc_contract = accounts.at("0x2eb8e9198e647f80ccf62a5e291bcd4a5a3ca68c", force=True) # Testnet Stablecoins - alliance_usdc_dai_contract = accounts.at("0x9715b2786f1053294fc8952df923b95cab9aac42", force=True) - alliance_usdt_dai_contract = accounts.at("0x86f6c353a0965eb069cd7f4f91c1afef8c725551", force=True) - - # START VOTE - if len(vote_ids_from_env) > 0: - (vote_id,) = vote_ids_from_env - else: - tx_params = {"from": LDO_HOLDER_ADDRESS_FOR_TESTS} - vote_id, _ = start_vote(tx_params, silent=True) - - vote_tx = helpers.execute_vote(accounts, vote_id, contracts.voting) - - print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") - - evm_script_factories_after = easy_track.getEVMScriptFactories() - - # 1. Add TMC stETH top up EVM script factory address TBA (AllowedRecipientsRegistry address TBA) - assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after - - ''' - create_and_enact_payment_motion( - easy_track, - trusted_caller=alliance_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=steth, - recievers=[alliance_steth_contract], - transfer_amounts=[10 * 10**18], - stranger=stranger, - ) - ''' - - ''' - tmc_steth_allowed_recipients_registry = interface.AllowedRecipientRegistry( - "0x1a7cFA9EFB4D5BfFDE87B0FaEb1fC65d653868C0" - ) - check_add_and_remove_recipient_with_voting( - registry=tmc_steth_allowed_recipients_registry, - helpers=helpers, - ldo_holder=ldo_holder, - dao_voting=contracts.voting, - ) - ''' - - - dai_transfer_amount = 1_000 * 10**18 - ''' - prepare_agent_for_steth_payment(4 * dai_transfer_amount) - ''' - - usdc_transfer_amount = 1_000 * 10**6 - ''' - prepare_agent_for_usdc_payment(4 * usdc_transfer_amount) - ''' - - usdt_transfer_amount = 1_000 * 10**6 - ''' - prepare_agent_for_usdt_payment(4 * usdt_transfer_amount) - ''' - - # 2. Add TMC stables top up EVM script factory address TBA (AllowedRecipientsRegistry address TBA, AllowedTokensRegistry address TBA) - assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after - - create_and_enact_payment_motion( - easy_track, - trusted_caller=alliance_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=interface.Dai(DAI_TOKEN), - recievers=[alliance_dai_usdc_contract], - transfer_amounts=[dai_transfer_amount], - stranger=stranger, - ) - - create_and_enact_payment_motion( - easy_track, - trusted_caller=alliance_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=interface.Usdc(USDC_TOKEN), - recievers=[alliance_usdc_dai_contract], - transfer_amounts=[usdc_transfer_amount], - stranger=stranger, - ) - - create_and_enact_payment_motion( - easy_track, - trusted_caller=alliance_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=interface.Usdt(USDT_TOKEN), - recievers=[alliance_usdt_dai_contract], - transfer_amounts=[usdt_transfer_amount], - stranger=stranger, - ) - - with reverts("TOKEN_NOT_ALLOWED"): - create_and_enact_payment_motion( - easy_track, - trusted_caller=alliance_multisig_acc, - factory=alliance_ops_top_up_evm_script_factory_new, - token=steth, - recievers=[alliance_dai_usdc_contract], - transfer_amounts=[1], - stranger=stranger, - ) - - - alliance_ops_allowed_recipients_registry = interface.AllowedRecipientRegistry( - "0xe1ba8dee84a4df8e99e495419365d979cdb19991" - ) - - check_add_and_remove_recipient_with_voting( - registry=alliance_ops_allowed_recipients_registry, - helpers=helpers, - ldo_holder=ldo_holder, - dao_voting=contracts.voting, - ) - - # validate vote events - assert count_vote_items_by_events(vote_tx, contracts.voting) == 1, "Incorrect voting items count" - - metadata = find_metadata_by_vote_id(vote_id) - - assert get_lido_vote_cid_from_str(metadata) == "bafkreibbrlprupitulahcrl57uda4nkzrbfajtrhhsaa3cbx5of4t2huoa" # todo: поменять адрес после тестовой публикации голоосвания на форке - - display_voting_events(vote_tx) - ''' - if bypass_events_decoding or network_name() in ("goerli", "goerli-fork"): - return - ''' - - evs = group_voting_events(vote_tx) - - ''' - validate_evmscript_factory_added_event( - evs[0], - EVMScriptFactoryAdded( - factory_addr=alliance_ops_top_up_evm_script_factory_new, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], - ), - ) - ''' - validate_evmscript_factory_added_event( - evs[0], - EVMScriptFactoryAdded( - factory_addr=alliance_ops_top_up_evm_script_factory_new, - permissions=create_permissions(contracts.finance, "newImmediatePayment") - + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], - ), - ) - -''' -def prepare_agent_for_steth_payment(amount: int): - agent, steth = contracts.agent, contracts.lido - eth_whale = accounts.at("0x00000000219ab540356cBB839Cbe05303d7705Fa", force=True) - if steth.balanceOf(agent) < amount: - steth.submit(ZERO_ADDRESS, {"from": eth_whale, "value": amount + 2 * STETH_TRANSFER_MAX_DELTA}) - steth.transfer(agent, amount + STETH_TRANSFER_MAX_DELTA, {"from": eth_whale}) - assert steth.balanceOf(agent) >= amount, "Insufficient stETH balance" - - -def prepare_agent_for_dai_payment(amount: int): - agent, dai = contracts.agent, interface.Dai(DAI_TOKEN) - if dai.balanceOf(agent) < amount: - dai_ward_impersonated = accounts.at("0x9759A6Ac90977b93B58547b4A71c78317f391A28", force=True) - dai.mint(agent, amount, {"from": dai_ward_impersonated}) - - assert dai.balanceOf(agent) >= amount, f"Insufficient DAI balance" - - -def prepare_agent_for_usdc_payment(amount: int): - agent, usdc = contracts.agent, interface.Usdc(USDC_TOKEN) - if usdc.balanceOf(agent) < amount: - usdc_minter = accounts.at("0x5B6122C109B78C6755486966148C1D70a50A47D7", force=True) - usdc_controller = accounts.at("0x79E0946e1C186E745f1352d7C21AB04700C99F71", force=True) - usdc_master_minter = interface.UsdcMasterMinter("0xE982615d461DD5cD06575BbeA87624fda4e3de17") - usdc_master_minter.incrementMinterAllowance(amount, {"from": usdc_controller}) - usdc.mint(agent, amount, {"from": usdc_minter}) - - assert usdc.balanceOf(agent) >= amount, "Insufficient USDC balance" - - -def prepare_agent_for_usdt_payment(amount: int): - agent, usdt = contracts.agent, interface.Usdt(USDT_TOKEN) - if usdt.balanceOf(agent) < amount: - usdt_owner = accounts.at("0xC6CDE7C39eB2f0F0095F41570af89eFC2C1Ea828", force=True) - usdt.issue(amount, {"from": usdt_owner}) - usdt.transfer(agent, amount, {"from": usdt_owner}) - - assert usdt.balanceOf(agent) >= amount, "Insufficient USDT balance" -''' diff --git a/tests/test_2024_10_08_holesky.py b/tests/test_2024_10_08_holesky.py new file mode 100644 index 00000000..385cd625 --- /dev/null +++ b/tests/test_2024_10_08_holesky.py @@ -0,0 +1,131 @@ +""" +Tests for voting 08/10/2024 +Add ET setup for Alliance + +""" + +from scripts.vote_2024_10_08_holesky import start_vote +from brownie import interface, ZERO_ADDRESS, reverts, web3, accounts, convert +from utils.test.tx_tracing_helpers import * +from utils.voting import find_metadata_by_vote_id +from utils.ipfs import get_lido_vote_cid_from_str +from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, network_name +from utils.easy_track import create_permissions +from configs.config_mainnet import ( + DAI_TOKEN, + USDC_TOKEN, + USDT_TOKEN, +) +from utils.test.easy_track_helpers import create_and_enact_payment_motion, check_add_and_remove_recipient_with_voting +from utils.test.event_validators.easy_track import ( + validate_evmscript_factory_added_event, + EVMScriptFactoryAdded, + validate_evmscript_factory_removed_event, +) +_ +# STETH_TRANSFER_MAX_DELTA = 2 + +def test_vote(helpers, accounts, vote_ids_from_env, stranger, ldo_holder, bypass_events_decoding): + steth = "0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034" + easy_track = "0x1763b9ED3586B08AE796c7787811a2E1bc16163a" + + evm_script_factories_before = easy_track.getEVMScriptFactories() + + alliance_ops_allowed_recipients_registry = interface.AllowedRecipientRegistry( + "0xe1ba8dee84a4df8e99e495419365d979cdb19991" + ) + + alliance_ops_top_up_evm_script_factory_new = "0x343fa5f0c79277e2d27e440f40420d619f962a23" # TopUpAllowedRecipients + + alliance_multisig_acc = accounts.at("0x96d2Ff1C4D30f592B91fd731E218247689a76915", force=True) # Testnet DAO Multisigs + + assert alliance_ops_top_up_evm_script_factory_new not in evm_script_factories_before + + # START VOTE + if len(vote_ids_from_env) > 0: + (vote_id,) = vote_ids_from_env + else: + tx_params = {"from": LDO_HOLDER_ADDRESS_FOR_TESTS} + vote_id, _ = start_vote(tx_params, silent=True) + + vote_tx = helpers.execute_vote(accounts, vote_id, contracts.voting) + + print(f"voteId = {vote_id}, gasUsed = {vote_tx.gas_used}") + + evm_script_factories_after = easy_track.getEVMScriptFactories() + + # 1. Add Alliance top up EVM script factory address 0x9d156F7F5ed1fEbDc4996CAA835CD964A10bd650 (AllowedRecipientsRegistry address 0xe1ba8dee84a4df8e99e495419365d979cdb19991, AllowedTokensRegistry address 0x091c0ec8b4d54a9fcb36269b5d5e5af43309e666) + + assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after + + dai_transfer_amount = 1_000 * 10**18 + usdc_transfer_amount = 1_000 * 10**6 + usdt_transfer_amount = 1_000 * 10**6 + + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Dai(DAI_TOKEN), + recievers=[alliance_multisig_acc], + transfer_amounts=[dai_transfer_amount], + stranger=stranger, + ) + + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Usdc(USDC_TOKEN), + recievers=[alliance_multisig_acc], + transfer_amounts=[usdc_transfer_amount], + stranger=stranger, + ) + + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=interface.Usdt(USDT_TOKEN), + recievers=[alliance_multisig_acc], + transfer_amounts=[usdt_transfer_amount], + stranger=stranger, + ) + + with reverts("TOKEN_NOT_ALLOWED"): + create_and_enact_payment_motion( + easy_track, + trusted_caller=alliance_multisig_acc, + factory=alliance_ops_top_up_evm_script_factory_new, + token=steth, + recievers=[alliance_multisig_acc], + transfer_amounts=[1], + stranger=stranger, + ) + + check_add_and_remove_recipient_with_voting( + registry=alliance_ops_allowed_recipients_registry, + helpers=helpers, + ldo_holder=ldo_holder, + dao_voting=contracts.voting, + ) + + # validate vote events + assert count_vote_items_by_events(vote_tx, contracts.voting) == 1, "Incorrect voting items count" + + metadata = find_metadata_by_vote_id(vote_id) + + assert get_lido_vote_cid_from_str(metadata) == "bafkreibbrlprupitulahcrl57uda4nkzrbfajtrhhsaa3cbx5of4t2huoa" # todo: поменять адрес после тестовой публикации голоосвания на форке + + display_voting_events(vote_tx) + + evs = group_voting_events(vote_tx) + + validate_evmscript_factory_added_event( + evs[0], + EVMScriptFactoryAdded( + factory_addr=alliance_ops_top_up_evm_script_factory_new, + permissions=create_permissions(contracts.finance, "newImmediatePayment") + + create_permissions(alliance_ops_allowed_recipients_registry, "updateSpentAmount")[2:], + ), + ) From c04bc0eb4bc8b96b9e3fe30ed0d2118dcd61cd1f Mon Sep 17 00:00:00 2001 From: zuzueeka Date: Fri, 27 Sep 2024 19:33:13 +0300 Subject: [PATCH 4/5] add stables addresses on holesky --- configs/config_holesky.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/config_holesky.py b/configs/config_holesky.py index 51658631..60fdc6ea 100644 --- a/configs/config_holesky.py +++ b/configs/config_holesky.py @@ -79,9 +79,9 @@ "0x1d835790d93a28fb30d998c0cb27426e5d2d7c8c", ] # General network addresses -DAI_TOKEN = "" -USDT_TOKEN = "" -USDC_TOKEN = "" +DAI_TOKEN = "0x2eb8e9198e647f80ccf62a5e291bcd4a5a3ca68c" +USDT_TOKEN = "0x86f6c353a0965eb069cd7f4f91c1afef8c725551" +USDC_TOKEN = "0x9715b2786f1053294fc8952df923b95cab9aac42" WETH_TOKEN = "" From 4d97a13af7ac2840e8342781c17fc5cd906bf1f8 Mon Sep 17 00:00:00 2001 From: zuzueeka Date: Fri, 27 Sep 2024 19:33:41 +0300 Subject: [PATCH 5/5] fix tests --- tests/test_2024_10_08_holesky.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/tests/test_2024_10_08_holesky.py b/tests/test_2024_10_08_holesky.py index 385cd625..03821c2d 100644 --- a/tests/test_2024_10_08_holesky.py +++ b/tests/test_2024_10_08_holesky.py @@ -11,7 +11,7 @@ from utils.ipfs import get_lido_vote_cid_from_str from utils.config import contracts, LDO_HOLDER_ADDRESS_FOR_TESTS, network_name from utils.easy_track import create_permissions -from configs.config_mainnet import ( +from configs.config_holesky import ( DAI_TOKEN, USDC_TOKEN, USDT_TOKEN, @@ -20,24 +20,18 @@ from utils.test.event_validators.easy_track import ( validate_evmscript_factory_added_event, EVMScriptFactoryAdded, - validate_evmscript_factory_removed_event, ) -_ -# STETH_TRANSFER_MAX_DELTA = 2 def test_vote(helpers, accounts, vote_ids_from_env, stranger, ldo_holder, bypass_events_decoding): - steth = "0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034" - easy_track = "0x1763b9ED3586B08AE796c7787811a2E1bc16163a" - evm_script_factories_before = easy_track.getEVMScriptFactories() - - alliance_ops_allowed_recipients_registry = interface.AllowedRecipientRegistry( - "0xe1ba8dee84a4df8e99e495419365d979cdb19991" - ) + steth = interface.StETH("0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034") + easy_track = interface.EasyTrack("0x1763b9ED3586B08AE796c7787811a2E1bc16163a") - alliance_ops_top_up_evm_script_factory_new = "0x343fa5f0c79277e2d27e440f40420d619f962a23" # TopUpAllowedRecipients + evm_script_factories_before = easy_track.getEVMScriptFactories() - alliance_multisig_acc = accounts.at("0x96d2Ff1C4D30f592B91fd731E218247689a76915", force=True) # Testnet DAO Multisigs + alliance_ops_allowed_recipients_registry = interface.AllowedRecipientRegistry("0xe1ba8dee84a4df8e99e495419365d979cdb19991") + alliance_ops_top_up_evm_script_factory_new = interface.TopUpAllowedRecipients("0x343fa5f0c79277e2d27e440f40420d619f962a23") + alliance_multisig_acc = accounts.at("0x96d2Ff1C4D30f592B91fd731E218247689a76915", force=True) # Testnet DAO-Ops&QA Multisig assert alliance_ops_top_up_evm_script_factory_new not in evm_script_factories_before @@ -54,8 +48,6 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger, ldo_holder, bypass evm_script_factories_after = easy_track.getEVMScriptFactories() - # 1. Add Alliance top up EVM script factory address 0x9d156F7F5ed1fEbDc4996CAA835CD964A10bd650 (AllowedRecipientsRegistry address 0xe1ba8dee84a4df8e99e495419365d979cdb19991, AllowedTokensRegistry address 0x091c0ec8b4d54a9fcb36269b5d5e5af43309e666) - assert alliance_ops_top_up_evm_script_factory_new in evm_script_factories_after dai_transfer_amount = 1_000 * 10**18 @@ -119,6 +111,9 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger, ldo_holder, bypass display_voting_events(vote_tx) + if bypass_events_decoding or network_name() in ("holesky", "holesky-fork"): + return + evs = group_voting_events(vote_tx) validate_evmscript_factory_added_event(