Skip to content

Commit

Permalink
Merge branch 'develop' into feature/SKALE-2246-node-indicies-function
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrotkk authored Mar 4, 2020
2 parents ee96a59 + 4ae9df0 commit 1000c43
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions skale/contracts/delegation/validator_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 1 addition & 0 deletions skale/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions tests/contracts/delegation/validator_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1000c43

Please sign in to comment.