Skip to content

Commit

Permalink
fix: don't return empty list of registrations (#255)
Browse files Browse the repository at this point in the history
fixes:
- For cases where an SPO had all registrations invalid we no longer return empty list. That fixes the issue with calculating committee participation probability if T > 0 and SPO has no valid registrations.

Refs: ETCM-8662
  • Loading branch information
rsporny authored Nov 20, 2024
1 parent 89b2ada commit 2dd19c3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion E2E-tests/src/blockchain_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def get_trustless_candidates(self, mc_epoch: int, valid_only: bool) -> dict:
Arguments:
mc_epoch {int}
valid_only {bool} -- if True, returns only valid candidates
valid_only {bool} -- if True returns only valid registrations for an SPO.
Return: A dict of SPOs. Example response:
```
Expand Down
1 change: 1 addition & 0 deletions E2E-tests/src/substrate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ def get_trustless_candidates(self, mc_epoch, valid_only):
registrations = {
spo: [candidate for candidate in candidates if candidate["isValid"]]
for spo, candidates in registrations.items()
if any(candidate["isValid"] for candidate in candidates)
}
return registrations

Expand Down
2 changes: 2 additions & 0 deletions E2E-tests/tests/committee/test_committee.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ def test_there_is_at_least_one_trustless_candidate(self, api: BlockchainApi, cur
"""Test that the configured d-parameter has at least one trustless candidate"""
if api.get_d_param(current_mc_epoch).trustless_candidates_number == 0:
skip("T==0, test is irrelevant")
if current_mc_epoch < 3:
skip("Stake pool is not yet initialized")
assert len(api.get_trustless_candidates(current_mc_epoch, valid_only=True)) > 0

@mark.skip_blockchain("pc_evm", reason="not implemented yet on pc_evm")
Expand Down

0 comments on commit 2dd19c3

Please sign in to comment.