def test_dirty_read(looper, nodeSet, client1, wallet1): """ Tests the case when read request comes before write request is not executed on some nodes """ slow_nodes = list(nodeSet)[2:4] for node in slow_nodes: logger.debug("Making node {} slow".format(node)) make_node_slow(node) set_request = sendReqsToNodesAndVerifySuffReplies(looper, wallet1, client1, numReqs=1)[0] received_replies = getRepliesFromClientInbox(inbox=client1.inBox, reqId=set_request.reqId) seq_no = received_replies[0]["result"]["seqNo"] get_request = [wallet1.signOp({"type": GET_TXN, DATA: seq_no})] send_signed_requests(client1, get_request) waitForSufficientRepliesForRequests(looper, client1, requests=get_request) received_replies = getRepliesFromClientInbox(inbox=client1.inBox, reqId=get_request[0].reqId) results = [str(reply['result'][DATA]) for reply in received_replies] assert len(set(results)) == 1
def submit_operation_and_get_replies(looper, wallet, client, operation): request = wallet.signOp(operation) wallet.pendRequest(request) pending = wallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, client, requests=pending) return getRepliesFromClientInbox(client.inBox, request.reqId)
def test_state_proof_returned_for_get_attr(looper, addedRawAttribute, attributeName, attributeData, trustAnchor, trustAnchorWallet): """ Tests that state proof is returned in the reply for GET_ATTR transactions """ client = trustAnchor get_attr_operation = { TARGET_NYM: addedRawAttribute.dest, TXN_TYPE: GET_ATTR, RAW: attributeName } get_attr_request = trustAnchorWallet.signOp(get_attr_operation) trustAnchorWallet.pendRequest(get_attr_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) replies = getRepliesFromClientInbox(client.inBox, get_attr_request.reqId) expected_data = attrib_raw_data_serializer.deserialize(attributeData) for reply in replies: result = reply['result'] assert DATA in result data = attrib_raw_data_serializer.deserialize(result[DATA]) assert data == expected_data assert result[TXN_TIME] check_valid_proof(reply, client)
def test_state_proof_returned_for_missing_schema(looper, trustAnchor, trustAnchorWallet): """ Tests that state proof is returned in the reply for GET_NYM transactions """ client = trustAnchor dest = trustAnchorWallet.defaultId schema_name = "test_schema" schema_version = "1.0" get_schema_operation = { TARGET_NYM: dest, TXN_TYPE: GET_SCHEMA, DATA: { NAME: schema_name, VERSION: schema_version, } } get_schema_request = trustAnchorWallet.signOp(get_schema_operation) trustAnchorWallet.pendRequest(get_schema_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) replies = getRepliesFromClientInbox(client.inBox, get_schema_request.reqId) for reply in replies: result = reply['result'] assert ATTR_NAMES not in result[DATA] check_valid_proof(reply, client)
def test_state_proof_returned_for_get_schema(looper, trustAnchor, trustAnchorWallet): """ Tests that state proof is returned in the reply for GET_NYM transactions """ client = trustAnchor dest = trustAnchorWallet.defaultId schema_name = "test_schema" schema_version = "1.0" schema_attr_names = ["width", "height"] data = { NAME: schema_name, VERSION: schema_version, ATTR_NAMES: schema_attr_names } schema_operation = { TXN_TYPE: SCHEMA, DATA: data } nym_request = trustAnchorWallet.signOp(schema_operation) trustAnchorWallet.pendRequest(nym_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) get_schema_operation = { TARGET_NYM: dest, TXN_TYPE: GET_SCHEMA, DATA: { NAME: schema_name, VERSION: schema_version, } } get_schema_request = trustAnchorWallet.signOp(get_schema_operation) trustAnchorWallet.pendRequest(get_schema_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) replies = getRepliesFromClientInbox(client.inBox, get_schema_request.reqId) for reply in replies: result = reply['result'] assert DATA in result data = result.get(DATA) assert data assert ATTR_NAMES in data assert data[ATTR_NAMES] == schema_attr_names assert NAME in data assert VERSION in data assert result[TXN_TIME] check_valid_proof(reply, client)
def test_state_proof_returned_for_get_nym(looper, trustAnchor, trustAnchorWallet, userWalletA): """ Tests that state proof is returned in the reply for GET_NYM transactions """ client = trustAnchor dest = userWalletA.defaultId nym = { TARGET_NYM: dest, TXN_TYPE: NYM } nym_request = trustAnchorWallet.signOp(nym) trustAnchorWallet.pendRequest(nym_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) get_nym_operation = { TARGET_NYM: dest, TXN_TYPE: GET_NYM } get_nym_request = trustAnchorWallet.signOp(get_nym_operation) trustAnchorWallet.pendRequest(get_nym_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) replies = getRepliesFromClientInbox(client.inBox, get_nym_request.reqId) for reply in replies: result = reply['result'] assert DATA in result assert result[DATA] data = domain_state_serializer.deserialize(result[DATA]) assert ROLE in data assert VERKEY in data assert f.IDENTIFIER.nm in data assert result[TXN_TIME] check_valid_proof(reply, client)
def test_state_proof_returned_for_get_claim_def(looper, trustAnchor, trustAnchorWallet): """ Tests that state proof is returned in the reply for GET_NYM transactions """ client = trustAnchor dest = trustAnchorWallet.defaultId data = {"primary": {'N': '123'}, REVOCATION: {'h0': '456'}} claim_def_operation = { TXN_TYPE: CLAIM_DEF, REF: 12, DATA: data, SIGNATURE_TYPE: 'CL' } nym_request = trustAnchorWallet.signOp(claim_def_operation) trustAnchorWallet.pendRequest(nym_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) get_claim_def_operation = { ORIGIN: dest, TXN_TYPE: GET_CLAIM_DEF, REF: 12, SIGNATURE_TYPE: 'CL' } get_schema_request = trustAnchorWallet.signOp(get_claim_def_operation) trustAnchorWallet.pendRequest(get_schema_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) replies = getRepliesFromClientInbox(client.inBox, get_schema_request.reqId) expected_data = data for reply in replies: result = reply['result'] assert DATA in result data = result.get(DATA) assert data assert data == expected_data assert result[TXN_TIME] check_valid_proof(reply, client)
def test_state_proof_returned_for_missing_attr(looper, attributeName, trustAnchor, trustAnchorWallet): """ Tests that state proof is returned in the reply for GET_ATTR transactions """ client = trustAnchor get_attr_operation = { TARGET_NYM: trustAnchorWallet.defaultId, TXN_TYPE: GET_ATTR, RAW: attributeName } get_attr_request = trustAnchorWallet.signOp(get_attr_operation) trustAnchorWallet.pendRequest(get_attr_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) replies = getRepliesFromClientInbox(client.inBox, get_attr_request.reqId) for reply in replies: result = reply['result'] assert DATA not in result or result[DATA] is None check_valid_proof(reply, client)
def test_state_proof_returned_for_missing_claim_def(looper, trustAnchor, trustAnchorWallet): """ Tests that state proof is returned in the reply for GET_NYM transactions """ client = trustAnchor dest = trustAnchorWallet.defaultId get_claim_def_operation = { ORIGIN: dest, TXN_TYPE: GET_CLAIM_DEF, REF: 12, SIGNATURE_TYPE: 'CL' } get_schema_request = trustAnchorWallet.signOp(get_claim_def_operation) trustAnchorWallet.pendRequest(get_schema_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) replies = getRepliesFromClientInbox(client.inBox, get_schema_request.reqId) for reply in replies: result = reply['result'] assert DATA not in result or result[DATA] is None check_valid_proof(reply, client)
def test_state_proof_returned_for_missing_nym(looper, trustAnchor, trustAnchorWallet, userWalletA): """ Tests that state proof is returned in the reply for GET_NYM transactions """ client = trustAnchor # Make not existing id dest = userWalletA.defaultId dest = dest[:-3] dest += "fff" get_nym_operation = {TARGET_NYM: dest, TXN_TYPE: GET_NYM} get_nym_request = trustAnchorWallet.signOp(get_nym_operation) trustAnchorWallet.pendRequest(get_nym_request) pending = trustAnchorWallet.preparePending() client.submitReqs(*pending) waitForSufficientRepliesForRequests(looper, trustAnchor, requests=pending) replies = getRepliesFromClientInbox(client.inBox, get_nym_request.reqId) for reply in replies: result = reply['result'] assert DATA not in result or result[DATA] is None check_valid_proof(reply, client)
def chk(): receivedReplies = getRepliesFromClientInbox(client1.inBox, replied1.reqId) print(receivedReplies) assert len(receivedReplies) == nodeCount
def chk(): receivedReplies = getRepliesFromClientInbox(client1.inBox, replied1.reqId) assert len(receivedReplies) == nodeCount