Skip to content

Commit

Permalink
Merge pull request #118 from skalenetwork/feature/SKALE-2246-node-ind…
Browse files Browse the repository at this point in the history
…icies-function

SKALE-2246 Add get_validator_node_indices function
  • Loading branch information
dmytrotkk authored Mar 4, 2020
2 parents 4ae9df0 + 1000c43 commit 01b25d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions skale/contracts/delegation/validator_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ def get_trusted_validator_ids(self) -> list:
"""
return self.contract.functions.getTrustedValidators().call()

def get_validator_node_indices(self, validator_id: int) -> list:
"""Returns list of node indices to the validator
:returns: List of trusted node indices
:rtype: list
"""
return self.contract.functions.getValidatorNodeIndexes(validator_id).call()

@transaction_method
def _enable_validator(self, validator_id: int) -> TxRes:
"""For internal usage only"""
Expand Down
8 changes: 8 additions & 0 deletions tests/contracts/delegation/validator_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ def test_validator_id_by_address(skale):
assert validator_id == D_VALIDATOR_ID


def test_get_validator_node_indices(skale):
node_indices = skale.validator_service.get_validator_node_indices(
validator_id=D_VALIDATOR_ID
)
assert 0 in node_indices
assert 1 in node_indices


def test_enable_validator(skale):
_generate_new_validator(skale)
latest_id = skale.validator_service.number_of_validators()
Expand Down

0 comments on commit 01b25d3

Please sign in to comment.