From 2dd19c37a16789a5b6aa7b436198a3b8efcf027b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Sporny?= Date: Wed, 20 Nov 2024 17:08:56 +0100 Subject: [PATCH] fix: don't return empty list of registrations (#255) 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 --- E2E-tests/src/blockchain_api.py | 2 +- E2E-tests/src/substrate_api.py | 1 + E2E-tests/tests/committee/test_committee.py | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/E2E-tests/src/blockchain_api.py b/E2E-tests/src/blockchain_api.py index b0e8d1f66..2bdce881d 100644 --- a/E2E-tests/src/blockchain_api.py +++ b/E2E-tests/src/blockchain_api.py @@ -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: ``` diff --git a/E2E-tests/src/substrate_api.py b/E2E-tests/src/substrate_api.py index a863071db..b8733269e 100644 --- a/E2E-tests/src/substrate_api.py +++ b/E2E-tests/src/substrate_api.py @@ -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 diff --git a/E2E-tests/tests/committee/test_committee.py b/E2E-tests/tests/committee/test_committee.py index 3ff0410b4..8765a208e 100644 --- a/E2E-tests/tests/committee/test_committee.py +++ b/E2E-tests/tests/committee/test_committee.py @@ -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")