Skip to content

INDY-2215: add re-ask LedgerStatuses for the init catchup #1305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plenum/server/catchup/cons_proof_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def start(self, request_ledger_statuses: bool):

if request_ledger_statuses:
self._request_ledger_status_from_nodes()
self._schedule_reask_ledger_status()
self._schedule_reask_ledger_status()

def process_ledger_status(self, ledger_status: LedgerStatus, frm: str):
if not self._can_process_ledger_status(ledger_status):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pytest
from plenum.common.config_helper import PNodeConfigHelper
from plenum.common.messages.node_messages import LedgerStatus, ConsistencyProof
from plenum.common.util import getCallableName
from plenum.server.router import Route
from plenum.test.helper import sdk_send_random_and_check
from plenum.test.node_catchup.helper import waitNodeDataEquality
from plenum.test.pool_transactions.helper import \
Expand All @@ -12,7 +14,7 @@
call_count = 0


@pytest.fixture(scope='function', params=range(1, 4))
@pytest.fixture(scope='function', params=range(1, 5))
def lost_count(request):
return request.param

Expand All @@ -31,14 +33,6 @@ def test_catchup_with_lost_ledger_status(txnPoolNodeSet,

node_to_disconnect = txnPoolNodeSet[-1]

def unpatch_after_call(status, frm):
global call_count
call_count += 1
if call_count >= lost_count:
# unpatch processLedgerStatus after lost_count calls
monkeypatch.undo()
call_count = 0

sdk_send_random_and_check(looper, txnPoolNodeSet,
sdk_pool_handle, sdk_wallet_steward, 5)

Expand All @@ -60,9 +54,17 @@ def unpatch_after_call(status, frm):
config=tconf,
ha=nodeHa, cliha=nodeCHa,
pluginPaths=allPluginsPath)

def unpatch_after_call(status, frm):
global call_count
call_count += 1
if call_count >= lost_count:
# unpatch processLedgerStatus after lost_count calls
node_to_disconnect.nodeMsgRouter.add((LedgerStatus, node_to_disconnect.ledgerManager.processLedgerStatus))
call_count = 0

# patch processLedgerStatus
monkeypatch.setattr(node_to_disconnect.ledgerManager, 'processLedgerStatus',
unpatch_after_call)
node_to_disconnect.nodeMsgRouter.add((LedgerStatus, unpatch_after_call))

# add node_to_disconnect to pool
looper.add(node_to_disconnect)
Expand All @@ -88,14 +90,6 @@ def test_catchup_with_lost_first_consistency_proofs(txnPoolNodeSet,
Test makes sure that the node eventually finishes catchup'''
node_to_disconnect = txnPoolNodeSet[-1]

def unpatch_after_call(proof, frm):
global call_count
call_count += 1
if call_count >= lost_count:
# unpatch processConsistencyProof after lost_count calls
monkeypatch.undo()
call_count = 0

sdk_send_random_and_check(looper, txnPoolNodeSet,
sdk_pool_handle, sdk_wallet_steward, 5)

Expand All @@ -117,10 +111,18 @@ def unpatch_after_call(proof, frm):
config=tconf,
ha=nodeHa, cliha=nodeCHa,
pluginPaths=allPluginsPath)

def unpatch_after_call(proof, frm):
global call_count
call_count += 1
if call_count >= lost_count:
# unpatch processConsistencyProof after lost_count calls
node_to_disconnect.nodeMsgRouter.add((ConsistencyProof,
node_to_disconnect.ledgerManager.processConsistencyProof))
call_count = 0

# patch processConsistencyProof
monkeypatch.setattr(node_to_disconnect.ledgerManager,
'processConsistencyProof',
unpatch_after_call)
node_to_disconnect.nodeMsgRouter.add((ConsistencyProof, unpatch_after_call))
# add node_to_disconnect to pool
looper.add(node_to_disconnect)
txnPoolNodeSet[-1] = node_to_disconnect
Expand Down