Skip to content

Commit

Permalink
Merge pull request #480 from skalenetwork/hotfix/SKALE-4979-fix-new-n…
Browse files Browse the repository at this point in the history
…odes-list

SKALE-4979 Improve rotation conditions test
  • Loading branch information
dmytrotkk authored Feb 17, 2022
2 parents 56c5046 + cf3a358 commit e25755c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
19 changes: 17 additions & 2 deletions tests/manager/node_rotation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cleanup_nodes_schains, create_schain, add_test4_schain_type
)
from tests.constants import DEFAULT_SCHAIN_ID, DEFAULT_SCHAIN_NAME, DEFAULT_SCHAIN_INDEX
from tests.rotation_history.utils import set_up_nodes, run_dkg
from tests.rotation_history.utils import set_up_nodes, run_dkg, _skip_evm_time, TEST_ROTATION_DELAY


def test_get_rotation(skale):
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_is_rotation_active(skale):
run_dkg(nodes, skale_instances, group_index)

exiting_node_index = 1
set_up_nodes(skale, 1)
new_nodes, new_skale_instances = set_up_nodes(skale, 1)

assert not skale.node_rotation.is_new_node_found(name)
assert not skale.node_rotation.is_rotation_in_progress(name)
Expand All @@ -83,3 +83,18 @@ def test_is_rotation_active(skale):
assert skale.node_rotation.is_new_node_found(name)
assert skale.node_rotation.is_rotation_in_progress(name)
assert skale.node_rotation.is_rotation_active(name)

nodes[exiting_node_index] = new_nodes[0]
skale_instances[exiting_node_index] = new_skale_instances[0]

run_dkg(nodes, skale_instances, group_index, skip_time=False)

assert skale.node_rotation.is_new_node_found(name)
assert skale.node_rotation.is_rotation_in_progress(name)
assert skale.node_rotation.is_rotation_active(name)

_skip_evm_time(skale_instances[0].web3, TEST_ROTATION_DELAY)

assert skale.node_rotation.is_new_node_found(name)
assert not skale.node_rotation.is_rotation_in_progress(name)
assert not skale.node_rotation.is_rotation_active(name)
5 changes: 3 additions & 2 deletions tests/rotation_history/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ def fail_dkg(
return new_node_ids


def run_dkg(nodes, skale_instances, group_index):
def run_dkg(nodes, skale_instances, group_index, skip_time=True):
logger.info('Running DKG procedure...')
send_broadcasts(nodes, skale_instances, group_index)
send_alrights(nodes, skale_instances, group_index)
_skip_evm_time(skale_instances[0].web3, TEST_ROTATION_DELAY)
if skip_time:
_skip_evm_time(skale_instances[0].web3, TEST_ROTATION_DELAY)

0 comments on commit e25755c

Please sign in to comment.