Skip to content

Commit

Permalink
[INDY-1171] Integrate pool_transactions tests with libindy (#541)
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]>

* Exception handling additional fixes

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

* Exception handling fixes. wrapper for builder

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

* little tests fix

Signed-off-by: ArtObr <[email protected]>
  • Loading branch information
ArtObr authored and ashcherbakov committed Mar 6, 2018
1 parent ee920ce commit 8a7df59
Show file tree
Hide file tree
Showing 21 changed files with 723 additions and 680 deletions.
5 changes: 5 additions & 0 deletions plenum/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
# ROLES
STEWARD = Roles.STEWARD.value
TRUSTEE = Roles.TRUSTEE.value
STEWARD_STRING = 'STEWARD'

# TXNs
NODE = PlenumTransactions.NODE.value
Expand Down Expand Up @@ -169,6 +170,7 @@ class LedgerState(IntEnum):
POOL_LEDGER_ID = 0
DOMAIN_LEDGER_ID = 1
CONFIG_LEDGER_ID = 2
INVALID_LEDGER_ID = 5908

VALID_LEDGER_IDS = (POOL_LEDGER_ID, DOMAIN_LEDGER_ID, CONFIG_LEDGER_ID)

Expand Down Expand Up @@ -196,3 +198,6 @@ class ReplicaHooks(UniqueSet):
RECV_PPR = 5
RECV_PR = 6
RECV_CM = 7


INVALID_SEQ_NO = -23
16 changes: 16 additions & 0 deletions plenum/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,19 @@ def __init__(self, expLen, actLen, *args, **kwargs):
ex_txt = 'Message len {} exceeded allowed limit of {}'.format(
actLen, expLen)
super().__init__(ex_txt, *args, **kwargs)


class RequestNackedException(Exception):
pass


class RequestRejectedException(Exception):
pass


class CommonSdkIOException(Exception):
pass


class PoolLedgerTimeoutException(Exception):
pass
2 changes: 1 addition & 1 deletion plenum/common/messages/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class NetworkPortField(FieldBase):
_base_types = (int,)

def _specific_validation(self, val):
if val < 0 or val > 65535:
if val <= 0 or val > 65535:
return 'network port out of the range 0-65535'


Expand Down
18 changes: 12 additions & 6 deletions plenum/test/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from plenum.client.wallet import Wallet
from plenum.common.constants import DOMAIN_LEDGER_ID, OP_FIELD_NAME, REPLY, REQACK, REQNACK, REJECT, \
CURRENT_PROTOCOL_VERSION
from plenum.common.exceptions import RequestNackedException, RequestRejectedException, CommonSdkIOException, \
PoolLedgerTimeoutException
from plenum.common.messages.node_messages import Reply, PrePrepare, Prepare, Commit
from plenum.common.types import f
from plenum.common.util import getNoInstances, get_utc_epoch
Expand Down Expand Up @@ -1057,14 +1059,18 @@ def get_res(task, done_list):
def sdk_check_reply(req_res):
req, res = req_res
if isinstance(res, ErrorCode):
raise AssertionError("Got an error with code {} for request {}"
.format(res, req))
if res == 307:
raise PoolLedgerTimeoutException('Got PoolLedgerTimeout for request {}'
.format(req))
else:
raise CommonSdkIOException('Got an error with code {} for request {}'
.format(res, req))
if res['op'] == REQNACK:
raise AssertionError("ReqNack of id {}. Reason: {}"
.format(req['reqId'], res['reason']))
raise RequestNackedException('ReqNack of id {}. Reason: {}'
.format(req['reqId'], res['reason']))
if res['op'] == REJECT:
raise AssertionError("Reject of id {}. Reason: {}"
.format(req['reqId'], res['reason']))
raise RequestRejectedException('Reject of id {}. Reason: {}'
.format(req['reqId'], res['reason']))


def sdk_get_and_check_replies(looper, sdk_req_resp: Sequence, timeout=None):
Expand Down
4 changes: 2 additions & 2 deletions plenum/test/input_validation/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ class NetworkPortField(TestFieldBase):

@property
def negative_test_cases(self):
return -1, 65535 + 1
return 0, -1, 65535 + 1

@property
def positive_test_cases(self):
return 0, 9700, 65535
return 0 + 1, 9700, 65535


class NetworkIpAddressField(TestFieldBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_different_ledger_request_interleave(tconf, looper, txnPoolNodeSet,
sigseed, verkey, bls_key, nodeIp, nodePort, clientIp, clientPort = \
prepare_new_node_data(tconf, tdir, next_node_name)
node_req = looper.loop.run_until_complete(
prepare_node_request(next_node_name, steward_did, clientIp,
prepare_node_request(steward_did, next_node_name, clientIp,
clientPort, nodeIp, nodePort, bls_key,
sigseed))

Expand Down
3 changes: 1 addition & 2 deletions plenum/test/pool_transactions/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def sdk_node_theta_added(looper,
new_node_name,
tdir,
tconf,
allPluginsPath,
nodeClass=testNodeClass)
allPluginsPath)
txnPoolNodeSet.append(new_node)
looper.run(checkNodesConnected(txnPoolNodeSet))
sdk_pool_refresh(looper, sdk_pool_handle)
Expand Down
Loading

0 comments on commit 8a7df59

Please sign in to comment.