Skip to content

Commit

Permalink
Add deposit return test for pparam update
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinpkl committed Jun 4, 2024
1 parent 0f59349 commit 8ad594a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion cardano_node_tests/tests/tests_conway/test_pparam_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ def test_pparam_update( # noqa: C901
if is_in_bootstrap and not configuration.HAS_CC:
pytest.skip("The test doesn't work in bootstrap period without CC.")

init_return_account_balance = cluster.g_query.get_stake_addr_info(
pool_user_lg.stake.address
).reward_account_balance

# Check if total delegated stake is below the threshold. This can be used to check that
# undelegated stake is treated as Abstain. If undelegated stake was treated as Yes, than
# missing votes would approve the action.
Expand Down Expand Up @@ -632,13 +636,19 @@ def test_pparam_update( # noqa: C901
gov_state=cluster.g_conway_governance.query.gov_state(),
)

# For keeping track of how many proposals were submitted
# to check for all deposit required for action is returned back
submitted_proposal_count = 0

def _propose_pparams_update(
name_template: str,
proposals: tp.List[clusterlib_utils.UpdateProposal],
) -> conway_common.PParamPropRec:
anchor_url = f"http://www.pparam-action-{clusterlib.get_rand_str(4)}.com"
anchor_data_hash = cluster.g_conway_governance.get_anchor_data_hash(text=anchor_url)

# Increment count
nonlocal submitted_proposal_count
submitted_proposal_count += 1
return conway_common.propose_pparams_update(
cluster_obj=cluster,
name_template=name_template,
Expand Down Expand Up @@ -1175,6 +1185,16 @@ def _check_state(state: dict):
governance_utils.check_vote_view(cluster_obj=cluster, vote_data=fin_voted_votes.cc[0])
if fin_voted_votes.drep:
governance_utils.check_vote_view(cluster_obj=cluster, vote_data=fin_voted_votes.drep[0])

# Check for deposit return
deposit_amt = cluster.conway_genesis["govActionDeposit"]
enact_deposit_returned = cluster.g_query.get_stake_addr_info(
pool_user_lg.stake.address
).reward_account_balance
assert (
enact_deposit_returned == init_return_account_balance + deposit_amt * submitted_proposal_count
), "Incorrect return account balance"



class TestPParamData:
Expand Down

0 comments on commit 8ad594a

Please sign in to comment.