Skip to content

Commit

Permalink
INDY-1370: revert to logic with client without digest …
Browse files Browse the repository at this point in the history
Signed-off-by: toktar <[email protected]>
  • Loading branch information
Toktar committed Jun 6, 2018
1 parent 9a70869 commit c872e14
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
5 changes: 3 additions & 2 deletions indy_client/anon_creds/indy_public_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def _ensureReqCompleted(reqKey, client, clbk):
reply, err = get_reply_if_confirmed(client, reqKey)
reply, err = get_reply_if_confirmed(client, *reqKey)
if err:
raise OperationError(err)

Expand Down Expand Up @@ -221,7 +221,8 @@ async def _sendReq(self, op, clbk):
# pass some other tests. The client was not getting a chance to
# service its stack, we need to find a way to stop this starvation.
resp = await eventually(_ensureReqCompleted,
req.key, self.client, clbk,
(req.identifier, req.reqId),
self.client, clbk,
timeout=20, retryWait=2)
except NoConsensusYet:
raise TimeoutError('Request timed out')
Expand Down
26 changes: 17 additions & 9 deletions indy_client/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ def getNymReply(reply, err, *args):
Token.BoldOrange)

self.looper.loop.call_later(.2, self._ensureReqCompleted,
req.key, self.activeClient, getNymReply)
(req.identifier, req.reqId),
self.activeClient, getNymReply)

def _addNym(self, nym, role, newVerKey=None,
otherClientName=None, custom_clb=None):
Expand Down Expand Up @@ -616,7 +617,7 @@ def out(reply, error, *args, **kwargs):

self.looper.loop.call_later(.2,
self._ensureReqCompleted,
req.key,
(req.identifier, req.reqId),
self.activeClient,
custom_clb or out)
return True
Expand Down Expand Up @@ -649,7 +650,8 @@ def out(reply, error, *args, **kwargs):
format(get_payload_data(reply)[TARGET_NYM]), Token.BoldBlue)

self.looper.loop.call_later(.2, self._ensureReqCompleted,
req.key, self.activeClient, out)
(req.identifier, req.reqId),
self.activeClient, out)

def _getAttr(self, nym, raw, enc, hsh):
assert int(bool(raw)) + int(bool(enc)) + int(bool(hsh)) == 1
Expand Down Expand Up @@ -686,7 +688,8 @@ def getAttrReply(reply, err, *args):
self.print("Attr not found")

self.looper.loop.call_later(.2, self._ensureReqCompleted,
req.key, self.activeClient, getAttrReply)
(req.identifier, req.reqId),
self.activeClient, getAttrReply)

def _getSchema(self, nym, name, version):
req = self.activeWallet.requestSchema(
Expand All @@ -706,7 +709,8 @@ def getSchema(reply, err, *args):
self.print('"data" must be in proper format', Token.Error)

self.looper.loop.call_later(.2, self._ensureReqCompleted,
req.key, self.activeClient, getSchema)
(req.identifier, req.reqId),
self.activeClient, getSchema)

def _getClaimDef(self, seqNo, signature):
req = self.activeWallet.requestClaimDef(
Expand All @@ -726,7 +730,8 @@ def getClaimDef(reply, err, *args):
self.print('"data" must be in proper format', Token.Error)

self.looper.loop.call_later(.2, self._ensureReqCompleted,
req.key, self.activeClient, getClaimDef)
(req.identifier, req.reqId),
self.activeClient, getClaimDef)

def _sendNodeTxn(self, nym, data):
node = Node(nym, data, self.activeDID)
Expand All @@ -748,7 +753,8 @@ def out(reply, error, *args, **kwargs):
Token.BoldBlue)

self.looper.loop.call_later(.2, self._ensureReqCompleted,
req.key, self.activeClient, out)
(req.identifier, req.reqId),
self.activeClient, out)

def _sendPoolUpgTxn(
self,
Expand Down Expand Up @@ -788,7 +794,8 @@ def out(reply, error, *args, **kwargs):
Token.BoldBlue)

self.looper.loop.call_later(.2, self._ensureReqCompleted,
req.key, self.activeClient, out)
(req.identifier, req.reqId),
self.activeClient, out)

def _sendPoolConfigTxn(self, writes, force=False):
poolConfig = PoolConfig(trustee=self.activeDID,
Expand All @@ -808,7 +815,8 @@ def out(reply, error, *args, **kwargs):
self.print("Pool config successful", Token.BoldBlue)

self.looper.loop.call_later(.2, self._ensureReqCompleted,
req.key, self.activeClient, out)
(req.identifier, req.reqId),
self.activeClient, out)

@staticmethod
def parseAttributeString(attrs):
Expand Down
5 changes: 3 additions & 2 deletions indy_client/utils/user_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ def performOperation(self, op):
self._client.submitReqs(req)

def getRequestResult(reqKey):
reply, error = get_reply_if_confirmed(self._client, reqKey)
reply, error = get_reply_if_confirmed(self._client, *reqKey)
if reply is None and error is None:
raise Exception("Request has not been completed yet")
else:
return reply, error

reply, error = self._looper.run(eventually(partial(getRequestResult,
req.key),
(req.identifier,
req.reqId)),
retryWait=.5,
timeout=5))
assert not error, error
Expand Down
8 changes: 4 additions & 4 deletions indy_common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def getNonce(length=32):
return "".join([random.choice(hexChars) for i in range(length)])


def get_reply_if_confirmed(client, key: str):
reply, status = client.getReply(key)
def get_reply_if_confirmed(client, identifier, request_id: int):
reply, status = client.getReply(identifier, request_id)
if status == 'CONFIRMED':
return reply, None
_, errors = \
client.reqRepStore.getAllReplies(key)
client.reqRepStore.getAllReplies(identifier, request_id)
if not errors:
return None, None
sender, error_reason = errors.popitem()
Expand All @@ -100,7 +100,7 @@ def ensureReqCompleted(
kwargs=None,
cond=None):

reply, err = get_reply_if_confirmed(client, reqKey)
reply, err = get_reply_if_confirmed(client, *reqKey)

if err is None and reply is None and (cond is None or not cond()):
loop.call_later(.2, ensureReqCompleted, loop,
Expand Down
8 changes: 4 additions & 4 deletions indy_node/test/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def sdk_add_raw_attribute(looper, sdk_pool_handle, sdk_wallet_handle, name, valu


def checkGetAttr(reqKey, trustAnchor, attrName, attrValue):
reply, status = trustAnchor.getReply(reqKey)
reply, status = trustAnchor.getReply(*reqKey)
assert reply
data = json.loads(reply.get(DATA))
assert status == "CONFIRMED" and \
Expand All @@ -210,9 +210,9 @@ def getAttribute(
attrib, sender=trustAnchorWallet.defaultId)
trustAnchor.submitReqs(req)
timeout = waits.expectedTransactionExecutionTime(len(trustAnchor.nodeReg))
return looper.run(eventually(checkGetAttr, req.key, trustAnchor,
attributeName, attributeValue, retryWait=1,
timeout=timeout))
return looper.run(eventually(checkGetAttr, (req.identifier, req.reqId),
trustAnchor, attributeName, attributeValue,
retryWait=1, timeout=timeout))


def sdk_get_attribute():
Expand Down
4 changes: 2 additions & 2 deletions scripts/enable_bls
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def send_node_txn(node_name, bls_key, steward_seed, node_dest):
try:
looper.run(
eventually(_ensureReqCompleted,
req.key, client,
(req.identifier, req.reqId), client,
timeout=20, retryWait=2))
added = True
except NoConsensusYet:
Expand Down Expand Up @@ -96,7 +96,7 @@ def __send_node_request(wallet, client,


def _ensureReqCompleted(reqKey, client):
reply, err = get_reply_if_confirmed(client, reqKey)
reply, err = get_reply_if_confirmed(client, *reqKey)
if err:
raise OperationError(err)

Expand Down

0 comments on commit c872e14

Please sign in to comment.