Skip to content

Commit

Permalink
Merge pull request IntersectMBO#2235 from IntersectMBO/cast_votes_tes…
Browse files Browse the repository at this point in the history
…t_committee

Use `cast_votes` in test_committee.py
  • Loading branch information
mkoura authored Feb 14, 2024
2 parents 500ce79 + 32ebb6c commit bb434a5
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 258 deletions.
25 changes: 19 additions & 6 deletions cardano_node_tests/tests/tests_conway/conway_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,21 @@ def cast_vote(
approve_cc: tp.Optional[bool] = None,
approve_drep: tp.Optional[bool] = None,
approve_spo: tp.Optional[bool] = None,
cc_skip_votes: bool = False,
drep_skip_votes: bool = False,
spo_skip_votes: bool = False,
) -> VotedVotes:
"""Cast a vote."""
# pylint: disable=too-many-arguments
votes_cc = []
votes_drep = []
votes_spo = []

if approve_cc is not None:
votes_cc = [
cluster_obj.g_conway_governance.vote.create_committee(
_votes_cc = [
None # This CC member doesn't vote, his votes count as "No"
if cc_skip_votes and i % 3 == 0
else cluster_obj.g_conway_governance.vote.create_committee(
vote_name=f"{name_template}_cc{i}",
action_txid=action_txid,
action_ix=action_ix,
Expand All @@ -153,9 +159,12 @@ def cast_vote(
)
for i, m in enumerate(governance_data.cc_members, start=1)
]
votes_cc = [v for v in _votes_cc if v]
if approve_drep is not None:
votes_drep = [
cluster_obj.g_conway_governance.vote.create_drep(
_votes_drep = [
None # This DRep doesn't vote, his votes count as "No"
if drep_skip_votes and i % 3 == 0
else cluster_obj.g_conway_governance.vote.create_drep(
vote_name=f"{name_template}_drep{i}",
action_txid=action_txid,
action_ix=action_ix,
Expand All @@ -166,9 +175,12 @@ def cast_vote(
)
for i, d in enumerate(governance_data.dreps_reg, start=1)
]
votes_drep = [v for v in _votes_drep if v]
if approve_spo is not None:
votes_spo = [
cluster_obj.g_conway_governance.vote.create_spo(
_votes_spo = [
None # This SPO doesn't vote, his votes count as "No"
if spo_skip_votes and i % 3 == 0
else cluster_obj.g_conway_governance.vote.create_spo(
vote_name=f"{name_template}_pool{i}",
action_txid=action_txid,
action_ix=action_ix,
Expand All @@ -179,6 +191,7 @@ def cast_vote(
)
for i, p in enumerate(governance_data.pools_cold, start=1)
]
votes_spo = [v for v in _votes_spo if v]

cc_keys = [r.hot_skey_file for r in governance_data.cc_members] if votes_cc else []
drep_keys = [r.key_pair.skey_file for r in governance_data.dreps_reg] if votes_drep else []
Expand Down
Loading

0 comments on commit bb434a5

Please sign in to comment.