Skip to content

Commit 75687d4

Browse files
committed
refactor(tests): check payment address funds for each plutus script
Move the creation and funding of payment addresses into the `run_scenario` function to ensure sufficient funds for each test scenario.
1 parent 1583ba5 commit 75687d4

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

cardano_node_tests/tests/tests_plutus_v3/test_mint_build.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def update_cost_model(
7070
cost_model_len: int,
7171
) -> None:
7272
"""Update cost model to include values for new Plutus Core built-in functions."""
73+
name_template = f"{temp_template}_cost_model_upd"
74+
7375
if prot_version == BATCH5_PROT_VERSION:
7476
if cost_model_len >= BATCH5_COST_MODEL_LEN:
7577
return
@@ -86,7 +88,7 @@ def update_cost_model(
8688
return
8789

8890
pool_user = common.get_registered_pool_user(
89-
name_template=temp_template,
91+
name_template=name_template,
9092
cluster_manager=cluster_manager,
9193
cluster_obj=cluster_obj,
9294
)
@@ -95,23 +97,34 @@ def update_cost_model(
9597
)
9698
conway_common.update_cost_model(
9799
cluster_obj=cluster_obj,
98-
name_template=temp_template,
100+
name_template=name_template,
99101
governance_data=governance_data,
100102
cost_proposal_file=cost_proposal_file,
101103
pool_user=pool_user,
102104
)
103105

104106

105107
def run_scenario(
108+
cluster_manager: cluster_management.ClusterManager,
106109
cluster_obj: clusterlib.ClusterLib,
107110
temp_template: str,
108-
payment_addrs: list[clusterlib.AddressRecord],
109111
plutus_v_record: plutus_common.PlutusScriptData,
110112
outcome: Outcomes,
111113
is_cost_model_ok: bool,
112114
is_prot_version_ok: bool,
113115
):
114116
"""Run an e2e test for a Plutus builtin."""
117+
payment_addrs = common.get_payment_addrs(
118+
name_template=temp_template,
119+
cluster_manager=cluster_manager,
120+
cluster_obj=cluster_obj,
121+
num=2,
122+
fund_idx=[0],
123+
caching_key="plutusv3_builtins_batch_testing",
124+
amount=1_000_000_000,
125+
min_amount=300_000_000,
126+
)
127+
115128
payment_addr = payment_addrs[0]
116129
issuer_addr = payment_addrs[1]
117130

@@ -207,17 +220,6 @@ def run_plutusv3_builtins_test(
207220
subtests: pytest_subtests.SubTests,
208221
):
209222
"""Run minting tests with the tested Plutus Core built-in functions."""
210-
payment_addrs = common.get_payment_addrs(
211-
name_template=temp_template,
212-
cluster_manager=cluster_manager,
213-
cluster_obj=cluster_obj,
214-
num=2,
215-
fund_idx=[0],
216-
caching_key="plutusv3_builtins_batch_testing",
217-
amount=1400_000_000,
218-
min_amount=600_000_000,
219-
)
220-
221223
cases = (
222224
(success_scripts, Outcomes.SUCCESS),
223225
(fail_scripts, Outcomes.ERROR),
@@ -229,9 +231,9 @@ def run_plutusv3_builtins_test(
229231
script_stem = script.script_file.stem
230232
with subtests.test(variant=f"{variant}_{script_stem}"):
231233
run_scenario(
234+
cluster_manager=cluster_manager,
232235
cluster_obj=cluster_obj,
233236
temp_template=f"{temp_template}_{script_stem}",
234-
payment_addrs=payment_addrs,
235237
plutus_v_record=script,
236238
outcome=outcome,
237239
is_cost_model_ok=is_cost_model_ok,

0 commit comments

Comments
 (0)