Skip to content

Commit

Permalink
Merge pull request IntersectMBO#2215 from IntersectMBO/880pre_fixes
Browse files Browse the repository at this point in the history
Make tests run on 8.8.0-pre
  • Loading branch information
mkoura authored Feb 8, 2024
2 parents 2047788 + eaa7f0d commit 3e3d552
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 128 deletions.
31 changes: 16 additions & 15 deletions cardano_node_tests/cluster_scripts/conway/genesis.conway.spec.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"poolVotingThresholds": {
"pvtCommitteeNormal": 0.51,
"pvtCommitteeNoConfidence": 0.51,
"pvtHardForkInitiation": 0.51,
"pvtMotionNoConfidence": 0.51
},
"motionNoConfidence": 0.51,
"committeeNormal": 0.51,
"committeeNoConfidence": 0.51,
"hardForkInitiation": 0.51,
"ppSecurityGroup": 0.51
},
"dRepVotingThresholds": {
"dvtMotionNoConfidence": 0.51,
"dvtCommitteeNormal": 0.51,
"dvtCommitteeNoConfidence": 0.51,
"dvtUpdateToConstitution": 0.51,
"dvtHardForkInitiation": 0.51,
"dvtPPNetworkGroup": 0.51,
"dvtPPEconomicGroup": 0.51,
"dvtPPTechnicalGroup": 0.51,
"dvtPPGovGroup": 0.51,
"dvtTreasuryWithdrawal": 0.51
"motionNoConfidence": 0.51,
"committeeNormal": 0.51,
"committeeNoConfidence": 0.51,
"updateToConstitution": 0.51,
"hardForkInitiation": 0.51,
"ppNetworkGroup": 0.51,
"ppEconomicGroup": 0.51,
"ppTechnicalGroup": 0.51,
"ppGovGroup": 0.51,
"treasuryWithdrawal": 0.51
},
"committeeMinSize": 0,
"committeeMaxTermLength": 11000,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"poolVotingThresholds": {
"pvtCommitteeNormal": 0.51,
"pvtCommitteeNoConfidence": 0.51,
"pvtHardForkInitiation": 0.51,
"pvtMotionNoConfidence": 0.51
},
"motionNoConfidence": 0.51,
"committeeNormal": 0.51,
"committeeNoConfidence": 0.51,
"hardForkInitiation": 0.51,
"ppSecurityGroup": 0.51
},
"dRepVotingThresholds": {
"dvtMotionNoConfidence": 0.51,
"dvtCommitteeNormal": 0.51,
"dvtCommitteeNoConfidence": 0.51,
"dvtUpdateToConstitution": 0.51,
"dvtHardForkInitiation": 0.51,
"dvtPPNetworkGroup": 0.51,
"dvtPPEconomicGroup": 0.51,
"dvtPPTechnicalGroup": 0.51,
"dvtPPGovGroup": 0.51,
"dvtTreasuryWithdrawal": 0.51
"motionNoConfidence": 0.51,
"committeeNormal": 0.51,
"committeeNoConfidence": 0.51,
"updateToConstitution": 0.51,
"hardForkInitiation": 0.51,
"ppNetworkGroup": 0.51,
"ppEconomicGroup": 0.51,
"ppTechnicalGroup": 0.51,
"ppGovGroup": 0.51,
"treasuryWithdrawal": 0.51
},
"committeeMinSize": 0,
"committeeMaxTermLength": 11000,
Expand Down
2 changes: 1 addition & 1 deletion cardano_node_tests/tests/tests_conway/conway_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def possible_rem_issue(gov_state: tp.Dict[str, tp.Any], epoch: int) -> bool:
See https://github.com/IntersectMBO/cardano-ledger/issues/3979
"""
removed_actions: tp.List[tp.Dict[str, tp.Any]] = gov_state["nextRatifyState"][
"removedGovActions"
"expiredGovActions"
]
proposals: tp.List[tp.Dict[str, tp.Any]] = gov_state["proposals"]

Expand Down
89 changes: 47 additions & 42 deletions cardano_node_tests/tests/tests_conway/test_committee.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,18 +715,21 @@ def _cast_vote(
)

# Vote & approve the action
_cast_vote(
voted_votes_add = _cast_vote(
approve=True, vote_id="add_yes", action_txid=action_add_txid, action_ix=action_add_ix
)

# Check that CC members votes on "update committee" action are ignored
voted_votes_add = _cast_vote(
approve=True,
vote_id="add_with_ccs",
add_cc_votes=True,
action_txid=action_add_txid,
action_ix=action_add_ix,
)
# Check that CC cannot vote on "update committee" action
with pytest.raises(clusterlib.CLIError) as excinfo:
_cast_vote(
approve=True,
vote_id="add_with_ccs",
add_cc_votes=True,
action_txid=action_add_txid,
action_ix=action_add_ix,
)
err_str = str(excinfo.value)
assert "CommitteeVoter" in err_str, err_str

def _check_add_state(state: dict):
for i, _cc_member_key in enumerate((cc_member1_key, cc_member2_key)):
Expand All @@ -742,21 +745,21 @@ def _check_add_state(state: dict):
conway_common.save_gov_state(
gov_state=rat_add_gov_state, name_template=f"{temp_template}_rat_add_{_cur_epoch}"
)
rem_action = governance_utils.lookup_removed_actions(
rat_action = governance_utils.lookup_ratified_actions(
gov_state=rat_add_gov_state, action_txid=action_add_txid
)
if rem_action:
if rat_action:
break

# Known ledger issue where only one expired action gets removed in one epoch.
# See https://github.com/IntersectMBO/cardano-ledger/issues/3979
if not rem_action and conway_common.possible_rem_issue(
if not rat_action and conway_common.possible_rem_issue(
gov_state=rat_add_gov_state, epoch=_cur_epoch
):
xfail_ledger_3979_msgs.add("Only single expired action got removed")
continue

raise AssertionError("Action not found in removed actions")
raise AssertionError("Action not found in ratified actions")

next_rat_add_state = rat_add_gov_state["nextRatifyState"]
_check_add_state(next_rat_add_state["nextEnactState"])
Expand All @@ -769,15 +772,16 @@ def _check_add_state(state: dict):
name_template=f"{temp_template}_rat_add_{_cur_epoch}",
)

has_ledger_issue_4001 = False
xfail_ledger_4001_msgs = set()
for _cc_member_key in (cc_member1_key, cc_member2_key):
rat_add_member_rec = rat_add_committee_state["committee"].get(_cc_member_key) or {}
if rat_add_member_rec:
assert (
rat_add_member_rec["hotCredsAuthStatus"]["tag"] == "MemberAuthorized"
), "CC Member is no longer authorized"
if rat_add_member_rec["hotCredsAuthStatus"]["tag"] != "MemberAuthorized":
xfail_ledger_4001_msgs.add("Newly elected CC members lose authorization")
else:
has_ledger_issue_4001 = True
xfail_ledger_4001_msgs.add(
"Newly elected CC members are removed during ratification"
)

assert not rat_add_committee_state["committee"].get(
cc_member3_key
Expand All @@ -802,7 +806,7 @@ def _check_add_state(state: dict):
for i, _cc_member_key in enumerate((cc_member1_key, cc_member2_key)):
enact_add_member_rec = enact_add_committee_state["committee"][_cc_member_key]
assert (
has_ledger_issue_4001
xfail_ledger_4001_msgs
or enact_add_member_rec["hotCredsAuthStatus"]["tag"] == "MemberAuthorized"
), "CC Member was NOT authorized"
assert enact_add_member_rec["status"] == "Active", "CC Member should be active"
Expand Down Expand Up @@ -833,18 +837,21 @@ def _check_add_state(state: dict):
)

# Vote & approve the action
_cast_vote(
voted_votes_rem = _cast_vote(
approve=True, vote_id="rem_yes", action_txid=action_rem_txid, action_ix=action_rem_ix
)

# Check that CC members votes on "update committee" action are ignored
voted_votes_rem = _cast_vote(
approve=True,
vote_id="rem_with_ccs",
add_cc_votes=True,
action_txid=action_rem_txid,
action_ix=action_rem_ix,
)
# Check that CC cannot vote on "update committee" action
with pytest.raises(clusterlib.CLIError) as excinfo:
_cast_vote(
approve=True,
vote_id="rem_with_ccs",
add_cc_votes=True,
action_txid=action_rem_txid,
action_ix=action_rem_ix,
)
err_str = str(excinfo.value)
assert "CommitteeVoter" in err_str, err_str

def _check_rem_state(state: dict):
cc_member_val = state["committee"]["members"].get(cc_member2_key)
Expand All @@ -857,21 +864,21 @@ def _check_rem_state(state: dict):
conway_common.save_gov_state(
gov_state=rat_rem_gov_state, name_template=f"{temp_template}_rat_rem_{_cur_epoch}"
)
rem_action = governance_utils.lookup_removed_actions(
rat_action = governance_utils.lookup_ratified_actions(
gov_state=rat_rem_gov_state, action_txid=action_rem_txid
)
if rem_action:
if rat_action:
break

# Known ledger issue where only one expired action gets removed in one epoch.
# See https://github.com/IntersectMBO/cardano-ledger/issues/3979
if not rem_action and conway_common.possible_rem_issue(
if not rat_action and conway_common.possible_rem_issue(
gov_state=rat_rem_gov_state, epoch=_cur_epoch
):
xfail_ledger_3979_msgs.add("Only single expired action got removed")
continue

raise AssertionError("Action not found in removed actions")
raise AssertionError("Action not found in ratified actions")

next_rat_rem_state = rat_rem_gov_state["nextRatifyState"]
_check_rem_state(next_rat_rem_state["nextEnactState"])
Expand Down Expand Up @@ -941,12 +948,12 @@ def _check_rem_state(state: dict):
check_on_devel=False,
)
)
if has_ledger_issue_4001:
if xfail_ledger_4001_msgs:
known_issues.append(
blockers.GH(
issue=4001,
repo="IntersectMBO/cardano-ledger",
message="Newly elected CC members are removed during ratification",
message="; ".join(xfail_ledger_4001_msgs),
check_on_devel=False,
)
)
Expand Down Expand Up @@ -1320,10 +1327,8 @@ def _cast_vote(
gov_state=vote_gov_state, action_txid=action_txid
)
assert prop_vote["dRepVotes"], "No DRep votes"
if votes_cc:
assert prop_vote["committeeVotes"], "No committee votes"
if votes_spo:
assert prop_vote["stakePoolVotes"], "No stake pool votes"
assert not votes_cc or prop_vote["committeeVotes"], "No committee votes"
assert not votes_spo or prop_vote["stakePoolVotes"], "No stake pool votes"

return conway_common.VotedVotes(cc=[], drep=votes_drep, spo=votes_spo)

Expand All @@ -1336,21 +1341,21 @@ def _check_rat_gov_state(
conway_common.save_gov_state(
gov_state=gov_state, name_template=f"{name_template}_{_cur_epoch}"
)
rem_action = governance_utils.lookup_removed_actions(
rat_action = governance_utils.lookup_ratified_actions(
gov_state=gov_state, action_txid=action_txid, action_ix=action_ix
)
if rem_action:
if rat_action:
return gov_state

# Known ledger issue where only one expired action gets removed in one epoch.
# See https://github.com/IntersectMBO/cardano-ledger/issues/3979
if not rem_action and conway_common.possible_rem_issue(
if not rat_action and conway_common.possible_rem_issue(
gov_state=gov_state, epoch=_cur_epoch
):
xfail_ledger_3979_msgs.add("Only single expired action got removed")
continue

raise AssertionError("Action not found in removed actions")
raise AssertionError("Action not found in ratified actions")

return {}

Expand Down
8 changes: 4 additions & 4 deletions cardano_node_tests/tests/tests_conway/test_constitution.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _cast_vote(
)
assert not configuration.HAS_CC or prop_vote["committeeVotes"], "No committee votes"
assert prop_vote["dRepVotes"], "No DRep votes"
assert not prop_vote["stakePoolVotes"], "Unexpected stake pool votes"
assert not votes_spo or prop_vote["stakePoolVotes"], "Unexpected stake pool votes"

return conway_common.VotedVotes(cc=votes_cc, drep=votes_drep, spo=votes_spo)

Expand Down Expand Up @@ -276,15 +276,15 @@ def _check_state(state: dict):
conway_common.save_gov_state(
gov_state=rat_gov_state, name_template=f"{temp_template}_rat_{_cur_epoch}"
)
rem_action = governance_utils.lookup_removed_actions(
rat_action = governance_utils.lookup_ratified_actions(
gov_state=rat_gov_state, action_txid=action_txid
)
if rem_action:
if rat_action:
break

# Known ledger issue where only one expired action gets removed in one epoch.
# See https://github.com/IntersectMBO/cardano-ledger/issues/3979
if not rem_action and conway_common.possible_rem_issue(
if not rat_action and conway_common.possible_rem_issue(
gov_state=rat_gov_state, epoch=_cur_epoch
):
xfail_ledger_3979_msgs.add("Only single expired action got removed")
Expand Down
20 changes: 12 additions & 8 deletions cardano_node_tests/tests/tests_conway/test_no_confidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,15 @@ def _cast_vote(
_cast_vote(approve=False, vote_id="no")

# Vote & approve the action
_cast_vote(approve=True, vote_id="yes")
voted_votes = _cast_vote(approve=True, vote_id="yes")

# Testnet will be in state of no confidence, respin is needed
with cluster_manager.respin_on_failure():
# Check that CC members votes on "no confidence" action are ignored
voted_votes = _cast_vote(approve=True, vote_id="with_ccs", add_cc_votes=True)
# Check that CC cannot vote on "no confidence" action
with pytest.raises(clusterlib.CLIError) as excinfo:
_cast_vote(approve=True, vote_id="with_ccs", add_cc_votes=True)
err_str = str(excinfo.value)
assert "CommitteeVoter" in err_str, err_str

# Check ratification
xfail_ledger_3979_msgs = set()
Expand All @@ -259,21 +262,21 @@ def _cast_vote(
conway_common.save_gov_state(
gov_state=rat_gov_state, name_template=f"{temp_template}_rat_{_cur_epoch}"
)
rem_action = governance_utils.lookup_removed_actions(
rat_action = governance_utils.lookup_ratified_actions(
gov_state=rat_gov_state, action_txid=action_txid
)
if rem_action:
if rat_action:
break

# Known ledger issue where only one expired action gets removed in one epoch.
# See https://github.com/IntersectMBO/cardano-ledger/issues/3979
if not rem_action and conway_common.possible_rem_issue(
if not rat_action and conway_common.possible_rem_issue(
gov_state=rat_gov_state, epoch=_cur_epoch
):
xfail_ledger_3979_msgs.add("Only single expired action got removed")
continue

raise AssertionError("Action not found in removed actions")
raise AssertionError("Action not found in ratified actions")

next_rat_state = rat_gov_state["nextRatifyState"]
assert next_rat_state["ratificationDelayed"], "Ratification not delayed"
Expand Down Expand Up @@ -311,7 +314,8 @@ def _cast_vote(
governance_utils.check_action_view(cluster_obj=cluster, action_data=no_confidence_action)

# Check vote view
governance_utils.check_vote_view(cluster_obj=cluster, vote_data=voted_votes.cc[0])
if voted_votes.cc:
governance_utils.check_vote_view(cluster_obj=cluster, vote_data=voted_votes.cc[0])
governance_utils.check_vote_view(cluster_obj=cluster, vote_data=voted_votes.drep[0])
governance_utils.check_vote_view(cluster_obj=cluster, vote_data=voted_votes.spo[0])

Expand Down
Loading

0 comments on commit 3e3d552

Please sign in to comment.