1818from cardano_node_tests .utils import cluster_nodes
1919from cardano_node_tests .utils import clusterlib_utils
2020from cardano_node_tests .utils import dbsync_utils
21+ from cardano_node_tests .utils import defragment_utxos
2122from cardano_node_tests .utils import helpers
2223from cardano_node_tests .utils import submit_api
2324from 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