fix test_old_non_primary_restart_after_view_change
@@ -9,7 +9,7 @@ from plenum.test.test_node import ensureElectionsDone, getNonPrimaryReplicas
from plenum.test.view_change.helper import ensure_view_change, start_stopped_node
from stp_core.loop.eventually import eventually
-from plenum.test.helper import checkViewNoForNodes, sdk_send_random_and_check
+from plenum.test.helper import checkViewNoForNodes, sdk_send_random_and_check, waitForViewChange
from plenum.test.pool_transactions.conftest import sdk_node_theta_added
from plenum.test.primary_selection.conftest import sdk_one_node_added
@@ -19,21 +19,10 @@ logger = getlogger()
@pytest.fixture(scope='module')
-def all_nodes_view_change(
- looper,
- txnPoolNodeSet,
- sdk_pool_handle,
- sdk_wallet_client):
+def new_node_in_correct_view(looper, txnPoolNodeSet,
+ sdk_one_node_added, sdk_pool_handle, sdk_wallet_client):
for _ in range(5):
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_client, 2)
- ensure_view_change(looper, txnPoolNodeSet)
- ensureElectionsDone(looper, txnPoolNodeSet)
- ensure_all_nodes_have_same_data(looper, txnPoolNodeSet)
-
-
-@pytest.fixture(scope='module')
-def new_node_in_correct_view(all_nodes_view_change, looper, txnPoolNodeSet,
- sdk_one_node_added, sdk_pool_handle, sdk_wallet_client):
new_node = sdk_one_node_added
looper.run(eventually(checkViewNoForNodes, txnPoolNodeSet, retryWait=1,
timeout=10))
@@ -58,7 +47,6 @@ def test_old_non_primary_restart_after_view_change(new_node_in_correct_view,
the crashed node comes back up after view change
"""
node_to_stop = getNonPrimaryReplicas(txnPoolNodeSet, 0)[-1].node
- old_view_no = node_to_stop.viewNo
# Stop non-primary
disconnect_node_and_ensure_disconnected(looper, txnPoolNodeSet,
@@ -69,7 +57,9 @@ def test_old_non_primary_restart_after_view_change(new_node_in_correct_view,
# Send some requests before view change
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle,
sdk_wallet_client, 5)
+ old_view_no = txnPoolNodeSet[0].viewNo
ensure_view_change(looper, remaining_nodes, custom_timeout=tconf.VIEW_CHANGE_TIMEOUT)
+ waitForViewChange(looper, remaining_nodes, expectedViewNo=old_view_no + 1)
ensureElectionsDone(looper, remaining_nodes)
# Send some requests after view change
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle,
