Skip to content

Commit

Permalink
[INDY-993] Test_batch_rejection integrated with sdk (#558)
Browse files Browse the repository at this point in the history
* tests done

Signed-off-by: ArtObr <[email protected]>

* import fixes

Signed-off-by: ArtObr <[email protected]>
  • Loading branch information
ArtObr authored and ashcherbakov committed Mar 6, 2018
1 parent 8a7df59 commit 475e70b
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions plenum/test/batching_3pc/test_batch_rejection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@
from stp_core.loop.eventually import eventually
from plenum.common.constants import DOMAIN_LEDGER_ID
from plenum.common.util import updateNamedTuple
from plenum.test.helper import sendRandomRequests, \
waitForSufficientRepliesForRequests
from plenum.test.test_node import getNonPrimaryReplicas, getPrimaryReplica
from plenum.test.helper import sdk_send_random_requests, \
sdk_send_random_and_check
from plenum.test.test_node import getNonPrimaryReplicas, \
getPrimaryReplica


@pytest.fixture(scope="module")
def setup(tconf, looper, txnPoolNodeSet, client, wallet1):
def setup(tconf, looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_client):
# Patch the 3phase request sending method to send incorrect digest and
pr, otherR = getPrimaryReplica(txnPoolNodeSet, instId=0), \
getNonPrimaryReplicas(txnPoolNodeSet, instId=0)

reqs = sendRandomRequests(wallet1, client, tconf.Max3PCBatchSize)
waitForSufficientRepliesForRequests(
looper,
client,
requests=reqs,
customTimeoutPerReq=tconf.Max3PCBatchWait)
getNonPrimaryReplicas(txnPoolNodeSet, instId=0)

sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle,
sdk_wallet_client, tconf.Max3PCBatchSize)
stateRoot = pr.stateRootHash(DOMAIN_LEDGER_ID, to_str=False)

origMethod = pr.create3PCBatch
Expand All @@ -36,7 +33,8 @@ def badMethod(self, ledgerId):
return pp

pr.create3PCBatch = types.MethodType(badMethod, pr)
sendRandomRequests(wallet1, client, tconf.Max3PCBatchSize)
sdk_send_random_requests(looper, sdk_pool_handle, sdk_wallet_client,
tconf.Max3PCBatchSize)
return pr, otherR, stateRoot


Expand Down Expand Up @@ -75,15 +73,13 @@ def testViewChangeAfterBatchRejected(viewChanged):
"""


def testMoreBatchesWillBeSentAfterViewChange(reverted, viewChanged, wallet1,
client, tconf, looper):
def testMoreBatchesWillBeSentAfterViewChange(reverted, viewChanged,
txnPoolNodeSet,
sdk_pool_handle, sdk_wallet_client,
tconf, looper):
"""
After retrying discarded batches, new batches are sent
:return:
"""
reqs = sendRandomRequests(wallet1, client, tconf.Max3PCBatchSize)
waitForSufficientRepliesForRequests(
looper,
client,
requests=reqs,
customTimeoutPerReq=tconf.Max3PCBatchWait)
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle,
sdk_wallet_client, tconf.Max3PCBatchSize)

0 comments on commit 475e70b

Please sign in to comment.