Skip to content

Commit d0da67b

Browse files
committed
refactor: simplify fund_from_faucet parameter handling
- Updated `fund_from_faucet` to accept only `AddressRecord` objects, removing the need to handle `PoolUser` objects internally. - Adjusted calls to `fund_from_faucet` across multiple test files to explicitly pass `payment` attributes where necessary. - Removed redundant logic for extracting `payment` from `PoolUser` in `fund_from_faucet`. - Improved code readability and reduced potential for misuse.
1 parent 8e01322 commit d0da67b

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

cardano_node_tests/tests/test_delegation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def _get_pool_users(
280280

281281
# Fund payment addresses
282282
clusterlib_utils.fund_from_faucet(
283-
*pool_users,
283+
*[u.payment for u in pool_users],
284284
cluster_obj=cluster,
285285
all_faucets=cluster_manager.cache.addrs_data,
286286
amount=200_000_000,

cardano_node_tests/tests/test_staking_no_rewards.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_no_reward_unmet_pledge1(
157157
# Fund pool owner's addresses so balance keeps higher than pool pledge after fees etc.
158158
# are deducted
159159
clusterlib_utils.fund_from_faucet(
160-
pool_owner,
160+
pool_owner.payment,
161161
cluster_obj=cluster,
162162
all_faucets=cluster_manager.cache.addrs_data,
163163
amount=900_000_000,
@@ -317,7 +317,7 @@ def test_no_reward_unmet_pledge2(
317317

318318
# Fund user address so it has enough funds for fees etc.
319319
clusterlib_utils.fund_from_faucet(
320-
delegation_out.pool_user,
320+
delegation_out.pool_user.payment,
321321
cluster_obj=cluster,
322322
all_faucets=cluster_manager.cache.addrs_data,
323323
amount=900_000_000,
@@ -499,7 +499,7 @@ def test_no_reward_deregistered_stake_addr(
499499
# Fund pool owner's addresses so balance keeps higher than pool pledge after fees etc.
500500
# are deducted
501501
clusterlib_utils.fund_from_faucet(
502-
pool_owner,
502+
pool_owner.payment,
503503
cluster_obj=cluster,
504504
all_faucets=cluster_manager.cache.addrs_data,
505505
amount=900_000_000,
@@ -695,7 +695,7 @@ def test_no_reward_deregistered_reward_addr(
695695
# Fund pool owner's addresses so balance keeps higher than pool pledge after fees etc.
696696
# are deducted
697697
clusterlib_utils.fund_from_faucet(
698-
pool_reward,
698+
pool_reward.payment,
699699
cluster_obj=cluster,
700700
all_faucets=cluster_manager.cache.addrs_data,
701701
amount=900_000_000,
@@ -861,7 +861,7 @@ def test_deregister_reward_addr_retire_pool(
861861
# Fund pool owner's addresses so balance keeps higher than pool pledge after fees etc.
862862
# are deducted
863863
clusterlib_utils.fund_from_faucet(
864-
pool_owner,
864+
pool_owner.payment,
865865
cluster_obj=cluster,
866866
all_faucets=cluster_manager.cache.addrs_data,
867867
amount=900_000_000,

cardano_node_tests/tests/test_staking_rewards.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ def test_reward_addr_delegation( # noqa: C901
663663
# Fund pool owner's addresses so balance keeps higher than pool pledge after fees etc.
664664
# are deducted
665665
clusterlib_utils.fund_from_faucet(
666-
pool_owner,
666+
pool_owner.payment,
667667
cluster_obj=cluster,
668668
all_faucets=cluster_manager.cache.addrs_data,
669669
amount=900_000_000,
@@ -1189,7 +1189,7 @@ def test_2_pools_same_reward_addr( # noqa: C901
11891189
# Fund pool owner's addresses so balance keeps higher than pool pledge after fees etc.
11901190
# are deducted
11911191
clusterlib_utils.fund_from_faucet(
1192-
pool2_owner,
1192+
pool2_owner.payment,
11931193
cluster_obj=cluster,
11941194
all_faucets=cluster_manager.cache.addrs_data,
11951195
amount=900_000_000,

cardano_node_tests/tests/tests_conway/test_drep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@ def _check_records() -> list[blockers.GH]:
19601960
no_of_addr=2,
19611961
)
19621962
clusterlib_utils.fund_from_faucet(
1963-
*drep_users,
1963+
*[d.payment for d in drep_users],
19641964
cluster_obj=cluster,
19651965
faucet_data=cluster_manager.cache.addrs_data["faucet"],
19661966
# Add a lot of funds so no action can be ratified without the new DReps

cardano_node_tests/utils/faucet.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
def fund_from_faucet(
16-
*dst_addrs: clusterlib.AddressRecord | clusterlib.PoolUser,
16+
*dst_addrs: clusterlib.AddressRecord,
1717
cluster_obj: clusterlib.ClusterLib,
1818
faucet_data: dict | None = None,
1919
all_faucets: dict[str, dict] | None = None,
@@ -27,16 +27,12 @@ def fund_from_faucet(
2727
msg = "Either `faucet_data` or `all_faucets` must be provided."
2828
raise AssertionError(msg)
2929

30-
# Get payment AddressRecord out of PoolUser
31-
dst_addr_records: list[clusterlib.AddressRecord] = [
32-
(r.payment if hasattr(r, "payment") else r) for r in dst_addrs
33-
]
3430
if isinstance(amount, int):
35-
amount = [amount] * len(dst_addr_records)
31+
amount = [amount] * len(dst_addrs)
3632

3733
fund_txouts = [
3834
clusterlib.TxOut(address=d.address, amount=a)
39-
for d, a in zip(dst_addr_records, amount)
35+
for d, a in zip(dst_addrs, amount)
4036
if force or cluster_obj.g_query.get_address_balance(d.address) < a
4137
]
4238
if not fund_txouts:

cardano_node_tests/utils/governance_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def create_vote_stake(
109109

110110
# Fund the payment address with some ADA
111111
clusterlib_utils.fund_from_faucet(
112-
*pool_users,
112+
*[u.payment for u in pool_users],
113113
cluster_obj=cluster_obj,
114114
faucet_data=cluster_manager.cache.addrs_data["faucet"],
115115
amount=500_000_000_000,

0 commit comments

Comments
 (0)