-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for options
exit-at-block
and stop-at-block
- Loading branch information
Michał Kudela
committed
Nov 26, 2024
1 parent
f9b2f04
commit 5fe8398
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |