Skip to content

Commit

Permalink
fix(tests): ensure reconfiguration finishes within a single epoch.
Browse files Browse the repository at this point in the history
Ensure reconfiguration finishes within a single epoch and take
submission delay into account when restarting node services.
  • Loading branch information
mkoura committed Oct 28, 2024
1 parent e7c9e00 commit e555e35
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cardano_node_tests/tests/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def reconf_for_dynamic(self) -> None:
with open(supervisor_conf, "w", encoding="utf-8") as fp_out:
fp_out.write(supervisor_conf_content)

cluster_nodes.reload_supervisor_config()
cluster_nodes.reload_supervisor_config(delay=0)

@pytest.fixture
def payment_addrs(
Expand Down Expand Up @@ -447,8 +447,8 @@ def _save_state(curr_epoch: int) -> tp.Dict[str, int]:
blocks_before: tp.Dict[str, int] = ledger_state["blocksBefore"]
return blocks_before

# The network needs to be at least in epoch 2
cluster.wait_for_epoch(epoch_no=2)
# The network needs to be at least in epoch 1
cluster.wait_for_epoch(epoch_no=1)

# Wait for the epoch to be at least half way through and not too close to the end.
# We want the original pool to have time to forge blocks in this epoch, before it becomes
Expand All @@ -457,8 +457,9 @@ def _save_state(curr_epoch: int) -> tp.Dict[str, int]:
clusterlib_utils.wait_for_epoch_interval(
cluster_obj=cluster,
start=(cluster.epoch_length_sec // 2),
stop=-50,
stop=-(configuration.TX_SUBMISSION_DELAY + 20),
)
reconf_epoch = cluster.g_query.get_epoch()

# The cluster needs respin after this point
cluster_manager.set_needs_respin()
Expand All @@ -468,9 +469,13 @@ def _save_state(curr_epoch: int) -> tp.Dict[str, int]:
cluster_nodes.restart_all_nodes()

tip = cluster.g_query.get_tip()
epoch_end = cluster.time_to_epoch_end(tip)
curr_epoch = int(tip["epoch"])
reconf_epoch = curr_epoch

assert (
reconf_epoch == curr_epoch
), "Failed to finish reconfiguration in single epoch, it would affect other checks"

epoch_end = cluster.time_to_epoch_end(tip)
curr_time = time.time()
epoch_end_timestamp = curr_time + epoch_end
test_end_timestamp = epoch_end_timestamp + (num_epochs * cluster.epoch_length_sec)
Expand Down

0 comments on commit e555e35

Please sign in to comment.