Skip to content

Commit b386905

Browse files
authored
Merge pull request #3100 from IntersectMBO/add_build_estimate_tests2
feat: add more `build-estimate` tests
2 parents a9e860b + e06d32b commit b386905

File tree

4 files changed

+74
-41
lines changed

4 files changed

+74
-41
lines changed

cardano_node_tests/tests/test_addr_registration.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def test_addr_registration_deregistration(
282282

283283
@allure.link(helpers.get_vcs_link())
284284
@submit_utils.PARAM_SUBMIT_METHOD
285-
@common.PARAM_USE_BUILD_CMD
285+
@common.PARAM_BUILD_METHOD
286286
@pytest.mark.smoke
287287
@pytest.mark.testnets
288288
@pytest.mark.dbsync
@@ -291,8 +291,8 @@ def test_addr_registration_certificate_order(
291291
cluster: clusterlib.ClusterLib,
292292
pool_users: list[clusterlib.PoolUser],
293293
pool_users_disposable: list[clusterlib.PoolUser],
294-
use_build_cmd: bool,
295294
submit_method: str,
295+
build_method: str,
296296
):
297297
"""Submit (de)registration certificates in single TX and check that the order matter.
298298
@@ -347,13 +347,18 @@ def test_addr_registration_certificate_order(
347347
name_template=temp_template,
348348
src_address=user_payment.address,
349349
submit_method=submit_method,
350-
use_build_cmd=use_build_cmd,
350+
build_method=build_method,
351351
tx_files=tx_files,
352352
deposit=deposit,
353353
)
354354
except (clusterlib.CLIError, submit_api.SubmitApiError) as exc:
355355
if "(ValueNotConservedUTxO" in str(exc) and VERSIONS.transaction_era >= VERSIONS.CONWAY:
356356
issues.api_484.finish_test()
357+
if (
358+
build_method == clusterlib_utils.BuildMethods.BUILD_EST
359+
and "does not balance in its use of assets" in str(exc)
360+
):
361+
issues.cli_1199.finish_test()
357362
raise
358363

359364
# Check that the stake address is registered

cardano_node_tests/tests/test_scripts.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -541,15 +541,15 @@ def test_multisig_atleast(
541541

542542
@allure.link(helpers.get_vcs_link())
543543
@submit_utils.PARAM_SUBMIT_METHOD
544-
@common.PARAM_USE_BUILD_CMD
544+
@common.PARAM_BUILD_METHOD
545545
@pytest.mark.smoke
546546
@pytest.mark.dbsync
547547
def test_normal_tx_to_script_addr(
548548
self,
549549
cluster: clusterlib.ClusterLib,
550550
payment_addrs: list[clusterlib.AddressRecord],
551-
use_build_cmd: bool,
552551
submit_method: str,
552+
build_method: str,
553553
):
554554
"""Send funds to script address using TX signed with skeys (not using witness files)."""
555555
temp_template = common.get_test_id(cluster)
@@ -577,7 +577,7 @@ def test_normal_tx_to_script_addr(
577577
name_template=temp_template,
578578
src_address=src_address,
579579
submit_method=submit_method,
580-
use_build_cmd=use_build_cmd,
580+
build_method=build_method,
581581
txouts=txouts,
582582
tx_files=tx_files,
583583
)
@@ -2196,7 +2196,7 @@ def payment_addrs(
21962196

21972197
@allure.link(helpers.get_vcs_link())
21982198
@submit_utils.PARAM_SUBMIT_METHOD
2199-
@common.PARAM_USE_BUILD_CMD
2199+
@common.PARAM_BUILD_METHOD
22002200
@pytest.mark.parametrize("script_version", ("simple_v1", "simple_v2"))
22012201
@pytest.mark.smoke
22022202
@pytest.mark.testnets
@@ -2205,8 +2205,8 @@ def test_script_utxo_datum(
22052205
self,
22062206
cluster: clusterlib.ClusterLib,
22072207
payment_addrs: list[clusterlib.AddressRecord],
2208-
use_build_cmd: bool,
22092208
submit_method: str,
2209+
build_method: str,
22102210
script_version: str,
22112211
):
22122212
"""Test creating UTxO with datum on Simple Scripts V1 and V2 address."""
@@ -2256,7 +2256,7 @@ def test_script_utxo_datum(
22562256
name_template=temp_template,
22572257
src_address=src_addr.address,
22582258
submit_method=submit_method,
2259-
use_build_cmd=use_build_cmd,
2259+
build_method=build_method,
22602260
txouts=txouts,
22612261
tx_files=tx_files,
22622262
)
@@ -2452,7 +2452,7 @@ def test_script_reference_utxo(
24522452

24532453
@allure.link(helpers.get_vcs_link())
24542454
@submit_utils.PARAM_SUBMIT_METHOD
2455-
@common.PARAM_USE_BUILD_CMD
2455+
@common.PARAM_BUILD_METHOD
24562456
@pytest.mark.parametrize("script_version", ("simple_v1", "simple_v2"))
24572457
@pytest.mark.parametrize("address_type", ("shelley", "byron"))
24582458
@pytest.mark.smoke
@@ -2462,8 +2462,8 @@ def test_spend_reference_script(
24622462
self,
24632463
cluster: clusterlib.ClusterLib,
24642464
payment_addrs: list[clusterlib.AddressRecord],
2465-
use_build_cmd: bool,
24662465
submit_method: str,
2466+
build_method: str,
24672467
script_version: str,
24682468
address_type: str,
24692469
):
@@ -2527,12 +2527,12 @@ def test_spend_reference_script(
25272527
name_template=f"{temp_template}_spend",
25282528
src_address=reference_addr.address,
25292529
submit_method=submit_method,
2530-
use_build_cmd=use_build_cmd,
2530+
build_method=build_method,
25312531
txins=[reference_utxo],
25322532
txouts=txouts,
25332533
tx_files=tx_files,
25342534
witness_override=2 if address_type == "byron" else None,
2535-
witness_count_add=0 if use_build_cmd else 2,
2535+
byron_witness_count=1 if address_type == "byron" else 0,
25362536
)
25372537

25382538
# Check that the reference UTxO was spent

cardano_node_tests/tests/test_tx_basic.py

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from cardano_node_tests.utils import cluster_nodes
1919
from cardano_node_tests.utils import clusterlib_utils
2020
from cardano_node_tests.utils import dbsync_utils
21+
from cardano_node_tests.utils import defragment_utxos
2122
from cardano_node_tests.utils import helpers
2223
from cardano_node_tests.utils import submit_api
2324
from cardano_node_tests.utils import submit_utils
@@ -535,16 +536,16 @@ def test_transfer_all_build_estimate(
535536

536537
@allure.link(helpers.get_vcs_link())
537538
@submit_utils.PARAM_SUBMIT_METHOD
538-
@common.PARAM_USE_BUILD_CMD
539+
@common.PARAM_BUILD_METHOD
539540
@pytest.mark.smoke
540541
@pytest.mark.testnets
541542
@pytest.mark.dbsync
542543
def test_funds_to_valid_address(
543544
self,
544545
cluster: clusterlib.ClusterLib,
545546
payment_addrs: list[clusterlib.AddressRecord],
546-
use_build_cmd: bool,
547547
submit_method: str,
548+
build_method: str,
548549
):
549550
"""Send funds to a valid payment address.
550551
@@ -572,7 +573,7 @@ def test_funds_to_valid_address(
572573
name_template=temp_template,
573574
src_address=src_address,
574575
submit_method=submit_method,
575-
use_build_cmd=use_build_cmd,
576+
build_method=build_method,
576577
txouts=txouts,
577578
tx_files=tx_files,
578579
)
@@ -596,16 +597,16 @@ def test_funds_to_valid_address(
596597

597598
@allure.link(helpers.get_vcs_link())
598599
@submit_utils.PARAM_SUBMIT_METHOD
599-
@common.PARAM_USE_BUILD_CMD
600+
@common.PARAM_BUILD_METHOD
600601
@pytest.mark.smoke
601602
@pytest.mark.testnets
602603
@pytest.mark.dbsync
603604
def test_get_txid(
604605
self,
605606
cluster: clusterlib.ClusterLib,
606607
payment_addrs: list[clusterlib.AddressRecord],
607-
use_build_cmd: bool,
608608
submit_method: str,
609+
build_method: str,
609610
):
610611
"""Get transaction ID (txid) from transaction body.
611612
@@ -631,7 +632,7 @@ def test_get_txid(
631632
name_template=temp_template,
632633
src_address=src_address,
633634
submit_method=submit_method,
634-
use_build_cmd=use_build_cmd,
635+
build_method=build_method,
635636
txouts=txouts,
636637
tx_files=tx_files,
637638
)
@@ -1239,7 +1240,7 @@ def test_far_future_ttl(
12391240
@allure.link(helpers.get_vcs_link())
12401241
@common.SKIPIF_WRONG_ERA
12411242
@submit_utils.PARAM_SUBMIT_METHOD
1242-
@common.PARAM_USE_BUILD_CMD
1243+
@common.PARAM_BUILD_METHOD
12431244
@pytest.mark.parametrize(
12441245
"cluster_default_tx_era",
12451246
(True, False),
@@ -1253,8 +1254,8 @@ def test_default_tx_era(
12531254
cluster: clusterlib.ClusterLib,
12541255
cluster_default_tx_era: clusterlib.ClusterLib,
12551256
payment_addrs: list[clusterlib.AddressRecord],
1256-
use_build_cmd: bool,
12571257
submit_method: str,
1258+
build_method: str,
12581259
):
12591260
"""Test default Tx era.
12601261
@@ -1276,7 +1277,7 @@ def test_default_tx_era(
12761277
name_template=temp_template,
12771278
src_address=src_address,
12781279
submit_method=submit_method,
1279-
use_build_cmd=use_build_cmd,
1280+
build_method=build_method,
12801281
txouts=txouts,
12811282
tx_files=tx_files,
12821283
)
@@ -1315,9 +1316,12 @@ def _from_to_transactions(
13151316
to_num: int,
13161317
amount: int,
13171318
submit_method: str,
1318-
use_build_cmd=False,
1319+
build_method: str,
13191320
):
1320-
"""Test 1 tx from `from_num` payment addresses to `to_num` payment addresses."""
1321+
"""Test 1 tx from `from_num` payment addresses to `to_num` payment addresses.
1322+
1323+
Defragment UTxOs to avoid exceeding transaction size limit.
1324+
"""
13211325
src_address = payment_addrs[0].address
13221326
# Addr1..addr<from_num+1>
13231327
from_addr_recs = payment_addrs[1 : from_num + 1]
@@ -1326,6 +1330,14 @@ def _from_to_transactions(
13261330
payment_addrs[i].address for i in range(from_num + 1, from_num + to_num + 1)
13271331
]
13281332

1333+
defragment_utxos.defragment(
1334+
cluster_obj=cluster_obj,
1335+
address=src_address,
1336+
skey_file=payment_addrs[0].skey_file,
1337+
max_len=100,
1338+
name_template=f"{tx_name}_add_funds",
1339+
)
1340+
13291341
# Fund "from" addresses
13301342
# Using `src_address` to fund the "from" addresses. In `build_and_submit_tx`, all remaining
13311343
# change is returned to `src_address`, so it should always have enough funds.
@@ -1348,11 +1360,20 @@ def _from_to_transactions(
13481360
name_template=f"{tx_name}_add_funds",
13491361
src_address=src_address,
13501362
submit_method=submit_method,
1351-
use_build_cmd=use_build_cmd,
1363+
build_method=build_method,
13521364
txouts=fund_dst,
13531365
tx_files=fund_tx_files,
13541366
)
13551367

1368+
for i, r in enumerate(from_addr_recs):
1369+
defragment_utxos.defragment(
1370+
cluster_obj=cluster_obj,
1371+
address=r.address,
1372+
skey_file=r.skey_file,
1373+
max_len=5,
1374+
name_template=f"{tx_name}_{i}",
1375+
)
1376+
13561377
# Create TX data
13571378
_txins = [cluster_obj.g_query.get_utxo(address=r.address) for r in from_addr_recs]
13581379
# Flatten the list of lists that is _txins
@@ -1366,7 +1387,7 @@ def _from_to_transactions(
13661387
name_template=tx_name,
13671388
src_address=src_address,
13681389
submit_method=submit_method,
1369-
use_build_cmd=use_build_cmd,
1390+
build_method=build_method,
13701391
txins=txins,
13711392
txouts=txouts,
13721393
tx_files=tx_files,
@@ -1446,8 +1467,8 @@ def test_10_transactions(
14461467
), f"Incorrect balance for destination address `{dst_address}`"
14471468

14481469
@allure.link(helpers.get_vcs_link())
1449-
@common.PARAM_USE_BUILD_CMD
14501470
@submit_utils.PARAM_SUBMIT_METHOD
1471+
@common.PARAM_BUILD_METHOD
14511472
@pytest.mark.parametrize("amount", (1_500_000, 2_000_000, 10_000_000))
14521473
@pytest.mark.smoke
14531474
@pytest.mark.testnets
@@ -1457,8 +1478,8 @@ def test_transaction_to_10_addrs_from_1_addr(
14571478
cluster: clusterlib.ClusterLib,
14581479
payment_addrs: list[clusterlib.AddressRecord],
14591480
amount: int,
1460-
use_build_cmd: bool,
14611481
submit_method: str,
1482+
build_method: str,
14621483
):
14631484
"""Test 1 transaction from 1 payment address to 10 payment addresses.
14641485
@@ -1474,12 +1495,12 @@ def test_transaction_to_10_addrs_from_1_addr(
14741495
to_num=10,
14751496
amount=amount,
14761497
submit_method=submit_method,
1477-
use_build_cmd=use_build_cmd,
1498+
build_method=build_method,
14781499
)
14791500

14801501
@allure.link(helpers.get_vcs_link())
1481-
@common.PARAM_USE_BUILD_CMD
14821502
@submit_utils.PARAM_SUBMIT_METHOD
1503+
@common.PARAM_BUILD_METHOD
14831504
@pytest.mark.parametrize("amount", (1_500_000, 2_000_000, 10_000_000))
14841505
@pytest.mark.smoke
14851506
@pytest.mark.testnets
@@ -1489,8 +1510,8 @@ def test_transaction_to_1_addr_from_10_addrs(
14891510
cluster: clusterlib.ClusterLib,
14901511
payment_addrs: list[clusterlib.AddressRecord],
14911512
amount: int,
1492-
use_build_cmd: bool,
14931513
submit_method: str,
1514+
build_method: str,
14941515
):
14951516
"""Test 1 transaction from 10 payment addresses to 1 payment address.
14961517
@@ -1506,12 +1527,12 @@ def test_transaction_to_1_addr_from_10_addrs(
15061527
to_num=1,
15071528
amount=amount,
15081529
submit_method=submit_method,
1509-
use_build_cmd=use_build_cmd,
1530+
build_method=build_method,
15101531
)
15111532

15121533
@allure.link(helpers.get_vcs_link())
1513-
@common.PARAM_USE_BUILD_CMD
15141534
@submit_utils.PARAM_SUBMIT_METHOD
1535+
@common.PARAM_BUILD_METHOD
15151536
@pytest.mark.parametrize("amount", (1_500_000, 2_000_000, 10_000_000))
15161537
@pytest.mark.smoke
15171538
@pytest.mark.testnets
@@ -1521,8 +1542,8 @@ def test_transaction_to_10_addrs_from_10_addrs(
15211542
cluster: clusterlib.ClusterLib,
15221543
payment_addrs: list[clusterlib.AddressRecord],
15231544
amount: int,
1524-
use_build_cmd: bool,
15251545
submit_method: str,
1546+
build_method: str,
15261547
):
15271548
"""Test 1 transaction from 10 payment addresses to 10 payment addresses.
15281549
@@ -1538,12 +1559,12 @@ def test_transaction_to_10_addrs_from_10_addrs(
15381559
to_num=10,
15391560
amount=amount,
15401561
submit_method=submit_method,
1541-
use_build_cmd=use_build_cmd,
1562+
build_method=build_method,
15421563
)
15431564

15441565
@allure.link(helpers.get_vcs_link())
1545-
@common.PARAM_USE_BUILD_CMD
15461566
@submit_utils.PARAM_SUBMIT_METHOD
1567+
@common.PARAM_BUILD_METHOD
15471568
@pytest.mark.parametrize("amount", (1_500_000, 2_000_000, 5_000_000))
15481569
@pytest.mark.smoke
15491570
@pytest.mark.testnets
@@ -1553,8 +1574,8 @@ def test_transaction_to_100_addrs_from_50_addrs(
15531574
cluster: clusterlib.ClusterLib,
15541575
payment_addrs: list[clusterlib.AddressRecord],
15551576
amount: int,
1556-
use_build_cmd: bool,
15571577
submit_method: str,
1578+
build_method: str,
15581579
):
15591580
"""Test 1 transaction from 50 payment addresses to 100 payment addresses.
15601581
@@ -1570,7 +1591,7 @@ def test_transaction_to_100_addrs_from_50_addrs(
15701591
to_num=100,
15711592
amount=amount,
15721593
submit_method=submit_method,
1573-
use_build_cmd=use_build_cmd,
1594+
build_method=build_method,
15741595
)
15751596

15761597

0 commit comments

Comments
 (0)