Skip to content

Commit

Permalink
[INDY-988] testRequestDynamicValidation sdk integration (hyperledger#557
Browse files Browse the repository at this point in the history
)

* Additional checks for sdk_ functions

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

* Fix for exception handling and new function for "json to object" converting

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

* Space and the end

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

* Most of test integrated with txnPoolNodeSet

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

* 3 test left to do

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

* two tests left in INDY-1019. Others integrated

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

* Little fixes

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

* Import resolve, TODO added

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

* New line at the end

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

* TODO for import added

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

* Unused looper import removed

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

* One more test integrated with sdk

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

* Fixtures for prev test

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

* Unused import removed

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

* Start of integration

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

* Changes for test_different_request integration with sdk

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

* helper changes commited

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

* INDY-1172 done with chages at pool_transactions

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

* little fix

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

* Code structure changes

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

* Additinal code structure changes

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

* Started sdk integration of tests

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

* Review fixes

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

* LibIndy versions update

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

* temp

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

* ha persist test done

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

* more tests done

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

* review fixes

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

* More tests done, some problems

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

* more tests done

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

* temp

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

* more tests

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

* all tests done, except one. need more of exception handling

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

* exception handling made. One test strange behaviour left

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

* test integrated

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

* import fixes

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

* little fix

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

* little fix

Signed-off-by: ArtObr <[email protected]>
  • Loading branch information
ArtObr authored and Andrew Nikitin committed Apr 10, 2018
1 parent 28f6a17 commit 6d71551
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions plenum/test/batching_3pc/test_basic_batching.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import types
import pytest
from plenum.common.exceptions import UnauthorizedClientRequest
from plenum.common.exceptions import UnauthorizedClientRequest, RequestRejectedException
from plenum.test.batching_3pc.helper import checkNodesHaveSameRoots
from plenum.test.helper import sendRandomRequests, checkRejectWithReason, waitForSufficientRepliesForRequests
from plenum.test.helper import sdk_send_random_requests, sdk_get_and_check_replies
from stp_core.loop.eventually import eventually
from plenum.common.exceptions import InvalidClientRequest
from plenum.test.helper import sdk_sign_request_from_dict, sdk_send_random_and_check
from plenum.common.request import Request


def testRequestStaticValidation(tconf, looper,txnPoolNodeSet,
def testRequestStaticValidation(tconf, looper, txnPoolNodeSet,
sdk_wallet_client):
"""
Check that for requests which fail static validation, REQNACK is sent
Expand Down Expand Up @@ -59,7 +59,7 @@ def testTreeRootsCorrectAfterEachBatch(tconf, looper, txnPoolNodeSet,


def testRequestDynamicValidation(tconf, looper, txnPoolNodeSet,
client, wallet1):
sdk_pool_handle, sdk_wallet_client):
"""
Check that for requests which fail dynamic (state based) validation,
REJECT is sent to the client
Expand All @@ -82,16 +82,14 @@ def rejectingMethod(self, req):
origMethods.append(node.doDynamicValidation)
node.doDynamicValidation = types.MethodType(rejectingMethod, node)

reqs = sendRandomRequests(wallet1, client, tconf.Max3PCBatchSize)
waitForSufficientRepliesForRequests(looper, client, requests=reqs[:-1])
reqs = sdk_send_random_requests(looper, sdk_pool_handle,
sdk_wallet_client,
tconf.Max3PCBatchSize)
sdk_get_and_check_replies(looper, reqs[:-1])
with pytest.raises(RequestRejectedException) as e:
sdk_get_and_check_replies(looper, reqs[-1:])

with pytest.raises(AssertionError):
waitForSufficientRepliesForRequests(looper, client, requests=reqs[-1:])

for node in txnPoolNodeSet:
looper.run(eventually(checkRejectWithReason, client,
'Simulated rejection', node.clientstack.name,
retryWait=1))
assert 'Simulated rejection' in e._excinfo[1].args[0]

for i, node in enumerate(txnPoolNodeSet):
node.doDynamicValidation = origMethods[i]

0 comments on commit 6d71551

Please sign in to comment.