Skip to content

Commit

Permalink
Test using 'build --tx-out-datum-embed' without provide protocol para…
Browse files Browse the repository at this point in the history
…ms (#1510)

* Test using 'build --tx-out-datum-embed' without provide protocol params

* Lock as little fund as possible

Also make it more likely that there's enough funds in txin

The test is not supposed to fail, so it doesn't belong to negative tests group.

Co-authored-by: Martin Kourim <martin.kourim@iohk.io>
  • Loading branch information
saratomaz and mkoura committed Nov 29, 2022
1 parent 32fb0b3 commit ca29f8d
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions cardano_node_tests/tests/test_plutus_spend_build.py
Expand Up @@ -14,6 +14,7 @@
import pytest
from _pytest.fixtures import FixtureRequest
from cardano_clusterlib import clusterlib
from cardano_clusterlib import txtools

from cardano_node_tests.cluster_management import cluster_management
from cardano_node_tests.tests import common
Expand Down Expand Up @@ -1435,6 +1436,67 @@ def test_datum_on_key_credential_address(

dbsync_utils.check_tx(cluster_obj=cluster, tx_raw_output=tx_output)

@allure.link(helpers.get_vcs_link())
@common.PARAM_PLUTUS_VERSION
def test_embed_datum_without_pparams(
self,
cluster: clusterlib.ClusterLib,
payment_addrs: List[clusterlib.AddressRecord],
plutus_version: str,
):
"""Test 'build --tx-out-datum-embed' without providing protocol params file."""
__: Any # mypy workaround
temp_template = f"{common.get_test_id(cluster)}_{plutus_version}"

plutus_op = plutus_common.PlutusOp(
script_file=plutus_common.ALWAYS_SUCCEEDS[plutus_version].script_file,
datum_file=plutus_common.DATUM_42_TYPED,
)

script_address = cluster.g_address.gen_payment_addr(
addr_name=temp_template, payment_script_file=plutus_op.script_file
)

tx_files = clusterlib.TxFiles(signing_key_files=[payment_addrs[0].skey_file])

utxos = cluster.g_query.get_utxo(address=payment_addrs[0].address)
txin = txtools.filter_utxo_with_highest_amount(utxos=utxos)

out_file = f"{temp_template}_tx.body"

cli_args = [
"transaction",
"build",
"--tx-in",
f"{txin.utxo_hash}#{txin.utxo_ix}",
"--tx-out",
f"{script_address}+2000000",
"--tx-out-datum-embed-file",
str(plutus_op.datum_file),
"--change-address",
payment_addrs[0].address,
"--out-file",
out_file,
"--testnet-magic",
str(cluster.network_magic),
*cluster.g_transaction.tx_era_arg,
]

cluster.cli(cli_args)

tx_signed = cluster.g_transaction.sign_tx(
tx_body_file=out_file,
signing_key_files=tx_files.signing_key_files,
tx_name=f"{temp_template}_signed",
)

try:
cluster.g_transaction.submit_tx(tx_file=tx_signed, txins=[txin])
except clusterlib.CLIError as err:
if "PPViewHashesDontMatch" in str(err):
pytest.xfail("build cmd requires protocol params - see node issue #4058")
raise


@common.SKIPIF_PLUTUS_UNUSABLE
@pytest.mark.testnets
Expand Down

0 comments on commit ca29f8d

Please sign in to comment.