Skip to content

Commit

Permalink
Add test for options exit-at-block and stop-at-block
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Kudela committed Nov 26, 2024
1 parent f9b2f04 commit 5fe8398
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/python/functional/hived/test_node_exit_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import annotations

from typing import Final

import pytest

import test_tools as tt

NUMBER_OF_REVERSIBLE_BLOCKS: Final[int] = 21


@pytest.mark.testnet()
@pytest.mark.timeout(120)
def test_option_exit_at_block() -> None:
node = tt.InitNode()
node.run(exit_at_block=5 + NUMBER_OF_REVERSIBLE_BLOCKS)

# block_log saved only irreversible blocks
assert node.block_log.get_head_block_number() == 5, "Incorrect number of blocks in saved block_log."
assert not node.is_running(), "Node still running, it should not."


@pytest.mark.testnet()
def test_option_stop_at_block() -> None:
node = tt.InitNode()
node.run(stop_at_block=5)
node.wait_for_block_with_number(5, timeout=40)

assert node.is_running(), "Node, shouldn't be closed."
with pytest.raises(TimeoutError):
node.wait_for_block_with_number(6, timeout=6) # wait time needed to generate 2 blocks.
assert node.get_last_block_number() == 5, "Node should be stop at block 10, not generate more."

0 comments on commit 5fe8398

Please sign in to comment.