From ddd45aa1b35679a65e9e96a56abfbf73a6fa859f Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Thu, 11 Jul 2024 14:56:02 +0200 Subject: [PATCH 1/3] Call expensive function only once and store the result in a variable --- cardano_node_tests/tests/tests_conway/test_pparam_update.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 328222635..5027bbd5a 100644 --- a/cardano_node_tests/tests/tests_conway/test_pparam_update.py +++ b/cardano_node_tests/tests/tests_conway/test_pparam_update.py @@ -1256,7 +1256,8 @@ def _check_state(state: dict): governance_utils.check_vote_view(cluster_obj=cluster, vote_data=fin_voted_votes.drep[0]) # Check deposit return for both after enactment and expiration - [r.start(url=helpers.get_vcs_link()) for r in (reqc.cip034ex, reqc.cip034en)] + _url = helpers.get_vcs_link() + [r.start(url=_url) for r in (reqc.cip034ex, reqc.cip034en)] # First wait to ensure that all proposals are expired/enacted for deposit to be retuned _cur_epoch = cluster.g_query.get_epoch() From 2564185ec4cfc1793cd7d6cb509b8baeba401ca5 Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Thu, 11 Jul 2024 14:58:44 +0200 Subject: [PATCH 2/3] Fix typo --- cardano_node_tests/tests/tests_conway/test_pparam_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5027bbd5a..501dd3276 100644 --- a/cardano_node_tests/tests/tests_conway/test_pparam_update.py +++ b/cardano_node_tests/tests/tests_conway/test_pparam_update.py @@ -1269,7 +1269,7 @@ def _check_state(state: dict): total_deposit_return = cluster.g_query.get_stake_addr_info( pool_user_lg.stake.address ).reward_account_balance - # Check total deposit return accounting for both expired and enaacted actions + # Check total deposit return accounting for both expired and enacted actions assert ( total_deposit_return == init_return_account_balance + deposit_amt * submitted_proposal_count From 8db0dc5402e5d2b5de6fe181b5d6ac4178aab54c Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Thu, 11 Jul 2024 14:59:18 +0200 Subject: [PATCH 3/3] Move the least important checks to the end of test --- .../tests/tests_conway/test_info.py | 34 +++++++++---------- .../tests/tests_conway/test_pparam_update.py | 12 +++---- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cardano_node_tests/tests/tests_conway/test_info.py b/cardano_node_tests/tests/tests_conway/test_info.py index 78fa1854a..10c0fd3dc 100644 --- a/cardano_node_tests/tests/tests_conway/test_info.py +++ b/cardano_node_tests/tests/tests_conway/test_info.py @@ -233,23 +233,6 @@ def test_info( ], "Ratification is delayed unexpectedly" reqc.cip038_05.success() - # Check action view - governance_utils.check_action_view(cluster_obj=cluster, action_data=info_action) - - # Check vote view - reqc.cli022.start(url=helpers.get_vcs_link()) - if votes_cc: - governance_utils.check_vote_view(cluster_obj=cluster, vote_data=votes_cc[0]) - governance_utils.check_vote_view(cluster_obj=cluster, vote_data=votes_drep[0]) - governance_utils.check_vote_view(cluster_obj=cluster, vote_data=votes_spo[0]) - reqc.cli022.success() - - # Check dbsync - dbsync_utils.check_votes( - votes=governance_utils.VotedVotes(cc=votes_cc, drep=votes_drep, spo=votes_spo), - txhash=vote_txid, - ) - # Check deposit is returned reqc.cip034ex.start(url=helpers.get_vcs_link()) @@ -267,3 +250,20 @@ def test_info( deposit_returned == init_return_account_balance + action_deposit_amt ), "Incorrect return account balance" reqc.cip034ex.success() + + # Check action view + governance_utils.check_action_view(cluster_obj=cluster, action_data=info_action) + + # Check vote view + reqc.cli022.start(url=helpers.get_vcs_link()) + if votes_cc: + governance_utils.check_vote_view(cluster_obj=cluster, vote_data=votes_cc[0]) + governance_utils.check_vote_view(cluster_obj=cluster, vote_data=votes_drep[0]) + governance_utils.check_vote_view(cluster_obj=cluster, vote_data=votes_spo[0]) + reqc.cli022.success() + + # Check dbsync + dbsync_utils.check_votes( + votes=governance_utils.VotedVotes(cc=votes_cc, drep=votes_drep, spo=votes_spo), + txhash=vote_txid, + ) 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 501dd3276..df91299e3 100644 --- a/cardano_node_tests/tests/tests_conway/test_pparam_update.py +++ b/cardano_node_tests/tests/tests_conway/test_pparam_update.py @@ -1249,12 +1249,6 @@ def _check_state(state: dict): err_str = str(excinfo.value) assert "(GovActionsDoNotExist" in err_str, err_str - # Check vote view - if fin_voted_votes.cc: - governance_utils.check_vote_view(cluster_obj=cluster, vote_data=fin_voted_votes.cc[0]) - if fin_voted_votes.drep: - governance_utils.check_vote_view(cluster_obj=cluster, vote_data=fin_voted_votes.drep[0]) - # Check deposit return for both after enactment and expiration _url = helpers.get_vcs_link() [r.start(url=_url) for r in (reqc.cip034ex, reqc.cip034en)] @@ -1276,6 +1270,12 @@ def _check_state(state: dict): ), "Incorrect return account balance" [r.success() for r in (reqc.cip034ex, reqc.cip034en)] + # Check vote view + if fin_voted_votes.cc: + governance_utils.check_vote_view(cluster_obj=cluster, vote_data=fin_voted_votes.cc[0]) + if fin_voted_votes.drep: + governance_utils.check_vote_view(cluster_obj=cluster, vote_data=fin_voted_votes.drep[0]) + if db_errors_final: raise AssertionError("\n".join(db_errors_final)) [r.success() for r in (reqc.cip080, reqc.cip081, reqc.cip082, reqc.cip083)]