Skip to content

Commit

Permalink
Epoch intervals tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoura committed May 4, 2021
1 parent 5304cc9 commit 2d1be0c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cardano_node_tests/tests/test_pools.py
Expand Up @@ -603,7 +603,7 @@ def test_deregister_stake_pool(

# deregister stake pool
clusterlib_utils.wait_for_epoch_interval(
cluster_obj=cluster, start=1, stop=-DEREG_BUFFER_SEC
cluster_obj=cluster, start=1, stop=-DEREG_BUFFER_SEC, force_epoch=False
)
__, tx_raw_output = cluster.deregister_stake_pool(
pool_owners=pool_owners,
Expand Down Expand Up @@ -700,7 +700,7 @@ def test_reregister_stake_pool(

# deregister stake pool
clusterlib_utils.wait_for_epoch_interval(
cluster_obj=cluster, start=1, stop=-DEREG_BUFFER_SEC
cluster_obj=cluster, start=1, stop=-DEREG_BUFFER_SEC, force_epoch=False
)
cluster.deregister_stake_pool(
pool_owners=pool_owners,
Expand Down Expand Up @@ -840,7 +840,7 @@ def test_cancel_stake_pool_deregistration(

# deregister stake pool in epoch + 2
clusterlib_utils.wait_for_epoch_interval(
cluster_obj=cluster, start=1, stop=-DEREG_BUFFER_SEC
cluster_obj=cluster, start=1, stop=-DEREG_BUFFER_SEC, force_epoch=False
)
cluster.deregister_stake_pool(
pool_owners=pool_owners,
Expand Down
18 changes: 13 additions & 5 deletions cardano_node_tests/tests/test_staking.py
Expand Up @@ -728,7 +728,9 @@ def test_reward_simple(
pool_reward = clusterlib.PoolUser(payment=pool_rec["payment"], stake=pool_rec["reward"])

# make sure we have enough time to finish the registration/delegation in one epoch
clusterlib_utils.wait_for_epoch_interval(cluster_obj=cluster, start=-600, stop=-400)
clusterlib_utils.wait_for_epoch_interval(
cluster_obj=cluster, start=5, stop=-300, force_epoch=False
)

init_owner_rewards = cluster.get_stake_addr_info(
pool_reward.stake.address
Expand Down Expand Up @@ -761,7 +763,9 @@ def test_reward_simple(

# withdraw rewards to payment address, make sure we have enough time to finish
# the withdrawal in one epoch
clusterlib_utils.wait_for_epoch_interval(cluster_obj=cluster, start=-600, stop=-400)
clusterlib_utils.wait_for_epoch_interval(
cluster_obj=cluster, start=5, stop=-300, force_epoch=False
)
cluster.withdraw_reward(
stake_addr_record=pool_user.stake,
dst_addr_record=pool_user.payment,
Expand Down Expand Up @@ -802,7 +806,7 @@ def test_reward_amount( # noqa: C901

# make sure we have enough time to finish the registration/delegation in one epoch
clusterlib_utils.wait_for_epoch_interval(
cluster_obj=cluster, start=-100, stop=-40, force_epoch=False
cluster_obj=cluster, start=5, stop=-40, force_epoch=False
)

init_epoch = cluster.get_epoch()
Expand Down Expand Up @@ -1067,7 +1071,7 @@ def test_reward_addr_delegation( # noqa: C901

# make sure we have enough time to update the pool parameters
clusterlib_utils.wait_for_epoch_interval(
cluster_obj=cluster, start=-100, stop=-30, force_epoch=False
cluster_obj=cluster, start=5, stop=-40, force_epoch=False
)
init_epoch = cluster.get_epoch()

Expand Down Expand Up @@ -2065,6 +2069,11 @@ def test_deregister_reward_addr_retire_pool(
force=True,
)

# make sure we have enough time to finish deregistration in one epoch
clusterlib_utils.wait_for_epoch_interval(
cluster_obj=cluster, start=5, stop=-40, force_epoch=False
)

src_dereg_balance = cluster.get_address_balance(pool_owner.payment.address)
stake_acount_balance = cluster.get_stake_addr_info(
pool_owner.stake.address
Expand All @@ -2077,7 +2086,6 @@ def test_deregister_reward_addr_retire_pool(
stake_pool_id = cluster.get_stake_pool_id(node_cold.vkey_file)

# deregister stake pool
clusterlib_utils.wait_for_epoch_interval(cluster_obj=cluster, start=1, stop=-30)
__, tx_raw_output = cluster.deregister_stake_pool(
pool_owners=[pool_owner],
cold_key_pair=node_cold,
Expand Down
3 changes: 2 additions & 1 deletion cardano_node_tests/utils/clusterlib_utils.py
Expand Up @@ -604,7 +604,8 @@ def wait_for_epoch_interval(
end of an epoch.
stop: An end of the interval, in seconds. Negative number for counting from the
end of an epoch.
force_epoch: A bool indicating whether the interval must be in current epoch.
force_epoch: A bool indicating whether the interval must be in current epoch
(True by default).
"""
start_abs = start if start >= 0 else cluster_obj.epoch_length_sec + start
stop_abs = stop if stop >= 0 else cluster_obj.epoch_length_sec + stop
Expand Down

0 comments on commit 2d1be0c

Please sign in to comment.