fix fixtures in testOneNodeAltersAClientRequest()
import pytest
import sys
-from plenum.test.delayers import ppDelay, ppgDelay
-from plenum.test.helper import sdk_json_to_request_object
+from plenum.test.delayers import ppDelay, ppgDelay, nom_delay, req_delay
+from plenum.test.helper import sdk_json_to_request_object, \
+ sdk_send_random_requests
from stp_core.loop.eventually import eventually
from plenum.common.exceptions import InsufficientCorrectSignatures
from stp_core.common.log import getlogger
@@ -18,15 +19,6 @@ whitelist = ['doing nothing for now',
'InvalidSignature']
-@pytest.fixture(scope="module")
-def setup(txnPoolNodeSet):
- alpha = txnPoolNodeSet[0]
- alpha.nodeIbStasher.delay(ppgDelay(sys.maxsize))
- pool_without_alpha = list(txnPoolNodeSet)
- pool_without_alpha.remove(alpha)
- return adict(goodNodes=pool_without_alpha)
-
-
@pytest.fixture(scope="module")
def evilAlpha(txnPoolNodeSet):
makeNodeFaulty(txnPoolNodeSet[0], changesRequest)
@@ -37,17 +29,30 @@ faultyNodes = 1
def testOneNodeAltersAClientRequest(looper,
txnPoolNodeSet,
- setup,
evilAlpha,
- sent1):
- sent1 = sdk_json_to_request_object(sent1[0][0])
- checkPropagated(looper, txnPoolNodeSet, sent1, faultyNodes)
+ sdk_pool_handle,
+ sdk_wallet_client):
+ """Malicious Alpha node sends incorrect propagate. This test check that
+ nodes raise InsufficientCorrectSignatures in validate this propagate"""
- goodNodes = setup.goodNodes
+ alpha = txnPoolNodeSet[0]
+ goodNodes = list(txnPoolNodeSet)
+ goodNodes.remove(alpha)
+ # delay incoming client messages for good nodes by 250 milliseconds
+ # this gives Alpha a chance to send a propagate message
+ for n in goodNodes: # type: TestNode
+ n.nodeIbStasher.delay(ppDelay(sys.maxsize))
+ n.nodeIbStasher.delay(req_delay(sys.maxsize))
+ pastNodes = []
+
+ request_couple_json = sdk_send_random_requests(looper, sdk_pool_handle,
+ sdk_wallet_client, 1)
+ sent1 = sdk_json_to_request_object(request_couple_json[0][0])
+ checkPropagated(looper, txnPoolNodeSet, sent1, faultyNodes)
def check():
for node in goodNodes:
-
+ if node not in pastNodes:
# ensure the nodes are suspicious of Alpha
params = node.spylog.getLastParams(TestNode.reportSuspiciousNode)
frm = params["nodeName"]
@@ -61,6 +66,10 @@ def testOneNodeAltersAClientRequest(looper,
assert 'Alpha' not in props
for good in goodNodes:
assert good.name in props
+ pastNodes.append(node)
+
+ for node in goodNodes:
+ node.nodeIbStasher.resetDelays()
