Skip to content

Commit 9da4ee2

Browse files
cleaner way
2 parents 50a2738 + f3cf774 commit 9da4ee2

18 files changed

+219
-76
lines changed

cardano_node_tests/tests/issues.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@
191191
fixed_in="10.1.3.0", # Unknown yet, will be fixed/changed sometime in the future
192192
message="Delegation to DRep2 removed after retirement of DRep1.",
193193
)
194+
ledger_5365 = blockers.GH(
195+
issue=5365,
196+
repo="IntersectMBO/cardano-ledger",
197+
fixed_in="10.6.0.0",
198+
message="queryPoolState returns current pool params instead of the future ones.",
199+
)
194200

195201
node_3788 = blockers.GH(
196202
issue=3788,

cardano_node_tests/tests/test_chain_transactions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@ def _repeat_submit(cluster_obj: clusterlib.ClusterLib, tx_file: pl.Path) -> str:
7575
cluster_obj.g_transaction.submit_tx_bare(tx_file=tx_file)
7676
except clusterlib.CLIError as exc:
7777
exc_str = str(exc)
78-
if r == 0 and "(BadInputsUTxO" in exc_str:
78+
inputs_spent = (
79+
'(ConwayMempoolFailure "All inputs are spent.'
80+
in exc_str # In cardano-node >= 10.6.0
81+
or "(BadInputsUTxO" in exc_str
82+
)
83+
if r == 0 and inputs_spent:
7984
err_str = "Tx input is missing, maybe temporary fork happened?"
80-
elif "(BadInputsUTxO" in exc_str:
85+
elif inputs_spent:
8186
break
8287
raise
8388
if r > 2:

cardano_node_tests/tests/test_pool_saturation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ def _get_saturation_threshold(
5252
cluster_obj: clusterlib.ClusterLib, ledger_state: dict, pool_id: str
5353
) -> int:
5454
"""Calculate how much Lovelace is needed to reach saturation threshold."""
55-
account_state = ledger_state["stateBefore"]["esAccountState"]
55+
account_state = clusterlib_utils.get_chain_account_state(ledger_state=ledger_state)
5656
active_supply = (
57-
cluster_obj.genesis["maxLovelaceSupply"]
58-
- account_state["reserves"]
59-
- account_state["treasury"]
57+
cluster_obj.genesis["maxLovelaceSupply"] - account_state.reserves - account_state.treasury
6058
)
6159
k_param = cluster_obj.g_query.get_protocol_params()["stakePoolTargetNum"]
6260
saturation_amount = int(active_supply / k_param)

cardano_node_tests/tests/test_pools.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from cardano_node_tests.cluster_management import cluster_management
2525
from cardano_node_tests.tests import common
26+
from cardano_node_tests.tests import issues
2627
from cardano_node_tests.utils import cluster_nodes
2728
from cardano_node_tests.utils import clusterlib_utils
2829
from cardano_node_tests.utils import configuration
@@ -117,7 +118,8 @@ def _check_staking(
117118

118119
assert (
119120
# Strip 'e0' from the beginning of the address hash
120-
helpers.decode_bech32(stake_addr_info.address)[2:] in pool_params["owners"]
121+
helpers.decode_bech32(stake_addr_info.address)[2:]
122+
in helpers.get_pool_param("owners", pool_params=pool_params)
121123
), "'owner' value is different than expected"
122124

123125

@@ -1465,12 +1467,12 @@ def test_update_stake_pool_metadata(
14651467
raise ValueError(msg)
14661468

14671469
# Check that pool is going to be updated with correct data
1468-
future_params = cluster.g_query.get_pool_state(
1469-
stake_pool_id=pool_creation_out.stake_pool_id
1470-
).future_pool_params
1471-
assert not clusterlib_utils.check_pool_data(
1472-
pool_params=future_params, pool_creation_data=pool_data_updated
1473-
)
1470+
pool_state = cluster.g_query.get_pool_state(stake_pool_id=pool_creation_out.stake_pool_id)
1471+
has_issue_5365 = pool_state.future_pool_params == pool_state.pool_params
1472+
if not has_issue_5365:
1473+
assert not clusterlib_utils.check_pool_data(
1474+
pool_params=pool_state.future_pool_params, pool_creation_data=pool_data_updated
1475+
)
14741476

14751477
if cluster.epoch_length_sec <= TWO_HOURS_SEC:
14761478
cluster.wait_for_epoch(epoch_no=update_epoch + 1, padding_seconds=5)
@@ -1482,6 +1484,9 @@ def test_update_stake_pool_metadata(
14821484
pool_data=pool_data_updated,
14831485
)
14841486

1487+
if has_issue_5365:
1488+
issues.ledger_5365.finish_test()
1489+
14851490
@allure.link(helpers.get_vcs_link())
14861491
@common.PARAM_BUILD_METHOD_NO_EST
14871492
@pytest.mark.testnets
@@ -1589,12 +1594,12 @@ def test_update_stake_pool_parameters(
15891594
raise ValueError(msg)
15901595

15911596
# Check that pool is going to be updated with correct data
1592-
future_params = cluster.g_query.get_pool_state(
1593-
stake_pool_id=pool_creation_out.stake_pool_id
1594-
).future_pool_params
1595-
assert not clusterlib_utils.check_pool_data(
1596-
pool_params=future_params, pool_creation_data=pool_data_updated
1597-
)
1597+
pool_state = cluster.g_query.get_pool_state(stake_pool_id=pool_creation_out.stake_pool_id)
1598+
has_issue_5365 = pool_state.future_pool_params == pool_state.pool_params
1599+
if not has_issue_5365:
1600+
assert not clusterlib_utils.check_pool_data(
1601+
pool_params=pool_state.future_pool_params, pool_creation_data=pool_data_updated
1602+
)
15981603

15991604
if cluster.epoch_length_sec <= TWO_HOURS_SEC:
16001605
cluster.wait_for_epoch(epoch_no=update_epoch + 1, padding_seconds=5)
@@ -1606,6 +1611,9 @@ def test_update_stake_pool_parameters(
16061611
pool_data=pool_data_updated,
16071612
)
16081613

1614+
if has_issue_5365:
1615+
issues.ledger_5365.finish_test()
1616+
16091617
@allure.link(helpers.get_vcs_link())
16101618
@pytest.mark.testnets
16111619
@pytest.mark.smoke

cardano_node_tests/tests/test_tx_many_utxos.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ def many_utxos(
115115
# transactions. This can happen from time to time, we stress
116116
# the network here and waiting for 2 blocks may not be enough to get a
117117
# transaction through.
118-
if "BadInputsUTxO" not in str(err):
118+
exc_str = str(err)
119+
inputs_spent = (
120+
'(ConwayMempoolFailure "All inputs are spent.'
121+
in exc_str # In cardano-node >= 10.6.0
122+
or "(BadInputsUTxO" in exc_str
123+
)
124+
if not inputs_spent:
119125
raise
120126
excp = err
121127
else:

cardano_node_tests/tests/test_tx_mempool.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ def test_query_mempool_txin(
8989
try:
9090
cluster.g_transaction.submit_tx_bare(tx_file=out_file_signed)
9191
except clusterlib.CLIError as exc: # noqa: PERF203
92-
if r == 0 or "(BadInputsUTxO" not in str(exc):
92+
exc_str = str(exc)
93+
inputs_spent = (
94+
'(ConwayMempoolFailure "All inputs are spent.'
95+
in exc_str # In cardano-node >= 10.6.0
96+
or "(BadInputsUTxO" in exc_str
97+
)
98+
if r == 0 or not inputs_spent:
9399
raise
94100
break
95101
else:

cardano_node_tests/tests/test_tx_negative.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,11 @@ def test_duplicated_tx(
683683
# It should NOT be possible to submit a transaction twice
684684
with pytest.raises(clusterlib.CLIError) as excinfo:
685685
cluster.g_transaction.submit_tx_bare(out_file_signed)
686-
assert "ValueNotConservedUTxO" in str(excinfo.value)
686+
exc_str = str(excinfo.value)
687+
assert (
688+
'(ConwayMempoolFailure "All inputs are spent.' in exc_str # In cardano-node >= 10.6.0
689+
or "(ValueNotConservedUTxO" in exc_str
690+
), exc_str
687691

688692
@allure.link(helpers.get_vcs_link())
689693
@pytest.mark.smoke
@@ -1149,7 +1153,10 @@ def test_nonexistent_utxo_ix(
11491153
or "The following tx input(s) were not present in the UTxO" in err
11501154
), err
11511155
elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW:
1152-
assert "BadInputsUTxO" in err, err
1156+
assert (
1157+
'(ConwayMempoolFailure "All inputs are spent.' in err # In cardano-node >= 10.6.0
1158+
or "(BadInputsUTxO" in err
1159+
), err
11531160
else:
11541161
msg = f"Unsupported build method: {build_method}"
11551162
raise ValueError(msg)
@@ -1189,7 +1196,10 @@ def test_nonexistent_utxo_hash(
11891196
or "The following tx input(s) were not present in the UTxO" in err
11901197
), err
11911198
elif build_method == clusterlib_utils.BuildMethods.BUILD_RAW:
1192-
assert "BadInputsUTxO" in err, err
1199+
assert (
1200+
'(ConwayMempoolFailure "All inputs are spent.' in err # In cardano-node >= 10.6.0
1201+
or "(BadInputsUTxO" in err
1202+
), err
11931203
else:
11941204
msg = f"Unsupported build method: {build_method}"
11951205
raise ValueError(msg)

cardano_node_tests/tests/tests_conway/test_pparam_update.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,8 @@ def _check_proposed_pparams(
11531153
)
11541154
fin_approve_epoch = cluster.g_query.get_epoch()
11551155

1156+
assert not cluster.g_query.get_future_pparams(), "Future pparams should be empty"
1157+
11561158
# db-sync check
11571159
[r.start(url=_url) for r in (reqc.cip080, reqc.cip081, reqc.cip082, reqc.cip083)]
11581160
try:
@@ -1202,7 +1204,7 @@ def _check_proposed_pparams(
12021204
)
12031205

12041206
def _check_state(state: dict):
1205-
pparams = state.get("curPParams") or state.get("currentPParams") or {}
1207+
pparams = state.get("curPParams") or state.get("currentPParams") or state or {}
12061208
clusterlib_utils.check_updated_params(
12071209
update_proposals=fin_update_proposals, protocol_params=pparams
12081210
)
@@ -1277,6 +1279,7 @@ def _check_state(state: dict):
12771279

12781280
next_rat_state = rat_gov_state["nextRatifyState"]
12791281
_check_state(next_rat_state["nextEnactState"])
1282+
_check_state(cluster.g_query.get_future_pparams())
12801283
reqc.cip038_04.start(url=helpers.get_vcs_link())
12811284
assert not next_rat_state["ratificationDelayed"], "Ratification is delayed unexpectedly"
12821285
reqc.cip038_04.success()
@@ -1331,6 +1334,8 @@ def _check_state(state: dict):
13311334
if is_spo_total_below_threshold:
13321335
reqc.cip064_04.success()
13331336

1337+
assert not cluster.g_query.get_future_pparams(), "Future pparams should be empty"
1338+
13341339
# db-sync check
13351340
try:
13361341
reqc.db024.start(url=helpers.get_vcs_link())

cardano_node_tests/tests/tests_conway/test_treasury_withdrawals.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ def _cast_vote(
359359
voted_votes = _cast_vote(approve=True, vote_id="yes")
360360
approved_epoch = cluster.g_query.get_epoch()
361361

362-
treasury_init = clusterlib_utils.get_ledger_state(cluster_obj=cluster)["stateBefore"][
363-
"esAccountState"
364-
]["treasury"]
362+
treasury_init = clusterlib_utils.get_chain_account_state(
363+
ledger_state=clusterlib_utils.get_ledger_state(cluster_obj=cluster)
364+
).treasury
365365

366366
# Check ratification
367367
rat_epoch = cluster.wait_for_epoch(epoch_no=approved_epoch + 1, padding_seconds=5)
@@ -400,9 +400,9 @@ def _cast_vote(
400400
assert "(GovActionsDoNotExist" in err_str, err_str
401401

402402
reqc.cip079.start(url=helpers.get_vcs_link())
403-
treasury_finish = clusterlib_utils.get_ledger_state(cluster_obj=cluster)["stateBefore"][
404-
"esAccountState"
405-
]["treasury"]
403+
treasury_finish = clusterlib_utils.get_chain_account_state(
404+
ledger_state=clusterlib_utils.get_ledger_state(cluster_obj=cluster)
405+
).treasury
406406
assert treasury_init != treasury_finish, "Treasury balance didn't change"
407407
reqc.cip079.success()
408408

cardano_node_tests/tests/tests_plutus/spend_build.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,12 @@ def _build_spend_locked_txin( # noqa: C901
299299
if VERSIONS.transaction_era >= VERSIONS.CONWAY and "(DeserialiseFailure" in str_exc:
300300
issues.ledger_4198.finish_test()
301301
# Check if resubmitting failed because an input UTxO was already spent
302-
if "(BadInputsUTxO" not in str_exc:
302+
inputs_spent = (
303+
'(ConwayMempoolFailure "All inputs are spent.'
304+
in str_exc # In cardano-node >= 10.6.0
305+
or "(BadInputsUTxO" in str_exc
306+
)
307+
if not inputs_spent:
303308
raise
304309
else:
305310
pytest.fail("Transaction was not submitted successfully")

0 commit comments

Comments
 (0)