Skip to content

Commit

Permalink
Merge pull request #2000 from input-output-hk/TestMinting_add_submit_api
Browse files Browse the repository at this point in the history
Add submit-api testing to `TestMinting`
  • Loading branch information
mkoura authored Oct 12, 2023
2 parents d513f3d + 896a281 commit ed41398
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions cardano_node_tests/tests/test_native_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from cardano_node_tests.utils import dbsync_utils
from cardano_node_tests.utils import helpers
from cardano_node_tests.utils import logfiles
from cardano_node_tests.utils import submit_api
from cardano_node_tests.utils import submit_utils
from cardano_node_tests.utils import tx_view
from cardano_node_tests.utils.versions import VERSIONS
Expand Down Expand Up @@ -547,6 +548,7 @@ def test_minting_burning_diff_tokens_single_tx(
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_out_burn2)

@allure.link(helpers.get_vcs_link())
@submit_utils.PARAM_SUBMIT_METHOD
@common.PARAM_USE_BUILD_CMD
@pytest.mark.smoke
@pytest.mark.dbsync
Expand All @@ -555,6 +557,7 @@ def test_minting_burning_same_token_single_tx(
cluster: clusterlib.ClusterLib,
issuers_addrs: tp.List[clusterlib.AddressRecord],
use_build_cmd: bool,
submit_method: str,
):
"""Test minting one token and burning the same token in single transaction.
Expand Down Expand Up @@ -647,7 +650,12 @@ def test_minting_burning_same_token_single_tx(
)

# submit signed transaction
cluster.g_transaction.submit_tx(tx_file=out_file_signed, txins=tx_output.txins)
submit_utils.submit_tx(
submit_method=submit_method,
cluster_obj=cluster,
tx_file=out_file_signed,
txins=tx_output.txins,
)

token_utxo = cluster.g_query.get_utxo(tx_raw_output=tx_output, coins=[token])
assert token_utxo and token_utxo[0].amount == 1, "The token was not minted"
Expand All @@ -660,6 +668,7 @@ def test_minting_burning_same_token_single_tx(
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output)

@allure.link(helpers.get_vcs_link())
@submit_utils.PARAM_SUBMIT_METHOD
@common.PARAM_USE_BUILD_CMD
@pytest.mark.parametrize(
"tokens_db",
Expand All @@ -684,6 +693,7 @@ def test_bundle_minting_and_burning_witnesses(
multisig_script_policyid: tp.Tuple[pl.Path, str],
tokens_db: tp.Tuple[int, int, int],
use_build_cmd: bool,
submit_method: str,
):
"""Test minting and burning multiple different tokens that are in single bundle.
Expand Down Expand Up @@ -727,6 +737,7 @@ def _mint_tokens() -> clusterlib.TxRawOutput:
cluster_obj=cluster,
new_tokens=tokens_to_mint,
temp_template=f"{temp_template}_mint",
submit_method=submit_method,
use_build_cmd=use_build_cmd,
)

Expand All @@ -740,7 +751,7 @@ def _mint_tokens() -> clusterlib.TxRawOutput:
try:
# Disable logging of "Not enough funds to make the transaction"
logging.disable(logging.ERROR)
with pytest.raises(clusterlib.CLIError) as excinfo:
with pytest.raises((clusterlib.CLIError, submit_api.SubmitApiError)) as excinfo:
_mint_tokens()
err_msg = str(excinfo.value)
assert (
Expand Down Expand Up @@ -778,6 +789,7 @@ def _mint_tokens() -> clusterlib.TxRawOutput:
cluster_obj=cluster,
new_tokens=tokens_to_burn,
temp_template=f"{temp_template}_burn",
submit_method=submit_method,
use_build_cmd=use_build_cmd,
)

Expand All @@ -802,6 +814,7 @@ def _mint_tokens() -> clusterlib.TxRawOutput:
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_out_burn)

@allure.link(helpers.get_vcs_link())
@submit_utils.PARAM_SUBMIT_METHOD
@common.PARAM_USE_BUILD_CMD
@pytest.mark.parametrize(
"tokens_db",
Expand All @@ -826,6 +839,7 @@ def test_bundle_minting_and_burning_sign(
simple_script_policyid: tp.Tuple[pl.Path, str],
tokens_db: tp.Tuple[int, int, int],
use_build_cmd: bool,
submit_method: str,
):
"""Test minting and burning multiple different tokens that are in single bundle.
Expand Down Expand Up @@ -870,6 +884,7 @@ def _mint_tokens() -> clusterlib.TxRawOutput:
cluster_obj=cluster,
new_tokens=tokens_to_mint,
temp_template=f"{temp_template}_mint",
submit_method=submit_method,
use_build_cmd=use_build_cmd,
)

Expand All @@ -883,7 +898,7 @@ def _mint_tokens() -> clusterlib.TxRawOutput:
try:
# Disable logging of "Not enough funds to make the transaction"
logging.disable(logging.ERROR)
with pytest.raises(clusterlib.CLIError) as excinfo:
with pytest.raises((clusterlib.CLIError, submit_api.SubmitApiError)) as excinfo:
_mint_tokens()
err_msg = str(excinfo.value)
assert (
Expand Down Expand Up @@ -921,6 +936,7 @@ def _mint_tokens() -> clusterlib.TxRawOutput:
cluster_obj=cluster,
new_tokens=tokens_to_burn,
temp_template=f"{temp_template}_burn",
submit_method=submit_method,
use_build_cmd=use_build_cmd,
)

Expand All @@ -941,6 +957,7 @@ def _mint_tokens() -> clusterlib.TxRawOutput:
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_out_burn)

@allure.link(helpers.get_vcs_link())
@submit_utils.PARAM_SUBMIT_METHOD
@common.PARAM_USE_BUILD_CMD
@pytest.mark.smoke
@pytest.mark.dbsync
Expand All @@ -949,6 +966,7 @@ def test_minting_and_partial_burning(
cluster: clusterlib.ClusterLib,
issuers_addrs: tp.List[clusterlib.AddressRecord],
use_build_cmd: bool,
submit_method: str,
):
"""Test minting and partial burning of tokens.
Expand Down Expand Up @@ -990,6 +1008,7 @@ def test_minting_and_partial_burning(
cluster_obj=cluster,
new_tokens=[token_mint],
temp_template=f"{temp_template}_mint",
submit_method=submit_method,
use_build_cmd=use_build_cmd,
sign_incrementally=True,
)
Expand All @@ -1006,6 +1025,7 @@ def test_minting_and_partial_burning(
cluster_obj=cluster,
new_tokens=[token_burn],
temp_template=f"{temp_template}_burn1",
submit_method=submit_method,
sign_incrementally=True,
)

Expand All @@ -1020,6 +1040,7 @@ def test_minting_and_partial_burning(
cluster_obj=cluster,
new_tokens=[final_burn],
temp_template=f"{temp_template}_burn2",
submit_method=submit_method,
use_build_cmd=use_build_cmd,
sign_incrementally=True,
)
Expand All @@ -1034,6 +1055,7 @@ def test_minting_and_partial_burning(
dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_out_burn2)

@allure.link(helpers.get_vcs_link())
@submit_utils.PARAM_SUBMIT_METHOD
@common.PARAM_USE_BUILD_CMD
@pytest.mark.smoke
@pytest.mark.dbsync
Expand All @@ -1042,6 +1064,7 @@ def test_minting_unicode_asset_name(
cluster: clusterlib.ClusterLib,
issuers_addrs: tp.List[clusterlib.AddressRecord],
use_build_cmd: bool,
submit_method: str,
):
"""Test minting and burning of token with unicode non-ascii chars in its asset name.
Expand Down Expand Up @@ -1085,6 +1108,7 @@ def test_minting_unicode_asset_name(
cluster_obj=cluster,
new_tokens=[token_mint],
temp_template=f"{temp_template}_mint",
submit_method=submit_method,
use_build_cmd=use_build_cmd,
)

Expand All @@ -1099,6 +1123,7 @@ def test_minting_unicode_asset_name(
cluster_obj=cluster,
new_tokens=[token_burn],
temp_template=f"{temp_template}_burn",
submit_method=submit_method,
use_build_cmd=use_build_cmd,
)

Expand Down

0 comments on commit ed41398

Please sign in to comment.