Skip to content

Commit 7a24f89

Browse files
authored
Merge pull request #3154 from IntersectMBO/test_node_upgrade
This PR refactors basics test_node_upgrade.py
2 parents c8c0132 + b448998 commit 7a24f89

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

cardano_node_tests/tests/test_node_upgrade.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def test_hardfork(
258258
cluster_obj=cluster,
259259
name_template=f"{temp_template}_action",
260260
src_address=pool_user_singleton.payment.address,
261-
use_build_cmd=True,
261+
build_method=clusterlib_utils.BuildMethods.BUILD,
262262
tx_files=tx_files_action,
263263
)
264264

@@ -330,7 +330,7 @@ class TestUpgrade:
330330
@pytest.mark.upgrade_step1
331331
@pytest.mark.upgrade_step2
332332
@pytest.mark.upgrade_step3
333-
@common.PARAM_USE_BUILD_CMD
333+
@common.PARAM_BUILD_METHOD_NO_EST
334334
@pytest.mark.parametrize(
335335
"for_step",
336336
(
@@ -354,7 +354,7 @@ def test_prepare_tx(
354354
cluster_manager: cluster_management.ClusterManager,
355355
cluster: clusterlib.ClusterLib,
356356
payment_addrs_disposable: list[clusterlib.AddressRecord],
357-
use_build_cmd: bool,
357+
build_method: str,
358358
for_step: int,
359359
file_type: str,
360360
):
@@ -364,28 +364,23 @@ def test_prepare_tx(
364364
be submitted in next node version and/or next era.
365365
"""
366366
temp_template = common.get_test_id(cluster)
367-
build_str = "build" if use_build_cmd else "build_raw"
367+
build_str = build_method
368368

369369
src_address = payment_addrs_disposable[0].address
370370
dst_address = payment_addrs_disposable[1].address
371371

372372
txouts = [clusterlib.TxOut(address=dst_address, amount=2_000_000)]
373373
tx_files = clusterlib.TxFiles(signing_key_files=[payment_addrs_disposable[0].skey_file])
374374

375-
if use_build_cmd:
375+
if build_method == clusterlib_utils.BuildMethods.BUILD:
376376
tx_raw_output = cluster.g_transaction.build_tx(
377377
src_address=src_address,
378378
tx_name=temp_template,
379379
tx_files=tx_files,
380380
txouts=txouts,
381381
fee_buffer=1_000_000,
382382
)
383-
out_file_signed = cluster.g_transaction.sign_tx(
384-
tx_body_file=tx_raw_output.out_file,
385-
signing_key_files=tx_files.signing_key_files,
386-
tx_name=temp_template,
387-
)
388-
else:
383+
elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW:
389384
fee = cluster.g_transaction.calculate_tx_fee(
390385
src_address=src_address,
391386
tx_name=temp_template,
@@ -399,11 +394,23 @@ def test_prepare_tx(
399394
tx_files=tx_files,
400395
fee=fee,
401396
)
402-
out_file_signed = cluster.g_transaction.sign_tx(
403-
tx_body_file=tx_raw_output.out_file,
404-
signing_key_files=tx_files.signing_key_files,
397+
elif build_method == clusterlib_utils.BuildMethods.BUILD_EST:
398+
tx_raw_output = cluster.g_transaction.build_estimate_tx(
399+
src_address=src_address,
405400
tx_name=temp_template,
401+
txouts=txouts,
402+
tx_files=tx_files,
403+
fee_buffer=1_000_000,
406404
)
405+
else:
406+
msg = f"Unsupported build method: {build_method}"
407+
raise ValueError(msg)
408+
409+
out_file_signed = cluster.g_transaction.sign_tx(
410+
tx_body_file=tx_raw_output.out_file,
411+
signing_key_files=tx_files.signing_key_files,
412+
tx_name=f"{temp_template}_{build_method}_signed",
413+
)
407414

408415
copy_files = [
409416
payment_addrs_disposable[0].skey_file,
@@ -432,7 +439,7 @@ def test_prepare_tx(
432439
@pytest.mark.upgrade_step1
433440
@pytest.mark.upgrade_step2
434441
@pytest.mark.upgrade_step3
435-
@common.PARAM_USE_BUILD_CMD
442+
@common.PARAM_BUILD_METHOD_NO_EST
436443
@pytest.mark.parametrize(
437444
"for_step",
438445
(
@@ -467,14 +474,14 @@ def test_submit_tx(
467474
self,
468475
cluster_manager: cluster_management.ClusterManager,
469476
cluster: clusterlib.ClusterLib,
470-
use_build_cmd: bool,
477+
build_method: str,
471478
for_step: int,
472479
from_step: int,
473480
file_type: str,
474481
):
475482
"""Submit transaction that was created by previous node version and/or in previous era."""
476483
temp_template = common.get_test_id(cluster)
477-
build_str = "build" if use_build_cmd else "build_raw"
484+
build_str = build_method
478485

479486
tx_dir = (
480487
temptools.get_basetemp()

0 commit comments

Comments
 (0)