diff --git a/skale/contracts/delegation/validator_service.py b/skale/contracts/delegation/validator_service.py index 1438f794..d4c188d5 100644 --- a/skale/contracts/delegation/validator_service.py +++ b/skale/contracts/delegation/validator_service.py @@ -152,6 +152,12 @@ def _enable_validator(self, validator_id: int) -> TxRes: func = self.contract.functions.enableValidator(validator_id) return post_transaction(self.skale.wallet, func, GAS['enable_validator']) + @transaction_method + def _disable_validator(self, validator_id: int) -> TxRes: + """For internal usage only""" + func = self.contract.functions.disableValidator(validator_id) + return post_transaction(self.skale.wallet, func, GAS['disable_validator']) + def _is_validator_trusted(self, validator_id: int) -> bool: """For internal usage only""" return self.contract.functions.trustedValidators(validator_id).call() diff --git a/skale/utils/constants.py b/skale/utils/constants.py index 3a52edf5..f914407f 100644 --- a/skale/utils/constants.py +++ b/skale/utils/constants.py @@ -43,6 +43,7 @@ 'delegate': 3000000, 'accept_pending_delegation': 1000000, 'enable_validator': 1000000, + 'disable_validator': 1000000, 'link_node_address': 1000000, 'unlink_node_address': 1000000, 'cancel_pending_delegation': 1000000, diff --git a/tests/contracts/delegation/validator_service_test.py b/tests/contracts/delegation/validator_service_test.py index af2367a0..abfa0b60 100644 --- a/tests/contracts/delegation/validator_service_test.py +++ b/tests/contracts/delegation/validator_service_test.py @@ -122,6 +122,30 @@ def test_enable_validator(skale): assert is_validator_trusted +def test_disable_validator(skale): + _generate_new_validator(skale) + latest_id = skale.validator_service.number_of_validators() + + is_validator_trusted = skale.validator_service._is_validator_trusted(latest_id) + assert not is_validator_trusted + + tx_res = skale.validator_service._enable_validator( + validator_id=latest_id, + wait_for=True + ) + check_receipt(tx_res.receipt) + + is_validator_trusted = skale.validator_service._is_validator_trusted(latest_id) + assert is_validator_trusted + + tx_res = skale.validator_service._disable_validator( + validator_id=latest_id, + wait_for=True + ) + is_validator_trusted = skale.validator_service._is_validator_trusted(latest_id) + assert not is_validator_trusted + + def test_is_validator_trusted(skale): is_validator_trusted = skale.validator_service._is_validator_trusted(D_VALIDATOR_ID) assert is_validator_trusted