Skip to content

Commit fb7d096

Browse files
authored
Merge pull request #2805 from IntersectMBO/imp_test_change_delegation
feat(tests): update delegation test for DRep retirement
2 parents 6589fba + 43a9cf7 commit fb7d096

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

cardano_node_tests/tests/tests_conway/test_drep.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,6 @@ def _get_drep_rec(
14281428
def test_change_delegation(
14291429
self,
14301430
cluster_rewards: clusterlib.ClusterLib,
1431-
cluster_manager: cluster_management.ClusterManager,
14321431
payment_addr_rewards: clusterlib.AddressRecord,
14331432
pool_user_rewards: clusterlib.PoolUser,
14341433
testfile_temp_dir: pl.Path,
@@ -1442,29 +1441,25 @@ def test_change_delegation(
14421441
* Check that the delegation is of correct DRep id
14431442
* Change delegation to drep2 and submit certificate
14441443
* Check that vote delegation is updated to second DRep
1444+
* Retire the first DRep
1445+
* Check that votes are still delegated to the second DRep
14451446
"""
14461447
cluster = cluster_rewards
14471448
temp_template = common.get_test_id(cluster)
14481449
deposit_amt = cluster.g_query.get_address_deposit()
14491450

14501451
# Get first DRep
1451-
key1 = helpers.get_current_line_str()
1452-
drep1 = get_custom_drep(
1452+
drep1 = create_drep(
14531453
name_template=f"custom_drep_1_{temp_template}",
1454-
cluster_manager=cluster_manager,
14551454
cluster_obj=cluster,
14561455
payment_addr=payment_addr_rewards,
1457-
caching_key=key1,
14581456
)
14591457

14601458
# Get second DRep
1461-
key2 = helpers.get_current_line_str()
1462-
drep2 = get_custom_drep(
1459+
drep2 = create_drep(
14631460
name_template=f"custom_drep_2_{temp_template}",
1464-
cluster_manager=cluster_manager,
14651461
cluster_obj=cluster,
14661462
payment_addr=payment_addr_rewards,
1467-
caching_key=key2,
14681463
)
14691464

14701465
# Create stake address registration cert
@@ -1509,8 +1504,10 @@ def _deregister():
15091504

15101505
request.addfinalizer(_deregister)
15111506

1512-
stake_addr_info = cluster.g_query.get_stake_addr_info(pool_user_rewards.stake.address)
1513-
assert stake_addr_info.vote_delegation == governance_utils.get_drep_cred_name(
1507+
stake_addr_info_deleg1 = cluster.g_query.get_stake_addr_info(
1508+
pool_user_rewards.stake.address
1509+
)
1510+
assert stake_addr_info_deleg1.vote_delegation == governance_utils.get_drep_cred_name(
15141511
drep_id=drep1.drep_id
15151512
), "Votes are NOT delegated to the correct DRep 1"
15161513

@@ -1538,8 +1535,10 @@ def _deregister():
15381535
tx_files=tx_files,
15391536
deposit=deposit_amt,
15401537
)
1541-
stake_addr_info = cluster.g_query.get_stake_addr_info(pool_user_rewards.stake.address)
1542-
assert stake_addr_info.vote_delegation == governance_utils.get_drep_cred_name(
1538+
stake_addr_info_deleg2 = cluster.g_query.get_stake_addr_info(
1539+
pool_user_rewards.stake.address
1540+
)
1541+
assert stake_addr_info_deleg2.vote_delegation == governance_utils.get_drep_cred_name(
15431542
drep_id=drep2.drep_id
15441543
), "Votes are NOT changed to the correct DRep 2"
15451544
reqc.cip086.success()
@@ -1568,14 +1567,20 @@ def _deregister():
15681567
ret_drep_state = cluster.g_conway_governance.query.drep_state(
15691568
drep_vkey_file=drep1.key_pair.vkey_file
15701569
)
1571-
assert not ret_drep_state, "DRep was not retired"
1570+
assert not ret_drep_state, "DRep 1 was not retired"
15721571

1573-
stake_addr_info = cluster.g_query.get_stake_addr_info(pool_user_rewards.stake.address)
1574-
if not stake_addr_info.vote_delegation:
1575-
issues.ledger_4772.finish_test()
1576-
assert stake_addr_info.vote_delegation == governance_utils.get_drep_cred_name(
1577-
drep_id=drep2.drep_id
1578-
), "Votes are no longer delegated to DRep 2!"
1572+
stake_addr_info_ret = cluster.g_query.get_stake_addr_info(pool_user_rewards.stake.address)
1573+
1574+
if conway_common.is_in_bootstrap(cluster):
1575+
assert (
1576+
not stake_addr_info_ret.vote_delegation
1577+
), "Due to ledger issue 4772, vote delegation should be empty with PV9"
1578+
else:
1579+
if not stake_addr_info_ret.vote_delegation:
1580+
issues.ledger_4772.finish_test()
1581+
assert stake_addr_info_ret.vote_delegation == governance_utils.get_drep_cred_name(
1582+
drep_id=drep2.drep_id
1583+
), "Votes are no longer delegated to DRep 2!"
15791584

15801585

15811586
class TestDRepActivity:

0 commit comments

Comments
 (0)