Skip to content

Commit 9df7d73

Browse files
authored
Merge pull request #2798 from IntersectMBO/testnet_drep_funds
feat: don't cache fixture when deposit too high
2 parents 67e4b99 + 243c4bd commit 9df7d73

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

cardano_node_tests/tests/tests_conway/test_drep.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
LOGGER = logging.getLogger(__name__)
3737
DATA_DIR = pl.Path(__file__).parent.parent / "data"
3838

39+
MAINNET_DREP_DEPOSIT = 500_000_000
40+
3941
pytestmark = pytest.mark.skipif(
4042
VERSIONS.transaction_era < VERSIONS.CONWAY,
4143
reason="runs only with Tx era >= Conway",
@@ -59,19 +61,27 @@ def get_payment_addr(
5961
name_template: str,
6062
cluster_manager: cluster_management.ClusterManager,
6163
cluster_obj: clusterlib.ClusterLib,
62-
caching_key: str,
64+
caching_key: str = "",
6365
amount: tp.Optional[int] = None,
6466
) -> clusterlib.AddressRecord:
6567
"""Create new payment address."""
66-
with cluster_manager.cache_fixture(key=caching_key) as fixture_cache:
67-
if fixture_cache.value:
68-
return fixture_cache.value # type: ignore
6968

69+
def _create_addr() -> clusterlib.AddressRecord:
7070
addr = clusterlib_utils.create_payment_addr_records(
71-
f"drep_addr_{name_template}",
71+
f"{name_template}_fund_addr",
7272
cluster_obj=cluster_obj,
7373
)[0]
74-
fixture_cache.value = addr
74+
return addr
75+
76+
if caching_key:
77+
with cluster_manager.cache_fixture(key=caching_key) as fixture_cache:
78+
if fixture_cache.value:
79+
return fixture_cache.value # type: ignore
80+
81+
addr = _create_addr()
82+
fixture_cache.value = addr
83+
else:
84+
addr = _create_addr()
7585

7686
# Fund source address
7787
clusterlib_utils.fund_from_faucet(
@@ -186,14 +196,23 @@ def payment_addr(
186196
cluster_manager: cluster_management.ClusterManager,
187197
cluster: clusterlib.ClusterLib,
188198
) -> clusterlib.AddressRecord:
199+
if cluster.conway_genesis["dRepDeposit"] < MAINNET_DREP_DEPOSIT:
200+
amount = 1_000_000_000
201+
key = helpers.get_current_line_str()
202+
else:
203+
amount = MAINNET_DREP_DEPOSIT + 10_000_000
204+
# Don't cache the fixture when DRep deposit is high. We don't know on how many
205+
# different workers the tests will run, and we might end up creating many addresses
206+
# with lot of funds if the fixture is cached.
207+
key = ""
208+
189209
test_id = common.get_test_id(cluster)
190-
key = helpers.get_current_line_str()
191210
return get_payment_addr(
192211
name_template=test_id,
193212
cluster_manager=cluster_manager,
194213
cluster_obj=cluster,
195214
caching_key=key,
196-
amount=2000_000_000,
215+
amount=amount,
197216
)
198217

199218

0 commit comments

Comments
 (0)