Skip to content
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

[INDY-993] Test_batch_rejection integrated with sdk #558

Merged
Merged
Changes from all commits
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
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)