Skip to content

Commit d410873

Browse files
This PR refactors basics test_node_upgrade.py
1 parent e84416f commit d410873

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

cardano_node_tests/tests/test_node_upgrade.py

Lines changed: 36 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,29 @@ 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 = (
368+
"build"
369+
if build_method == clusterlib_utils.BuildMethods.BUILD
370+
else "build_raw"
371+
if build_method == clusterlib_utils.BuildMethods.BUILD_RAW
372+
else "build_estimate"
373+
)
368374

369375
src_address = payment_addrs_disposable[0].address
370376
dst_address = payment_addrs_disposable[1].address
371377

372378
txouts = [clusterlib.TxOut(address=dst_address, amount=2_000_000)]
373379
tx_files = clusterlib.TxFiles(signing_key_files=[payment_addrs_disposable[0].skey_file])
374380

375-
if use_build_cmd:
381+
if build_method == clusterlib_utils.BuildMethods.BUILD:
376382
tx_raw_output = cluster.g_transaction.build_tx(
377383
src_address=src_address,
378384
tx_name=temp_template,
379385
tx_files=tx_files,
380386
txouts=txouts,
381387
fee_buffer=1_000_000,
382388
)
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:
389+
elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW:
389390
fee = cluster.g_transaction.calculate_tx_fee(
390391
src_address=src_address,
391392
tx_name=temp_template,
@@ -399,11 +400,23 @@ def test_prepare_tx(
399400
tx_files=tx_files,
400401
fee=fee,
401402
)
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,
403+
elif build_method == clusterlib_utils.BuildMethods.BUILD_EST:
404+
tx_raw_output = cluster.g_transaction.build_estimate_tx(
405+
src_address=src_address,
405406
tx_name=temp_template,
407+
txouts=txouts,
408+
tx_files=tx_files,
409+
fee_buffer=1_000_000,
406410
)
411+
else:
412+
msg = f"Unsupported build method: {build_method}"
413+
raise ValueError(msg)
414+
415+
out_file_signed = cluster.g_transaction.sign_tx(
416+
tx_body_file=tx_raw_output.out_file,
417+
signing_key_files=tx_files.signing_key_files,
418+
tx_name=temp_template,
419+
)
407420

408421
copy_files = [
409422
payment_addrs_disposable[0].skey_file,
@@ -432,7 +445,7 @@ def test_prepare_tx(
432445
@pytest.mark.upgrade_step1
433446
@pytest.mark.upgrade_step2
434447
@pytest.mark.upgrade_step3
435-
@common.PARAM_USE_BUILD_CMD
448+
@common.PARAM_BUILD_METHOD_NO_EST
436449
@pytest.mark.parametrize(
437450
"for_step",
438451
(
@@ -467,14 +480,20 @@ def test_submit_tx(
467480
self,
468481
cluster_manager: cluster_management.ClusterManager,
469482
cluster: clusterlib.ClusterLib,
470-
use_build_cmd: bool,
483+
build_method: str,
471484
for_step: int,
472485
from_step: int,
473486
file_type: str,
474487
):
475488
"""Submit transaction that was created by previous node version and/or in previous era."""
476489
temp_template = common.get_test_id(cluster)
477-
build_str = "build" if use_build_cmd else "build_raw"
490+
build_str = (
491+
"build"
492+
if build_method == clusterlib_utils.BuildMethods.BUILD
493+
else "build_raw"
494+
if build_method == clusterlib_utils.BuildMethods.BUILD_RAW
495+
else "build_estimate"
496+
)
478497

479498
tx_dir = (
480499
temptools.get_basetemp()

0 commit comments

Comments
 (0)