Skip to content

Commit e99e1f1

Browse files
Check Ratify State
1 parent 034d740 commit e99e1f1

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

cardano_node_tests/tests/tests_conway/test_committee.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,12 @@ def _check_resign_dbsync(res_member: clusterlib.CCMember) -> None:
11031103
)
11041104
assert rat_action, "Action not found in ratified actions"
11051105

1106+
rat_state = cluster.g_query.get_ratify_state()
1107+
clusterlib_utils.check_ratify_state(
1108+
ratify_state=rat_state,
1109+
expected_txid=action_add_txid,
1110+
)
1111+
11061112
# Disapprove ratified add action, the voting shouldn't have any effect
11071113
conway_common.cast_vote(
11081114
cluster_obj=cluster,

cardano_node_tests/tests/tests_conway/test_constitution.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,13 @@ def _check_cli_query():
483483
conway_common.save_gov_state(
484484
gov_state=rat_gov_state, name_template=f"{temp_template}_rat_{rat_epoch}"
485485
)
486+
487+
rat_state = cluster.g_query.get_ratify_state()
488+
clusterlib_utils.check_ratify_state(
489+
ratify_state=rat_state,
490+
expected_txid=action_txid,
491+
)
492+
486493
rat_action = governance_utils.lookup_ratified_actions(
487494
gov_state=rat_gov_state, action_txid=action_txid
488495
)

cardano_node_tests/utils/clusterlib_utils.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,3 +1615,36 @@ def get_just_lovelace_utxos(
16151615
return cl_txtools._get_usable_utxos(
16161616
address_utxos=address_utxos, coins={clusterlib.DEFAULT_COIN}
16171617
)
1618+
1619+
1620+
def check_ratify_state(
1621+
*,
1622+
ratify_state: dict,
1623+
expected_txid: str,
1624+
expected_fields: tp.Iterable[str] = (
1625+
"enactedGovActions",
1626+
"expiredGovActions",
1627+
"nextEnactState",
1628+
"ratificationDelayed",
1629+
),
1630+
) -> None:
1631+
"""Validate ratify-state structure and ensure the expected action is listed.
1632+
1633+
Args:
1634+
ratify_state: The JSON output from `cardano-cli query ratify-state`.
1635+
expected_txid: The transaction ID of the action expected to be ratified.
1636+
expected_fields: Required top-level fields.
1637+
1638+
Raises:
1639+
AssertionError: If the structure or contents are not as expected.
1640+
"""
1641+
missing_fields = set(expected_fields) - set(ratify_state)
1642+
if missing_fields:
1643+
msg = f"Missing expected fields in ratify-state: {missing_fields}"
1644+
raise AssertionError(msg)
1645+
1646+
enacted = ratify_state.get("enactedGovActions", [])
1647+
action_txids = {a.get("actionId", {}).get("txId") for a in enacted}
1648+
if expected_txid not in action_txids:
1649+
msg = f"Expected txid {expected_txid} not found in enactedGovActions."
1650+
raise AssertionError(msg)

0 commit comments

Comments
 (0)