Skip to content

Commit

Permalink
feat: add easy track factories check
Browse files Browse the repository at this point in the history
  • Loading branch information
rkolpakov committed Feb 7, 2024
1 parent fcbba22 commit 6ced0f9
Showing 1 changed file with 84 additions and 1 deletion.
85 changes: 84 additions & 1 deletion tests/test_simple_dvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
SET_NODE_OPERATOR_LIMIT_ROLE = "0x07b39e0faf2521001ae4e58cb9ffd3840a63e205d288dc9c93c3774f0d794754"
MANAGE_SIGNING_KEYS = "0x75abc64490e17b40ea1e66691c3eb493647b24430b358bd87ec3e5127f1621ee"

# TODO: check trusted caller address
TRUSTED_CALLER = "0x08637515E85A4633E23dfc7861e2A9f53af640f7"

simple_dvt_repo_ens = "simple-dvt.lidopm.eth"
simple_dvt_content_uri = (
Expand Down Expand Up @@ -196,6 +198,88 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger, bypass_events_deco
assert update_target_validator_limits_evm_script_factory in evm_script_factories
assert change_node_operator_managers_evm_script_factory in evm_script_factories

evs = group_voting_events(vote_tx)

validate_evmscript_factory_added_event(
evs[8],
EVMScriptFactoryAdded(
factory_addr=add_node_operators_evm_script_factory,
permissions=create_permissions(simple_dvt, "addNodeOperator")
+ create_permissions(contracts.acl, "grantPermissionP")[2:]
)
)
validate_evmscript_factory_added_event(
evs[9],
EVMScriptFactoryAdded(
factory_addr=activate_node_operators_evm_script_factory,
permissions=create_permissions(simple_dvt, "activateNodeOperator")
+ create_permissions(contracts.acl, "grantPermissionP")[2:]
)
)
validate_evmscript_factory_added_event(
evs[10],
EVMScriptFactoryAdded(
factory_addr=deactivate_node_operators_evm_script_factory,
permissions=create_permissions(simple_dvt, "deactivateNodeOperator")
+ create_permissions(contracts.acl, "revokePermission")[2:]
)
)
validate_evmscript_factory_added_event(
evs[11],
EVMScriptFactoryAdded(
factory_addr=set_vetted_validators_limits_evm_script_factory,
permissions=create_permissions(simple_dvt, "setNodeOperatorStakingLimit")
)
)
validate_evmscript_factory_added_event(
evs[12],
EVMScriptFactoryAdded(
factory_addr=update_target_validator_limits_evm_script_factory,
permissions=create_permissions(simple_dvt, "updateTargetValidatorsLimits")
)
)
validate_evmscript_factory_added_event(
evs[13],
EVMScriptFactoryAdded(
factory_addr=set_node_operator_names_evm_script_factory,
permissions=create_permissions(simple_dvt, "setNodeOperatorName")
)
)
validate_evmscript_factory_added_event(
evs[14],
EVMScriptFactoryAdded(
factory_addr=set_node_operator_reward_addresses_evm_script_factory,
permissions=create_permissions(simple_dvt, "setNodeOperatorRewardAddress")
)
)
validate_evmscript_factory_added_event(
evs[15],
EVMScriptFactoryAdded(
factory_addr=change_node_operator_managers_evm_script_factory,
permissions=create_permissions(contracts.acl, "revokePermission")
+ create_permissions(contracts.acl, "grantPermissionP")[2:]
)
)

assert interface.AddNodeOperators(add_node_operators_evm_script_factory).nodeOperatorsRegistry() == simple_dvt
assert interface.AddNodeOperators(add_node_operators_evm_script_factory).trustedCaller() == TRUSTED_CALLER
assert interface.ActivateNodeOperators(activate_node_operators_evm_script_factory).nodeOperatorsRegistry() == simple_dvt
assert interface.ActivateNodeOperators(activate_node_operators_evm_script_factory).trustedCaller() == TRUSTED_CALLER
assert interface.DeactivateNodeOperators(deactivate_node_operators_evm_script_factory).nodeOperatorsRegistry() == simple_dvt
assert interface.DeactivateNodeOperators(deactivate_node_operators_evm_script_factory).trustedCaller() == TRUSTED_CALLER
assert interface.SetVettedValidatorsLimits(set_vetted_validators_limits_evm_script_factory).nodeOperatorsRegistry() == simple_dvt
assert interface.SetVettedValidatorsLimits(set_vetted_validators_limits_evm_script_factory).trustedCaller() == TRUSTED_CALLER
assert interface.SetNodeOperatorNames(set_node_operator_names_evm_script_factory).nodeOperatorsRegistry() == simple_dvt
assert interface.SetNodeOperatorNames(set_node_operator_names_evm_script_factory).trustedCaller() == TRUSTED_CALLER
assert interface.SetNodeOperatorRewardAddresses(set_node_operator_reward_addresses_evm_script_factory).nodeOperatorsRegistry() == simple_dvt
assert interface.SetNodeOperatorRewardAddresses(set_node_operator_reward_addresses_evm_script_factory).trustedCaller() == TRUSTED_CALLER
assert interface.UpdateTargetValidatorLimits(update_target_validator_limits_evm_script_factory).nodeOperatorsRegistry() == simple_dvt
assert interface.UpdateTargetValidatorLimits(update_target_validator_limits_evm_script_factory).trustedCaller() == TRUSTED_CALLER
assert interface.ChangeNodeOperatorManagers(change_node_operator_managers_evm_script_factory).nodeOperatorsRegistry() == simple_dvt
assert interface.ChangeNodeOperatorManagers(change_node_operator_managers_evm_script_factory).trustedCaller() == TRUSTED_CALLER



# validate vote events
# assert count_vote_items_by_events(vote_tx, contracts.voting) == 65, "Incorrect voting items count"

Expand All @@ -204,7 +288,6 @@ def test_vote(helpers, accounts, vote_ids_from_env, stranger, bypass_events_deco
# if bypass_events_decoding or network_name() in ("goerli", "goerli-fork"):
# return

# evs = group_voting_events(vote_tx)


def has_permission(permission: Permission, how: List[int]) -> bool:
Expand Down

0 comments on commit 6ced0f9

Please sign in to comment.