|
11 | 11 | from cardano_node_tests.tests import common |
12 | 12 | from cardano_node_tests.tests.tests_conway import conway_common |
13 | 13 | from cardano_node_tests.tests.tests_plutus_v2 import mint_raw |
14 | | -from cardano_node_tests.utils import clusterlib_utils |
15 | 14 | from cardano_node_tests.utils import configuration |
16 | 15 | from cardano_node_tests.utils import governance_utils |
17 | 16 | from cardano_node_tests.utils import helpers |
@@ -95,85 +94,28 @@ def test_update_in_pv9( |
95 | 94 | if len(init_cost_model) >= 185: |
96 | 95 | pytest.skip("PlutusV2 cost model was already updated.") |
97 | 96 |
|
98 | | - cost_proposal_file = DATA_DIR / "cost_models_list_185_v2_v3.json" |
99 | | - |
100 | | - def _update_cost_model() -> None: |
101 | | - anchor_data = governance_utils.get_default_anchor_data() |
102 | | - _name_template = f"{temp_template}_cost_model" |
103 | | - |
104 | | - update_proposals = [ |
105 | | - clusterlib_utils.UpdateProposal( |
106 | | - arg="--cost-model-file", |
107 | | - value=str(cost_proposal_file), |
108 | | - name="", # costModels |
109 | | - ) |
110 | | - ] |
111 | | - |
112 | | - cost_model_proposal = conway_common.propose_pparams_update( |
113 | | - cluster_obj=cluster, |
114 | | - name_template=_name_template, |
115 | | - anchor_url=anchor_data.url, |
116 | | - anchor_data_hash=anchor_data.hash, |
117 | | - pool_user=pool_user_lgp, |
118 | | - proposals=update_proposals, |
119 | | - ) |
120 | | - |
121 | | - # Make sure we have enough time to submit the votes in one epoch |
122 | | - clusterlib_utils.wait_for_epoch_interval(cluster_obj=cluster, start=1, stop=-40) |
123 | | - prop_epoch = cluster.g_query.get_epoch() |
124 | | - |
125 | | - # Vote & approve the action |
126 | | - conway_common.cast_vote( |
127 | | - cluster_obj=cluster, |
128 | | - governance_data=governance_data, |
129 | | - name_template=f"{_name_template}_yes", |
130 | | - payment_addr=pool_user_lgp.payment, |
131 | | - action_txid=cost_model_proposal.action_txid, |
132 | | - action_ix=cost_model_proposal.action_ix, |
133 | | - approve_cc=True, |
134 | | - ) |
135 | | - |
136 | | - assert cluster.g_query.get_epoch() == prop_epoch, ( |
137 | | - "Epoch changed and it would affect other checks" |
138 | | - ) |
139 | | - |
140 | | - # Wait for ratification |
141 | | - rat_epoch = cluster.wait_for_epoch(epoch_no=prop_epoch + 1, padding_seconds=5) |
142 | | - rat_gov_state = cluster.g_query.get_gov_state() |
143 | | - conway_common.save_gov_state( |
144 | | - gov_state=rat_gov_state, name_template=f"{_name_template}_{rat_epoch}" |
145 | | - ) |
146 | | - rat_action = governance_utils.lookup_ratified_actions( |
147 | | - state=rat_gov_state, |
148 | | - action_txid=cost_model_proposal.action_txid, |
149 | | - action_ix=cost_model_proposal.action_ix, |
150 | | - ) |
151 | | - assert rat_action, "Action not found in ratified actions" |
152 | | - |
153 | | - # Wait for enactment |
154 | | - enact_epoch = cluster.wait_for_epoch(epoch_no=prop_epoch + 2, padding_seconds=5) |
155 | | - enact_gov_state = cluster.g_query.get_gov_state() |
156 | | - conway_common.save_gov_state( |
157 | | - gov_state=enact_gov_state, name_template=f"{temp_template}_enact_{enact_epoch}" |
158 | | - ) |
159 | | - pparams = enact_gov_state.get("currentPParams") or {} |
160 | | - assert len(pparams["costModels"]["PlutusV2"]) == 185 |
161 | | - |
162 | 97 | # Check that Plutus script fails as expected in PV9 |
163 | 98 | mint_raw.check_missing_builtin( |
164 | 99 | cluster_obj=cluster, |
165 | | - temp_template=temp_template, |
| 100 | + temp_template=f"{temp_template}_check1", |
166 | 101 | payment_addr=payment_addrs_lgp[0], |
167 | 102 | issuer_addr=payment_addrs_lgp[1], |
168 | 103 | ) |
169 | 104 |
|
170 | 105 | # Update the PlutusV2 cost model |
171 | | - _update_cost_model() |
| 106 | + updated_cost_models = conway_common.update_cost_model( |
| 107 | + cluster_obj=cluster, |
| 108 | + name_template=f"{temp_template}_cost_model", |
| 109 | + governance_data=governance_data, |
| 110 | + cost_proposal_file=DATA_DIR / "cost_models_list_185_v2_v3.json", |
| 111 | + pool_user=pool_user_lgp, |
| 112 | + ) |
| 113 | + assert len(updated_cost_models["PlutusV2"]) == 185 |
172 | 114 |
|
173 | 115 | # Check again that the Plutus script fails as expected in PV9 |
174 | 116 | mint_raw.check_missing_builtin( |
175 | 117 | cluster_obj=cluster, |
176 | | - temp_template=temp_template, |
| 118 | + temp_template=f"{temp_template}_check2", |
177 | 119 | payment_addr=payment_addrs_lgp[0], |
178 | 120 | issuer_addr=payment_addrs_lgp[1], |
179 | 121 | ) |
0 commit comments