Skip to content

Commit 1fd3323

Browse files
This PR refactors test_scripts.py..
1 parent f323fee commit 1fd3323

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

cardano_node_tests/tests/test_scripts.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,15 +1798,15 @@ def payment_addrs(
17981798

17991799
@allure.link(helpers.get_vcs_link())
18001800
@submit_utils.PARAM_SUBMIT_METHOD
1801-
@common.PARAM_USE_BUILD_CMD
1801+
@common.PARAM_BUILD_METHOD_NO_EST
18021802
@pytest.mark.smoke
18031803
@pytest.mark.testnets
18041804
@pytest.mark.dbsync
18051805
def test_tx_script_metadata_json(
18061806
self,
18071807
cluster: clusterlib.ClusterLib,
18081808
payment_addrs: list[clusterlib.AddressRecord],
1809-
use_build_cmd: bool,
1809+
build_method: str,
18101810
submit_method: str,
18111811
):
18121812
"""Send transaction with auxiliary script and metadata JSON.
@@ -1837,7 +1837,7 @@ def test_tx_script_metadata_json(
18371837
name_template=temp_template,
18381838
src_address=payment_addrs[0].address,
18391839
submit_method=submit_method,
1840-
use_build_cmd=use_build_cmd,
1840+
build_method=build_method,
18411841
tx_files=tx_files,
18421842
)
18431843

@@ -1855,15 +1855,15 @@ def test_tx_script_metadata_json(
18551855

18561856
@allure.link(helpers.get_vcs_link())
18571857
@submit_utils.PARAM_SUBMIT_METHOD
1858-
@common.PARAM_USE_BUILD_CMD
1858+
@common.PARAM_BUILD_METHOD_NO_EST
18591859
@pytest.mark.smoke
18601860
@pytest.mark.testnets
18611861
@pytest.mark.dbsync
18621862
def test_tx_script_metadata_cbor(
18631863
self,
18641864
cluster: clusterlib.ClusterLib,
18651865
payment_addrs: list[clusterlib.AddressRecord],
1866-
use_build_cmd: bool,
1866+
build_method: str,
18671867
submit_method: str,
18681868
):
18691869
"""Send transaction with auxiliary script and metadata CBOR.
@@ -1895,7 +1895,7 @@ def test_tx_script_metadata_cbor(
18951895
name_template=temp_template,
18961896
src_address=payment_addrs[0].address,
18971897
submit_method=submit_method,
1898-
use_build_cmd=use_build_cmd,
1898+
build_method=build_method,
18991899
tx_files=tx_files,
19001900
)
19011901

@@ -1913,15 +1913,15 @@ def test_tx_script_metadata_cbor(
19131913

19141914
@allure.link(helpers.get_vcs_link())
19151915
@submit_utils.PARAM_SUBMIT_METHOD
1916-
@common.PARAM_USE_BUILD_CMD
1916+
@common.PARAM_BUILD_METHOD_NO_EST
19171917
@pytest.mark.smoke
19181918
@pytest.mark.testnets
19191919
@pytest.mark.dbsync
19201920
def test_tx_script_no_metadata(
19211921
self,
19221922
cluster: clusterlib.ClusterLib,
19231923
payment_addrs: list[clusterlib.AddressRecord],
1924-
use_build_cmd: bool,
1924+
build_method: str,
19251925
submit_method: str,
19261926
):
19271927
"""Send transaction with auxiliary script and no other metadata.
@@ -1949,7 +1949,7 @@ def test_tx_script_no_metadata(
19491949
name_template=temp_template,
19501950
src_address=payment_addrs[0].address,
19511951
submit_method=submit_method,
1952-
use_build_cmd=use_build_cmd,
1952+
build_method=build_method,
19531953
tx_files=tx_files,
19541954
)
19551955

@@ -1961,14 +1961,14 @@ def test_tx_script_no_metadata(
19611961
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output)
19621962

19631963
@allure.link(helpers.get_vcs_link())
1964-
@common.PARAM_USE_BUILD_CMD
1964+
@common.PARAM_BUILD_METHOD_NO_EST
19651965
@pytest.mark.smoke
19661966
@pytest.mark.testnets
19671967
def test_tx_script_invalid(
19681968
self,
19691969
cluster: clusterlib.ClusterLib,
19701970
payment_addrs: list[clusterlib.AddressRecord],
1971-
use_build_cmd: bool,
1971+
build_method: str,
19721972
):
19731973
"""Build transaction with invalid auxiliary script.
19741974
@@ -1983,17 +1983,30 @@ def test_tx_script_invalid(
19831983
)
19841984

19851985
with pytest.raises(clusterlib.CLIError) as excinfo:
1986-
if use_build_cmd:
1986+
if build_method == clusterlib_utils.BuildMethods.BUILD:
19871987
cluster.g_transaction.build_tx(
19881988
src_address=payment_addrs[0].address,
19891989
tx_name=temp_template,
19901990
fee_buffer=2_000_000,
19911991
tx_files=tx_files,
19921992
)
1993-
else:
1993+
elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW:
19941994
cluster.g_transaction.build_raw_tx(
1995-
src_address=payment_addrs[0].address, tx_name=temp_template, tx_files=tx_files
1995+
src_address=payment_addrs[0].address,
1996+
tx_name=temp_template,
1997+
tx_files=tx_files,
1998+
fee=0,
1999+
)
2000+
elif build_method == clusterlib_utils.BuildMethods.BUILD_EST:
2001+
cluster.g_transaction.build_estimate_tx(
2002+
src_address=payment_addrs[0].address,
2003+
tx_name=temp_template,
2004+
tx_files=tx_files,
2005+
fee_buffer=2_000_000,
19962006
)
2007+
else:
2008+
msg = f"Unsupported build method: {build_method}"
2009+
raise ValueError(msg)
19972010
err_str = str(excinfo.value)
19982011
assert 'Error in $: key "type" not found' in err_str, err_str
19992012

0 commit comments

Comments
 (0)