From 8a0c924cba25e47ae2f4beb210dd141443490539 Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Mon, 4 Nov 2024 16:10:20 +0100 Subject: [PATCH 1/2] refactor: update current protocol params query method Updated the method for querying protocol parameters from `g_conway_governance.query.gov_state()["currentPParams"]` to `g_query.get_protocol_params()` across multiple test files. It is cheaper to get just protocol parameters than complete governance state. --- cardano_node_tests/tests/tests_conway/conway_common.py | 4 +--- cardano_node_tests/tests/tests_conway/test_committee.py | 2 +- cardano_node_tests/tests/tests_conway/test_pparam_update.py | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cardano_node_tests/tests/tests_conway/conway_common.py b/cardano_node_tests/tests/tests_conway/conway_common.py index a87bb1a90..38c585bc8 100644 --- a/cardano_node_tests/tests/tests_conway/conway_common.py +++ b/cardano_node_tests/tests/tests_conway/conway_common.py @@ -29,9 +29,7 @@ def is_in_bootstrap( cluster_obj: clusterlib.ClusterLib, ) -> bool: """Check if the cluster is in bootstrap period.""" - pv = cluster_obj.g_conway_governance.query.gov_state()["currentPParams"]["protocolVersion"][ - "major" - ] + pv = cluster_obj.g_query.get_protocol_params()["protocolVersion"]["major"] return bool(pv == 9) diff --git a/cardano_node_tests/tests/tests_conway/test_committee.py b/cardano_node_tests/tests/tests_conway/test_committee.py index b9dd2a715..bb43e04cb 100644 --- a/cardano_node_tests/tests/tests_conway/test_committee.py +++ b/cardano_node_tests/tests/tests_conway/test_committee.py @@ -340,7 +340,7 @@ def test_add_rm_committee_members( # noqa: C901 # undelegated stake is treated as Abstain. If undelegated stake was treated as No, it # would not be possible to approve any action. delegated_stake = governance_utils.get_delegated_stake(cluster_obj=cluster) - cur_pparams = cluster.g_conway_governance.query.gov_state()["currentPParams"] + cur_pparams = cluster.g_query.get_protocol_params() drep_constitution_threshold = cur_pparams["dRepVotingThresholds"]["committeeNormal"] spo_constitution_threshold = cur_pparams["poolVotingThresholds"]["committeeNormal"] is_drep_total_below_threshold = ( diff --git a/cardano_node_tests/tests/tests_conway/test_pparam_update.py b/cardano_node_tests/tests/tests_conway/test_pparam_update.py index 4c72cd074..c2175cc1e 100644 --- a/cardano_node_tests/tests/tests_conway/test_pparam_update.py +++ b/cardano_node_tests/tests/tests_conway/test_pparam_update.py @@ -264,7 +264,7 @@ def test_pparam_update( # noqa: C901 # undelegated stake is treated as Abstain. If undelegated stake was treated as Yes, then # missing votes would approve the action. delegated_stake = governance_utils.get_delegated_stake(cluster_obj=cluster) - cur_pparams = cluster.g_conway_governance.query.gov_state()["currentPParams"] + cur_pparams = cluster.g_query.get_protocol_params() drep_constitution_threshold = cur_pparams["dRepVotingThresholds"]["ppGovGroup"] spo_constitution_threshold = cur_pparams["poolVotingThresholds"]["ppSecurityGroup"] is_drep_total_below_threshold = ( @@ -590,7 +590,7 @@ def test_pparam_update( # noqa: C901 ] # Hand-picked parameters and values that can stay changed even for other tests - cur_pparams = cluster.g_conway_governance.query.gov_state()["currentPParams"] + cur_pparams = cluster.g_query.get_protocol_params() fin_update_proposals = [ # From network group clusterlib_utils.UpdateProposal( @@ -1353,7 +1353,7 @@ def test_pparam_keys( _url = helpers.get_vcs_link() [r.start(url=_url) for r in (reqc.cip075, reqc.cip076, reqc.cip077, reqc.cip078)] - cur_pparam = cluster.g_conway_governance.query.gov_state()["currentPParams"] + cur_pparam = cluster.g_query.get_protocol_params() cur_pparam_keys = set(cur_pparam.keys()) known_pparam_keys = set().union( NETWORK_GROUP_PPARAMS, From b2a97aa43c47bef8ef880f18f05b5064c356e08b Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Mon, 4 Nov 2024 16:11:54 +0100 Subject: [PATCH 2/2] fix(tests): simplify pparams extraction in test_update_plutusv2_builtins Simplified the extraction of `pparams` by removing redundant checks for `curPParams`, which is not needed for enacted state. --- .../tests/tests_conway/test_update_plutusv2_builtins.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cardano_node_tests/tests/tests_conway/test_update_plutusv2_builtins.py b/cardano_node_tests/tests/tests_conway/test_update_plutusv2_builtins.py index 7a5654f27..5f6694e92 100644 --- a/cardano_node_tests/tests/tests_conway/test_update_plutusv2_builtins.py +++ b/cardano_node_tests/tests/tests_conway/test_update_plutusv2_builtins.py @@ -163,9 +163,7 @@ def _update_cost_model() -> None: conway_common.save_gov_state( gov_state=enact_gov_state, name_template=f"{temp_template}_enact_{enact_epoch}" ) - pparams = ( - enact_gov_state.get("curPParams") or enact_gov_state.get("currentPParams") or {} - ) + pparams = enact_gov_state.get("currentPParams") or {} assert len(pparams["costModels"]["PlutusV2"]) == 185 # Check that Plutus script fails as expected in PV9