Skip to content

Commit dc41e52

Browse files
committed
refactor: use get_epoch and get_block_no methods
Updated test cases to use cluster.g_query.get_epoch and cluster.g_query.get_block_no methods instead of directly accessing the tip dictionary. This improves code readability and maintainability.
1 parent 2568703 commit dc41e52

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

cardano_node_tests/tests/test_blocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def _save_state(curr_epoch: int) -> None:
353353

354354
tip = cluster.g_query.get_tip()
355355
epoch_end = cluster.time_to_epoch_end(tip)
356-
curr_epoch = int(tip["epoch"])
356+
curr_epoch = cluster.g_query.get_epoch(tip=tip)
357357
curr_time = time.time()
358358
epoch_end_timestamp = curr_time + epoch_end
359359
test_end_timestamp = epoch_end_timestamp + (num_epochs * cluster.epoch_length_sec)
@@ -510,7 +510,7 @@ def _save_state(curr_epoch: int) -> dict[str, int]:
510510
cluster_nodes.restart_all_nodes()
511511

512512
tip = cluster.g_query.get_tip()
513-
curr_epoch = int(tip["epoch"])
513+
curr_epoch = cluster.g_query.get_epoch(tip=tip)
514514

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

cardano_node_tests/tests/test_dbsync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def test_blocks(self, cluster: clusterlib.ClusterLib): # noqa: C901
124124
common.get_test_id(cluster)
125125

126126
tip = cluster.g_query.get_tip()
127-
block_no = int(tip["block"])
128-
epoch = int(tip["epoch"])
127+
block_no = cluster.g_query.get_block_no(tip=tip)
128+
epoch = cluster.g_query.get_epoch(tip=tip)
129129

130130
# Check records for last 50 epochs
131131
epoch_from = epoch - 50

cardano_node_tests/tests/test_pool_saturation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def _save_pool_records() -> None:
493493
)
494494

495495
tip = cluster.g_query.get_tip()
496-
if int(tip["epoch"]) != this_epoch:
496+
if cluster.g_query.get_epoch(tip=tip) != this_epoch:
497497
helpers.write_json(
498498
out_file=f"{temp_template}_{this_epoch}_failed_tip.json", content=tip
499499
)

0 commit comments

Comments
 (0)