Skip to content

Commit

Permalink
update tests to work with multiasset autobalance
Browse files Browse the repository at this point in the history
  • Loading branch information
saratomaz authored and mkoura committed Apr 4, 2023
1 parent 749c9e3 commit aa9274d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cardano_node_tests/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest
from cardano_clusterlib import clusterlib
from packaging import version

from cardano_node_tests.cluster_management import cluster_management
from cardano_node_tests.utils import cluster_nodes
Expand Down Expand Up @@ -61,6 +62,9 @@
)


SKIP_ASSET_BALANCING = VERSIONS.node >= version.parse("1.36.0")


# common parametrization
PARAM_USE_BUILD_CMD = pytest.mark.parametrize(
"use_build_cmd",
Expand Down
8 changes: 7 additions & 1 deletion cardano_node_tests/tests/test_native_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,7 @@ def test_transfer_tokens(
txouts=destinations,
fee_buffer=2_000_000,
tx_files=tx_files,
skip_asset_balancing=common.SKIP_ASSET_BALANCING,
)
except clusterlib.CLIError as err:
err_str = str(err)
Expand Down Expand Up @@ -1785,6 +1786,7 @@ def test_transfer_multiple_tokens(
txouts=destinations,
fee_buffer=2_000_000,
tx_files=tx_files,
skip_asset_balancing=common.SKIP_ASSET_BALANCING,
)
tx_signed = cluster.g_transaction.sign_tx(
tx_body_file=tx_raw_output.out_file,
Expand Down Expand Up @@ -1945,7 +1947,11 @@ def test_transfer_invalid_token_amount(
logging.disable(logging.NOTSET)

exc_val = str(excinfo.value)
assert "Non-Ada assets are unbalanced" in exc_val, exc_val
assert (
"Non-Ada assets are unbalanced" in exc_val
or f"Negative quantity ({self.NEW_TOKENS_NUM - token_amount}) in transaction output"
in exc_val
), exc_val
else:
with pytest.raises(clusterlib.CLIError) as excinfo:
try:
Expand Down
7 changes: 3 additions & 4 deletions cardano_node_tests/utils/dbsync_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,10 +849,9 @@ def check_tx(
# was used (change txout, fee in older node versions), so we'll skip some of the checks
if tx_raw_output.change_address:
assert tx_txouts.issubset(db_txouts), f"TX outputs not subset: ({tx_txouts} vs {db_txouts})"
assert len_db_txouts in (
len_out_txouts, # when there's no change txout
len_out_txouts + 1, # when there's a change txout
), f"Number of TX outputs doesn't match ({len_db_txouts} != {len_out_txouts} (+1))"
assert (
len_db_txouts >= len_out_txouts
), f"Number of TX outputs doesn't match ({len_db_txouts} < {len_out_txouts})"
else:
txouts_amount = clusterlib.calculate_utxos_balance(utxos=tx_raw_output.txouts)
assert (
Expand Down

0 comments on commit aa9274d

Please sign in to comment.