Improve test_catchup_from_unqeual_nodes_without_reasking
import pytest
from plenum.server.catchup.node_leecher_service import NodeLeecherService
-from plenum.test.delayers import delay_3pc
+from plenum.test.delayers import delay_3pc, lsDelay
from plenum.test.helper import sdk_send_random_and_check, max_3pc_batch_limits
from plenum.test.node_catchup.helper import ensure_all_nodes_have_same_data
-from plenum.test.stasher import delay_rules_without_processing
+from plenum.test.stasher import delay_rules_without_processing, start_delaying
nodeCount = 7
@@ -32,19 +32,24 @@ def test_catchup_from_unequal_nodes_without_reasking(looper,
txnPoolNodeSet,
sdk_pool_handle,
sdk_wallet_client):
- # Node numbers are selected so that test fails when using old algo
- lagged_node_1 = txnPoolNodeSet[2]
- lagged_node_2 = txnPoolNodeSet[-1]
+ lagged_node_1 = txnPoolNodeSet[-1]
+ lagged_node_2 = txnPoolNodeSet[-2]
+ normal_nodes = [node for node in txnPoolNodeSet
+ if node not in [lagged_node_1, lagged_node_2]]
+ normal_stashers = [node.nodeIbStasher for node in normal_nodes]
+
with delay_rules_without_processing(lagged_node_1.nodeIbStasher, delay_3pc()):
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_client, 2)
with delay_rules_without_processing(lagged_node_2.nodeIbStasher, delay_3pc()):
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_client, 7)
- ensure_all_nodes_have_same_data(looper, set(txnPoolNodeSet) - {lagged_node_2, lagged_node_1},
- custom_timeout=30)
+ ensure_all_nodes_have_same_data(looper, normal_nodes, custom_timeout=30)
+
+ # Make sure that we will receive cons proof from lagging node before all other nodes
+ start_delaying(normal_stashers, lsDelay(delay=0.5))
# Perform catchup and make sure it completes successfully
- lagged_node_2.start_catchup()
- ensure_all_nodes_have_same_data(looper, set(txnPoolNodeSet) - {lagged_node_1},
+ lagged_node_1.start_catchup()
+ ensure_all_nodes_have_same_data(looper, set(txnPoolNodeSet) - {lagged_node_2},
custom_timeout=30)
- assert lagged_node_2.ledgerManager._node_leecher._state == NodeLeecherService.State.Idle
+ assert lagged_node_1.ledgerManager._node_leecher._state == NodeLeecherService.State.Idle
